mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 07:37:33 +02:00
zero: rm extra call on start (#4474)
This commit is contained in:
parent
e0236d3737
commit
e64e682853
1 changed files with 9 additions and 18 deletions
|
@ -42,7 +42,7 @@ func (svc *Source) Run(
|
|||
svc.api = api
|
||||
svc.fileCachePath = fileCachePath
|
||||
|
||||
svc.tryLoadInitial(ctx)
|
||||
svc.tryLoadFromFile(ctx)
|
||||
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
eg.Go(func() error { return svc.watchUpdates(ctx) })
|
||||
|
@ -70,6 +70,14 @@ func (svc *Source) updateLoop(ctx context.Context) error {
|
|||
defer ticker.Stop()
|
||||
|
||||
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())
|
||||
|
||||
select {
|
||||
|
@ -78,14 +86,6 @@ func (svc *Source) updateLoop(ctx context.Context) error {
|
|||
case <-svc.checkForUpdate:
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,15 +116,6 @@ func (svc *Source) updateAndSave(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (svc *Source) tryLoadInitial(ctx context.Context) {
|
||||
err := svc.updateAndSave(ctx)
|
||||
if err != nil {
|
||||
log.Ctx(ctx).Error().Err(err).Msg("failed to load bootstrap config")
|
||||
svc.tryLoadFromFile(ctx)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *Source) tryLoadFromFile(ctx context.Context) {
|
||||
cfg, err := LoadBootstrapConfigFromFile(svc.fileCachePath, svc.fileCipher)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue