Skip to content

Commit

Permalink
indexer: Remove retry logic
Browse files Browse the repository at this point in the history
The retry logic in the indexer's controller is faulty in that every action that may return a timeout error (the entry path to set retry to true) will also return a Terminal state along with the timeout error.  Therefore after pausing briefly in the retry statement it will then break due to the next state being Terminal. I think the correct way to fix this is to just remove the rety logic as it can also cause an empty index report to be written to the database and simplifying the code seems to be the best approach.

Signed-off-by: Iain Duncan <[email protected]>
  • Loading branch information
iainduncani committed Oct 31, 2023
1 parent 51d8993 commit ffed2b8
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions indexer/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func (s *Controller) Index(ctx context.Context, manifest *claircore.Manifest) (*
// Terminal state is encountered.
func (s *Controller) run(ctx context.Context) (err error) {
var next State
var retry bool
var w time.Duration

// As long as there's not an error and the current state isn't Terminal, run
// the corresponding function.
Expand All @@ -97,10 +95,6 @@ func (s *Controller) run(ctx context.Context) (err error) {
continue
case errors.Is(err, nil):
// OK
case errors.Is(err, context.DeadlineExceeded):
// Either the function's internal deadline or the parent's deadline
// was hit.
retry = true
case errors.Is(err, context.Canceled):
// The parent context was canceled and the stateFunc noticed.
// Continuing the loop should drop execution out of it.
Expand All @@ -122,22 +116,6 @@ func (s *Controller) run(ctx context.Context) (err error) {
err = setReportErr
break
}
if retry {
t := time.NewTimer(w)
select {
case <-ctx.Done():
case <-t.C:
}
t.Stop()
w = jitter()
retry = false
// Execution is in this conditional because err ==
// context.DeadlineExceeded, so reset the err value to make sure the
// loop makes it back to the error handling switch above. If the
// context was canceled, the loop will end there; if not, there will
// be a retry.
err = nil
}
// This if statement preserves current behaviour of not setting
// currentState to Terminal when it's returned. This should be an
// internal detail, but is codified in the tests (for now).
Expand Down

0 comments on commit ffed2b8

Please sign in to comment.