浏览代码

Merge pull request #33483 from moypray/grpc_timeout

Limit max backoff delay to 2 seconds for GRPC connection
Kenfe-Mickaël Laventure 8 年之前
父节点
当前提交
8420e7e7f5
共有 1 个文件被更改,包括 4 次插入2 次删除
  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
 	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) {
 			return net.DialTimeout("unix", addr, timeout)
 		}),
-	)
+	}
 	conn, err := grpc.Dial(r.rpcAddr, dialOpts...)
 	if err != nil {
 		return nil, fmt.Errorf("error connecting to containerd: %v", err)