Skip to content

Add option to support foreground cascade deletion#11479

Merged
mattfarina merged 1 commit into
helm:mainfrom
MichaelMorrisEst:cascade
Apr 27, 2023
Merged

Add option to support foreground cascade deletion#11479
mattfarina merged 1 commit into
helm:mainfrom
MichaelMorrisEst:cascade

Conversation

@MichaelMorrisEst

@MichaelMorrisEst MichaelMorrisEst commented Oct 27, 2022

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Allows user to control if uninstall should not return until after pods have been deleted by specifying new option '--cascade' that uses kubernetes foreground cascade deletion
closes #10586

Special notes for your reviewer:
Unsure about one point of backwards compatibility, I've add comment in the relevant section of code in pkg/kube/inerface.go

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 27, 2022
@buccella

buccella commented Dec 2, 2022

Copy link
Copy Markdown

I'm interested in seeing this merged.

@MichaelMorrisEst maybe reviewers are passing this over due to the merge conflicts?

@paichinger

Copy link
Copy Markdown

Looking forward to this!

@MichaelMorrisEst

Copy link
Copy Markdown
Contributor Author

merge conflicts resolved

@buccella

Copy link
Copy Markdown

Looking to help move this along... can we get a maintainer to review? @mattfarina if you'd be so kind to take a look?

Comment thread cmd/helm/uninstall.go Outdated
f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation")
f.BoolVar(&client.KeepHistory, "keep-history", false, "remove all associated resources and mark the release as deleted, but retain the release history")
f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all the resources are deleted before returning. It will wait for as long as --timeout")
f.BoolVar(&client.Cascade, "cascade", false, "if set, all dependent resources are deleted before the deletion is completed")

@gjenkins8 gjenkins8 Jan 5, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(from helm dev call) Should we mimic kubectl delete --cascade:

    --cascade='background':
        Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents
        (e.g. Pods created by a ReplicationController). Defaults to background.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gjenkins8 for your suggestion. I have updated the implementation accordingly

Add --cascade=<background|foreground|orphan> option to helm uninstall
Current behaviour is hardcoded to background

Addresses issue: helm#10586

Signed-off-by: MichaelMorris <michael.morris@est.tech>
@MichaelMorrisEst

Copy link
Copy Markdown
Contributor Author

Resolved merge conflicts

@sabre1041

Copy link
Copy Markdown
Contributor

@MichaelMorrisEst taking a look at it now. will provide some feedback as soon as KubeCon concludes

@sabre1041 sabre1041 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@MichaelMorrisEst

Copy link
Copy Markdown
Contributor Author

Thanks @sabre1041 for the review, I appreciate you taking the time.
If another core-maintainer could review so can get merged that would be great. @scottrigby would you have time to take it?

@mattfarina mattfarina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I found one nit but it can be changed in a follow-up PR.

Comment thread pkg/action/uninstall.go
Comment on lines +242 to +244
default:
cfg.Log("uninstall: given cascade value: %s, defaulting to delete propagation background", cascadingFlag)
return v1.DeletePropagationBackground

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not validate the value passed in before using it? For an invalid value we could return an error. This would enforce the correct option. Sort of like validateCascadeFlag but for the API.

The more I think about it, the more I like using strings for DeletionPropagation as k8s is known to change APIs and this would let Helm gracefully handle any changes there.

@mattfarina mattfarina merged commit 3b74c13 into helm:main Apr 27, 2023
@felipecrs

Copy link
Copy Markdown
Contributor

Would it be possible to clarify the differences between orphan, background and foreground?

@MichaelMorrisEst

Copy link
Copy Markdown
Contributor Author

Would it be possible to clarify the differences between orphan, background and foreground?

See kubernetes documentation:
https://kubernetes.io/docs/concepts/architecture/garbage-collection/#cascading-deletion

iyuroch added a commit to iyuroch/go-helm-client that referenced this pull request Apr 29, 2025
we need IgnoreNotFound and DeletionPropagation for uninstalling as per
helm/helm#11479
martin-helmich pushed a commit to mittwald/go-helm-client that referenced this pull request Apr 29, 2025
we need IgnoreNotFound and DeletionPropagation for uninstalling as per
helm/helm#11479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm uninstall --wait doesn't actually wait for pods to be terminated

8 participants