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 <smirnov.andrey@gmail.com>
This commit is contained in:
Andrey Smirnov 2021-06-29 22:01:01 +03:00 committed by talos-bot
parent ee06dd69fc
commit 60d7360944

View File

@ -6,6 +6,7 @@ package cluster
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"sort" "sort"
@ -71,7 +72,12 @@ func (s *APIBootstrapper) Bootstrap(ctx context.Context, out io.Writer) error {
defer cancel() defer cancel()
if err = cli.Bootstrap(retryCtx, &machineapi.BootstrapRequest{}); err != nil { 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) return retry.ExpectedError(err)
} }