From 2f9ea5426a9ac277247b86b0057ab939c363cce6 Mon Sep 17 00:00:00 2001 From: Denis Mishin Date: Thu, 17 Aug 2023 16:45:51 -0400 Subject: [PATCH] check if an error is terminal during initial bootstrap loading --- internal/zero/bootstrap/bootstrap.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/zero/bootstrap/bootstrap.go b/internal/zero/bootstrap/bootstrap.go index 6cb176c70..5dad96ec3 100644 --- a/internal/zero/bootstrap/bootstrap.go +++ b/internal/zero/bootstrap/bootstrap.go @@ -42,7 +42,10 @@ func (svc *Source) Run( svc.api = api svc.fileCachePath = fileCachePath - svc.tryLoadInitial(ctx) + err := svc.tryLoadInitial(ctx) + if err != nil { + return err + } eg, ctx := errgroup.WithContext(ctx) eg.Go(func() error { return svc.watchUpdates(ctx) }) @@ -116,13 +119,16 @@ func (svc *Source) updateAndSave(ctx context.Context) error { return nil } -func (svc *Source) tryLoadInitial(ctx context.Context) { +func (svc *Source) tryLoadInitial(ctx context.Context) error { err := svc.updateAndSave(ctx) + if retry.IsTerminalError(err) { + return err + } if err != nil { log.Ctx(ctx).Error().Err(err).Msg("failed to load bootstrap config") svc.tryLoadFromFile(ctx) - return } + return nil } func (svc *Source) tryLoadFromFile(ctx context.Context) {