-
Notifications
You must be signed in to change notification settings - Fork 61
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: update owner references #773
fix: update owner references #773
Conversation
Codecov Report
@@ Coverage Diff @@
## main #773 +/- ##
=======================================
Coverage 14.83% 14.83%
=======================================
Files 13 13
Lines 1496 1496
=======================================
Hits 222 222
Misses 1253 1253
Partials 21 21
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, but overall LGTM. I'd like to see an e2e test proving this out. Tests prevent regression and double as documentation.
err = r.Delete(ctx, &template) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
err = r.Delete(ctx, &template) | |
if err != nil { | |
if err := r.Delete(ctx, &template); err != nil { |
err = r.Get(ctx, | ||
types.NamespacedName{ | ||
Namespace: eraserUtils.GetNamespace(), | ||
Name: job.GetName(), | ||
}, | ||
&template, | ||
) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = r.Get(ctx, | |
types.NamespacedName{ | |
Namespace: eraserUtils.GetNamespace(), | |
Name: job.GetName(), | |
}, | |
&template, | |
) | |
if err != nil { | |
if err := r.Get(ctx, | |
types.NamespacedName{ | |
Namespace: eraserUtils.GetNamespace(), | |
Name: job.GetName(), | |
}, | |
&template, | |
); err != nil { |
err = r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"}) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
err = r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"}) | |
if err != nil { | |
if err := r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"}); err != nil { |
err = r.Get(ctx, | ||
types.NamespacedName{ | ||
Namespace: eraserUtils.GetNamespace(), | ||
Name: job.GetName(), | ||
}, | ||
&template, | ||
) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
err = r.Delete(ctx, &template) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
err = r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"}) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job!
What this PR does / why we need it:
Fixes owner references to clean up all pods when deleting Eraser deployment. Eraser pods' owner references are now set to the jobtemplate, and the jobtemplate's owner references are set to the controller manager pod.
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when the PR gets merged):Fixes #634
Special notes for your reviewer:
Since ImageJob is not an object it does not have ObjectMeta field to set an owner reference.