Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check manifest to check index report #1131

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions indexer/controller/checkmanifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func checkManifest(ctx context.Context, s *Controller) (State, error) {
return Terminal, fmt.Errorf("failed to retrieve manifest: %w", err)
}
s.report = sr
if sr.State != IndexFinished.String() {
// The manifest has been processed with all the Scanners but the index report did not end up in the IndexFinished state.
// This means that something must have gone wrong along the way so reprocess the manifest again.
// Do not do any filtering of the Vscnrs as we do not went wrong during the scanning process.
return FetchLayers, nil
}

return Terminal, nil
}
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
Loading