Pārlūkot izejas kodu

Limit max backoff delay to 2 seconds for GRPC connection

Docker use default GRPC backoff strategy to reconnect to containerd when
connection is lost. and the delay time grows exponentially, until reaches 120s.

So Change the max delay time to 2s to avoid docker and containerd
connection failure.

Signed-off-by: Wentao Zhang <zhangwentao234@huawei.com>
Wentao Zhang 8 gadi atpakaļ
vecāks
revīzija
d3d8c77d19
1 mainītis faili ar 4 papildinājumiem un 2 dzēšanām
  1. 4 2
      libcontainerd/remote_unix.go

+ 4 - 2
libcontainerd/remote_unix.go

@@ -96,11 +96,13 @@ func New(stateDir string, options ...RemoteOption) (_ Remote, err error) {
 
 
 	// don't output the grpc reconnect logging
 	// don't output the grpc reconnect logging
 	grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
 	grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
-	dialOpts := append([]grpc.DialOption{grpc.WithInsecure()},
+	dialOpts := []grpc.DialOption{
+		grpc.WithInsecure(),
+		grpc.WithBackoffMaxDelay(2 * time.Second),
 		grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
 		grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
 			return net.DialTimeout("unix", addr, timeout)
 			return net.DialTimeout("unix", addr, timeout)
 		}),
 		}),
-	)
+	}
 	conn, err := grpc.Dial(r.rpcAddr, dialOpts...)
 	conn, err := grpc.Dial(r.rpcAddr, dialOpts...)
 	if err != nil {
 	if err != nil {
 		return nil, fmt.Errorf("error connecting to containerd: %v", err)
 		return nil, fmt.Errorf("error connecting to containerd: %v", err)