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

fix: ignore parsing logs of deleted scan jobs #950

Conversation

mycodeself
Copy link

@mycodeself mycodeself commented Feb 6, 2022

fixes #873 based on @py-go suggestion

Avoid retry parse deleted scan jobs handling the IsNotFound error and deleting the job.

@CLAassistant
Copy link

CLAassistant commented Feb 6, 2022

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #950 (c36e0fc) into main (ba43f89) will increase coverage by 0.17%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #950      +/-   ##
==========================================
+ Coverage   64.63%   64.81%   +0.17%     
==========================================
  Files          59       59              
  Lines        6982     6986       +4     
==========================================
+ Hits         4513     4528      +15     
+ Misses       2012     2004       -8     
+ Partials      457      454       -3     
Impacted Files Coverage Δ
pkg/kube/logs.go 35.84% <0.00%> (ø)
pkg/operator/controller/configauditreport.go 64.75% <0.00%> (+0.69%) ⬆️
pkg/operator/controller/ciskubebenchreport.go 58.22% <0.00%> (+4.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdab378...c36e0fc. Read the comment docs.

if errors.IsNotFound(err) {
log.V(1).Info("Ignoring not found job", "job", fmt.Sprintf("%s/%s", job.Namespace, job.Name), "owner", owner)
log.V(1).Info("Deleting complete scan job", "owner", owner)
return r.deleteJob(ctx, job)
Copy link
Contributor

@chen-keinan chen-keinan Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mycodeself Probably r.deleteJob will not find a job to delete, due to job not found.

Maybe it is better to return ctrl.Result{}, nil to remove it from the cache :
https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/internal/controller/controller.go#L332

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chen-keinan but return ctrl.Result{}, nil doesn't fit the signature of processCompleteScanJob it just returns an error. I guess that I should just return nil right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mycodeself FYI, The complete solution has been implemented by #956

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok @chen-keinan thanks for letting me know! I'll watch this PR to continue learning!

@danielpacak
Copy link
Contributor

Let's close this one and keep working on #956.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore parsing logs of scan jobs have been deleted
4 participants