mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
Merge pull request #118857 from dims/better-backoff-delays-and-connection-timeout-talking-to-containerd
Better back off delays and connection timeout to talk to containerd
This commit is contained in:
commit
6cb0308dbf
@ -56,11 +56,7 @@ func NewRemoteImageService(endpoint string, connectionTimeout time.Duration, tp
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
dialOpts := []grpc.DialOption{
|
var dialOpts []grpc.DialOption
|
||||||
grpc.WithConnectParams(grpc.ConnectParams{
|
|
||||||
Backoff: backoff.DefaultConfig,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
dialOpts = append(dialOpts,
|
dialOpts = append(dialOpts,
|
||||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
grpc.WithContextDialer(dialer),
|
grpc.WithContextDialer(dialer),
|
||||||
@ -77,6 +73,16 @@ func NewRemoteImageService(endpoint string, connectionTimeout time.Duration, tp
|
|||||||
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(tracingOpts...)))
|
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(tracingOpts...)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connParams := grpc.ConnectParams{
|
||||||
|
Backoff: backoff.DefaultConfig,
|
||||||
|
}
|
||||||
|
connParams.MinConnectTimeout = minConnectionTimeout
|
||||||
|
connParams.Backoff.BaseDelay = baseBackoffDelay
|
||||||
|
connParams.Backoff.MaxDelay = maxBackoffDelay
|
||||||
|
dialOpts = append(dialOpts,
|
||||||
|
grpc.WithConnectParams(connParams),
|
||||||
|
)
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, addr, dialOpts...)
|
conn, err := grpc.DialContext(ctx, addr, dialOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "Connect remote image service failed", "address", addr)
|
klog.ErrorS(err, "Connect remote image service failed", "address", addr)
|
||||||
|
@ -56,6 +56,11 @@ type remoteRuntimeService struct {
|
|||||||
const (
|
const (
|
||||||
// How frequently to report identical errors
|
// How frequently to report identical errors
|
||||||
identicalErrorDelay = 1 * time.Minute
|
identicalErrorDelay = 1 * time.Minute
|
||||||
|
|
||||||
|
// connection parameters
|
||||||
|
maxBackoffDelay = 3 * time.Second
|
||||||
|
baseBackoffDelay = 100 * time.Millisecond
|
||||||
|
minConnectionTimeout = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// CRIVersion is the type for valid Container Runtime Interface (CRI) API
|
// CRIVersion is the type for valid Container Runtime Interface (CRI) API
|
||||||
@ -80,11 +85,7 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration, t
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
dialOpts := []grpc.DialOption{
|
var dialOpts []grpc.DialOption
|
||||||
grpc.WithConnectParams(grpc.ConnectParams{
|
|
||||||
Backoff: backoff.DefaultConfig,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
dialOpts = append(dialOpts,
|
dialOpts = append(dialOpts,
|
||||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
grpc.WithContextDialer(dialer),
|
grpc.WithContextDialer(dialer),
|
||||||
@ -100,6 +101,17 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration, t
|
|||||||
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(tracingOpts...)),
|
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(tracingOpts...)),
|
||||||
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(tracingOpts...)))
|
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor(tracingOpts...)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connParams := grpc.ConnectParams{
|
||||||
|
Backoff: backoff.DefaultConfig,
|
||||||
|
}
|
||||||
|
connParams.MinConnectTimeout = minConnectionTimeout
|
||||||
|
connParams.Backoff.BaseDelay = baseBackoffDelay
|
||||||
|
connParams.Backoff.MaxDelay = maxBackoffDelay
|
||||||
|
dialOpts = append(dialOpts,
|
||||||
|
grpc.WithConnectParams(connParams),
|
||||||
|
)
|
||||||
|
|
||||||
conn, err := grpc.DialContext(ctx, addr, dialOpts...)
|
conn, err := grpc.DialContext(ctx, addr, dialOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "Connect remote runtime failed", "address", addr)
|
klog.ErrorS(err, "Connect remote runtime failed", "address", addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user