mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-06 11:28:10 +02:00
check if an error is terminal during initial bootstrap loading
This commit is contained in:
parent
2f9ea5426a
commit
27bbe742bb
1 changed files with 9 additions and 24 deletions
|
@ -42,10 +42,7 @@ func (svc *Source) Run(
|
||||||
svc.api = api
|
svc.api = api
|
||||||
svc.fileCachePath = fileCachePath
|
svc.fileCachePath = fileCachePath
|
||||||
|
|
||||||
err := svc.tryLoadInitial(ctx)
|
svc.tryLoadFromFile(ctx)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
eg.Go(func() error { return svc.watchUpdates(ctx) })
|
eg.Go(func() error { return svc.watchUpdates(ctx) })
|
||||||
|
@ -73,6 +70,14 @@ func (svc *Source) updateLoop(ctx context.Context) error {
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
err := retry.Retry(ctx,
|
||||||
|
"update bootstrap", svc.updateAndSave,
|
||||||
|
retry.WithWatch("bootstrap config updated", svc.checkForUpdate, nil),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("update bootstrap config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
ticker.Reset(svc.updateInterval.Load())
|
ticker.Reset(svc.updateInterval.Load())
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@ -81,14 +86,6 @@ func (svc *Source) updateLoop(ctx context.Context) error {
|
||||||
case <-svc.checkForUpdate:
|
case <-svc.checkForUpdate:
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
}
|
}
|
||||||
|
|
||||||
err := retry.Retry(ctx,
|
|
||||||
"update bootstrap", svc.updateAndSave,
|
|
||||||
retry.WithWatch("bootstrap config updated", svc.checkForUpdate, nil),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("update bootstrap config: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,18 +116,6 @@ func (svc *Source) updateAndSave(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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 nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Source) tryLoadFromFile(ctx context.Context) {
|
func (svc *Source) tryLoadFromFile(ctx context.Context) {
|
||||||
cfg, err := LoadBootstrapConfigFromFile(svc.fileCachePath, svc.fileCipher)
|
cfg, err := LoadBootstrapConfigFromFile(svc.fileCachePath, svc.fileCipher)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue