mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #84345 from danielqsj/withdialer
replace grpc.WithDialer which is deprecated
This commit is contained in:
commit
d6412b856f
@ -11,11 +11,6 @@ pkg/controller/podgc
|
|||||||
pkg/controller/replicaset
|
pkg/controller/replicaset
|
||||||
pkg/controller/resourcequota
|
pkg/controller/resourcequota
|
||||||
pkg/controller/statefulset
|
pkg/controller/statefulset
|
||||||
pkg/kubelet/apis/podresources
|
|
||||||
pkg/kubelet/cm/devicemanager
|
|
||||||
pkg/kubelet/pluginmanager/operationexecutor
|
|
||||||
pkg/kubelet/pluginmanager/pluginwatcher
|
|
||||||
pkg/kubelet/remote
|
|
||||||
pkg/probe/http
|
pkg/probe/http
|
||||||
pkg/registry/autoscaling/horizontalpodautoscaler/storage
|
pkg/registry/autoscaling/horizontalpodautoscaler/storage
|
||||||
pkg/registry/core/namespace/storage
|
pkg/registry/core/namespace/storage
|
||||||
|
@ -36,7 +36,7 @@ func GetClient(socket string, connectionTimeout time.Duration, maxMsgSize int) (
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("error dialing socket %s: %v", socket, err)
|
return nil, nil, fmt.Errorf("error dialing socket %s: %v", socket, err)
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ func (m *Stub) Register(kubeletEndpoint, resourceName string, pluginSockDir stri
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, kubeletEndpoint, grpc.WithInsecure(), grpc.WithBlock(),
|
conn, err := grpc.DialContext(ctx, kubeletEndpoint, grpc.WithInsecure(), grpc.WithBlock(),
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout("unix", addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
|
||||||
}))
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -177,8 +177,8 @@ func dial(unixSocketPath string) (pluginapi.DevicePluginClient, *grpc.ClientConn
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout("unix", addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -193,8 +193,8 @@ func dial(unixSocketPath string, timeout time.Duration) (registerapi.Registratio
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout("unix", addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ func dial(unixSocketPath string, timeout time.Duration) (registerapi.Registratio
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
c, err := grpc.DialContext(ctx, unixSocketPath, grpc.WithInsecure(), grpc.WithBlock(),
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout("unix", addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func NewRemoteImageService(endpoint string, connectionTimeout time.Duration) (in
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Connect remote image service %s failed: %v", addr, err)
|
klog.Errorf("Connect remote image service %s failed: %v", addr, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -56,7 +56,7 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) (
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dailer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Connect remote runtime %s failed: %v", addr, err)
|
klog.Errorf("Connect remote runtime %s failed: %v", addr, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -19,13 +19,13 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
@ -78,8 +78,8 @@ func CreateListener(endpoint string) (net.Listener, error) {
|
|||||||
return l, nil
|
return l, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAddressAndDialer returns the address parsed from the given endpoint and a dialer.
|
// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer.
|
||||||
func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
|
func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) {
|
||||||
protocol, addr, err := parseEndpointWithFallbackProtocol(endpoint, unixProtocol)
|
protocol, addr, err := parseEndpointWithFallbackProtocol(endpoint, unixProtocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
@ -91,8 +91,8 @@ func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout tim
|
|||||||
return addr, dial, nil
|
return addr, dial, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dial(addr string, timeout time.Duration) (net.Conn, error) {
|
func dial(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout(unixProtocol, addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, unixProtocol, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEndpointWithFallbackProtocol(endpoint string, fallbackProtocol string) (protocol string, addr string, err error) {
|
func parseEndpointWithFallbackProtocol(endpoint string, fallbackProtocol string) (protocol string, addr string, err error) {
|
||||||
|
@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
@ -29,8 +30,8 @@ func CreateListener(endpoint string) (net.Listener, error) {
|
|||||||
return nil, fmt.Errorf("CreateListener is unsupported in this build")
|
return nil, fmt.Errorf("CreateListener is unsupported in this build")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAddressAndDialer returns the address parsed from the given endpoint and a dialer.
|
// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer.
|
||||||
func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
|
func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) {
|
||||||
return "", nil, fmt.Errorf("GetAddressAndDialer is unsupported in this build")
|
return "", nil, fmt.Errorf("GetAddressAndDialer is unsupported in this build")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -53,8 +54,8 @@ func CreateListener(endpoint string) (net.Listener, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAddressAndDialer returns the address parsed from the given endpoint and a dialer.
|
// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer.
|
||||||
func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
|
func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) {
|
||||||
protocol, addr, err := parseEndpoint(endpoint)
|
protocol, addr, err := parseEndpoint(endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
@ -71,12 +72,12 @@ func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout tim
|
|||||||
return "", nil, fmt.Errorf("only support tcp and npipe endpoint")
|
return "", nil, fmt.Errorf("only support tcp and npipe endpoint")
|
||||||
}
|
}
|
||||||
|
|
||||||
func tcpDial(addr string, timeout time.Duration) (net.Conn, error) {
|
func tcpDial(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return net.DialTimeout(tcpProtocol, addr, timeout)
|
return (&net.Dialer{}).DialContext(ctx, tcpProtocol, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func npipeDial(addr string, timeout time.Duration) (net.Conn, error) {
|
func npipeDial(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return winio.DialPipe(addr, &timeout)
|
return winio.DialPipeContext(ctx, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEndpoint(endpoint string) (string, string, error) {
|
func parseEndpoint(endpoint string) (string, string, error) {
|
||||||
|
@ -496,8 +496,8 @@ func newGrpcConn(addr csiAddr) (*grpc.ClientConn, error) {
|
|||||||
return grpc.Dial(
|
return grpc.Dial(
|
||||||
string(addr),
|
string(addr),
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
grpc.WithDialer(func(target string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithContextDialer(func(ctx context.Context, target string) (net.Conn, error) {
|
||||||
return net.Dial(network, target)
|
return (&net.Dialer{}).DialContext(ctx, network, target)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user