From 6af838c3d1027f41d286ef21b2e52ae60315a358 Mon Sep 17 00:00:00 2001 From: Patrik Cyvoct Date: Wed, 28 Oct 2020 11:45:50 +0100 Subject: [PATCH] fix case when HC timeout is 0 Signed-off-by: Patrik Cyvoct --- .../apiserver/pkg/storage/storagebackend/factory/etcd3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go index cb32bfc9ed0..9a1618df8dd 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go @@ -92,7 +92,11 @@ func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) { return fmt.Errorf(errMsg) } client := clientValue.Load().(*clientv3.Client) - ctx, cancel := context.WithTimeout(context.Background(), c.HealthcheckTimeout) + healthcheckTimeout := storagebackend.DefaultHealthcheckTimeout + if c.HealthcheckTimeout != time.Duration(0) { + healthcheckTimeout = c.HealthcheckTimeout + } + ctx, cancel := context.WithTimeout(context.Background(), healthcheckTimeout) defer cancel() // See https://github.com/etcd-io/etcd/blob/c57f8b3af865d1b531b979889c602ba14377420e/etcdctl/ctlv3/command/ep_command.go#L118 _, err := client.Get(ctx, path.Join("/", c.Prefix, "health"))