Skip to content

feat: PreDelete hooks support (Issue #13975)#22288

Merged
agaudreault merged 55 commits intoargoproj:masterfrom
pedro-cs-ribeiro:pre-delete-hooks
Dec 5, 2025
Merged

feat: PreDelete hooks support (Issue #13975)#22288
agaudreault merged 55 commits intoargoproj:masterfrom
pedro-cs-ribeiro:pre-delete-hooks

Conversation

@pedro-cs-ribeiro
Copy link
Contributor

Closes #13975

This PR introduces PreDelete hooks for Argo CD. PreDelete hooks allow users to execute tasks before an application's resources are deleted, providing a way to perform graceful shutdowns, backup operations, or other cleanup tasks that should happen before resource deletion.

Implementation details:

The implementation follows the same pattern established for PostDelete hooks:

  • Adds PreDeleteFinalizerName constant
  • Implements Pre/UnSet/HasPreDeleteFinalizer methods
  • Adds hook detection logic via isPreDeleteHook()
  • Implements hook execution methods via executePreDeleteHooks() and cleanupPreDeleteHooks()
  • Updates application controller to respect the proper deletion order

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).
ArgoCD_PreDelete_Hook.mov

todaywasawesome and others added 8 commits March 10, 2025 17:03
Signed-off-by: Dan Garfield <dan@codefresh.io>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
…#22211)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
…rgoproj#22104) (argoproj#22208)

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
argoproj#22117)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
…delete-hooks

# Conflicts:
#	go.mod
#	go.sum
#	ui-test/package.json
@pedro-cs-ribeiro pedro-cs-ribeiro requested review from a team as code owners March 10, 2025 17:15
@bunnyshell
Copy link

bunnyshell bot commented Mar 10, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
@codecov
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.50%. Comparing base (0c6fa28) to head (418ff79).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
controller/appcontroller.go 62.79% 9 Missing and 7 partials ⚠️
controller/hook.go 87.30% 3 Missing and 5 partials ⚠️
pkg/apis/application/v1alpha1/types.go 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22288      +/-   ##
==========================================
+ Coverage   62.46%   62.50%   +0.04%     
==========================================
  Files         351      351              
  Lines       49502    49602     +100     
==========================================
+ Hits        30919    31002      +83     
- Misses      15622    15630       +8     
- Partials     2961     2970       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pedro-ribeiro-rci and others added 7 commits March 10, 2025 20:36
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
@xrow
Copy link

xrow commented Mar 25, 2025

Yesterday I was implementing a workaround because of this missing feature. Now I think holy sh*t cow there it is.

Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
@pedro-cs-ribeiro
Copy link
Contributor Author

@andrii-korotkov-verkada Thanks for the Review! I rebased the code correctly now and implemented some changes according to your review, please check.

Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

Overall LGTM.

pedro-cs-ribeiro and others added 9 commits October 8, 2025 10:29
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
@pedro-cs-ribeiro
Copy link
Contributor Author

Thanks for the review @agaudreault !

I just addressed all your comments and merged with the latest code, please take another look whenever you can.

@agaudreault agaudreault modified the milestones: v3.2, v3.3 Dec 5, 2025
Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

LGTM. I think the current code is solid and a good foundation for the future. User experience can be adapted as the feature usage grows 👍

@agaudreault agaudreault enabled auto-merge (squash) December 5, 2025 19:52
@agaudreault agaudreault added the for-release-blog-3-3 PR that should be highlighted in the Release Blog label Dec 5, 2025
@agaudreault agaudreault merged commit 3bf3d8a into argoproj:master Dec 5, 2025
33 of 34 checks passed
yuehaii pushed a commit to yuehaii/argo-cd that referenced this pull request Dec 11, 2025
Signed-off-by: Dan Garfield <dan@codefresh.io>
Signed-off-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
Co-authored-by: Dan Garfield <dan@codefresh.io>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrii Korotkov <137232734+andrii-korotkov-verkada@users.noreply.github.com>
Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com>
Co-authored-by: pedro-ribeiro-rci <pedro.ribeiro@rci.rogers.ca>
Co-authored-by: Pedro Ribeiro <pedro.ribeiro@cross-join.com>
Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
Co-authored-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
Signed-off-by: hai.yue <hai.yue@ingka.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for-release-blog-3-3 PR that should be highlighted in the Release Blog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pre-deletion resource hooks

Comments