From 60d7360944ff6fc1e75f98e37a754f3bb2962144 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 29 Jun 2021 22:01:01 +0300 Subject: [PATCH] fix: ignore deadline exceeded errors on bootstrap With the recent changes, bootstrap API might wait for the time to be in sync (as the apid is launched before time is sync). We set timeout to 500ms for the bootstrap API call, so there's a chance that a call might time out, and we should ignore it. Signed-off-by: Andrey Smirnov --- pkg/cluster/bootstrap.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/bootstrap.go b/pkg/cluster/bootstrap.go index bc78dc6a4..80ee8e6c6 100644 --- a/pkg/cluster/bootstrap.go +++ b/pkg/cluster/bootstrap.go @@ -6,6 +6,7 @@ package cluster import ( "context" + "errors" "fmt" "io" "sort" @@ -71,7 +72,12 @@ func (s *APIBootstrapper) Bootstrap(ctx context.Context, out io.Writer) error { defer cancel() if err = cli.Bootstrap(retryCtx, &machineapi.BootstrapRequest{}); err != nil { - if status.Code(err) == codes.FailedPrecondition || strings.Contains(err.Error(), "connection refused") { + switch { + case errors.Is(err, context.DeadlineExceeded): + return retry.ExpectedError(err) + case status.Code(err) == codes.FailedPrecondition || status.Code(err) == codes.DeadlineExceeded: + return retry.ExpectedError(err) + case strings.Contains(err.Error(), "connection refused"): return retry.ExpectedError(err) }