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: update owner references #773

Merged
merged 10 commits into from
Jul 28, 2023

Conversation

ashnamehrotra
Copy link
Contributor

@ashnamehrotra ashnamehrotra commented Jun 28, 2023

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.

@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2023

Codecov Report

Merging #773 (4c39ff4) into main (1fe18f5) will not change coverage.
Report is 3 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #773   +/-   ##
=======================================
  Coverage   14.83%   14.83%           
=======================================
  Files          13       13           
  Lines        1496     1496           
=======================================
  Hits          222      222           
  Misses       1253     1253           
  Partials       21       21           
Flag Coverage Δ
unittests 14.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@pmengelbert pmengelbert left a 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.

Comment on lines 271 to 272
err = r.Delete(ctx, &template)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
err = r.Delete(ctx, &template)
if err != nil {
if err := r.Delete(ctx, &template); err != nil {

Comment on lines 260 to 267
err = r.Get(ctx,
types.NamespacedName{
Namespace: eraserUtils.GetNamespace(),
Name: job.GetName(),
},
&template,
)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 {

Comment on lines 474 to 475
err = r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"})
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
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 {

Comment on lines 238 to 245
err = r.Get(ctx,
types.NamespacedName{
Namespace: eraserUtils.GetNamespace(),
Name: job.GetName(),
},
&template,
)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Comment on lines 250 to 251
err = r.Delete(ctx, &template)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Comment on lines 388 to 389
err = r.List(ctx, &podList, client.InNamespace(utils.GetNamespace()), client.MatchingLabels{"control-plane": "controller-manager"})
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

@pmengelbert pmengelbert left a comment

Choose a reason for hiding this comment

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

LGTM, great job!

@ashnamehrotra ashnamehrotra merged commit 575b3ef into eraser-dev:main Jul 28, 2023
84 checks passed
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.

Deleting the eraser deployment should delete collector + eraser pods
3 participants