Skip to content

Commit

Permalink
Retry running a CRD Manager if it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev committed Dec 2, 2024
1 parent 2b16ff0 commit ed8dbe7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions internal/component/prometheus/operator/common/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,22 @@ func (c *Component) Run(ctx context.Context) error {
innerCtx, cancel = context.WithCancel(ctx)
wg.Add(1)
go func() {
if err := manager.Run(innerCtx); err != nil {
level.Error(c.opts.Logger).Log("msg", "error running crd manager", "err", err)
errChan <- err
defer wg.Done()
retryInterval := 0 * time.Second
for {
select {
case <-innerCtx.Done():
//TODO: Log that the manager is exiting?
return
case <-time.After(retryInterval):
if err := manager.Run(innerCtx); err != nil {
level.Error(c.opts.Logger).Log("msg", "error running crd manager", "err", err)
errChan <- err
//TODO: What is a good default value for this?
retryInterval = 30 * time.Second
}
}
}
wg.Done()
}()
c.mut.Unlock()
}
Expand Down

0 comments on commit ed8dbe7

Please sign in to comment.