Skip to content

Commit

Permalink
fix(cli): retry polling on-demand CTR scan status
Browse files Browse the repository at this point in the history
There are sometimes that the API returns the scan status as
successful without any vulnerabilities, as if the assessment had no
vulnerabilities, but if you query it again, the assessment does have
vulnerabilities.

Workaround: Retry the polling mechanism twice on success :(

JIRA: RAIN-12964

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Aug 21, 2020
1 parent 27f5197 commit d14ea35
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cli/cmd/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,33 @@ func setDetailsFlag(cmds ...*flag.FlagSet) {
func pollScanStatus(requestID string) error {
cli.StartProgress(" Scan running...")

// @afiune bug: there are sometimes that the API returns the scan status as
// successful without any vulnerabilities, as if the assessment had none, but
// if you query it again, the assessment does have vulnerabilities.
//
// JIRA: RAIN-12964
// Workaround: Retry the polling mechanism twice on success :(
bugRetry := true
for {
assessment, err, retry := checkScanStatus(requestID)
if err != nil {
return err
}

if retry {
cli.Log.Debugw("waiting for a retry", "request_id", requestID, "sleep", vulCmdState.PollInterval)
time.Sleep(vulCmdState.PollInterval)
continue
}

// @afiune bug: there are sometimes that the API returns the scan status as
// successful without any vulnerabilities, as if the assessment had none, but
// if you query it again, the assessment does have vulnerabilities.
//
// JIRA: RAIN-12964
// Workaround: Retry the polling mechanism twice on success :(
if bugRetry {
bugRetry = false
time.Sleep(vulCmdState.PollInterval)
continue
}
Expand Down

0 comments on commit d14ea35

Please sign in to comment.