feat: add Prune and Delete as application level sync option
Checklist:
- [x] 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.
- [x] The title of the PR states what changed and the related issues number (used for the release note).
- [x] The title of the PR conforms to the Toolchain Guide
- [x] I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
- [x] I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
- [x] Does this PR require documentation updates?
- [x] I've updated documentation as required by this PR.
- [x] I have signed off all my commits as required by DCO
- [x] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
- [x] My build is green (troubleshooting builds).
- [x] My new feature complies with the feature status guidelines.
- [x] 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).
My goal was mainly to add Prune/Delete=confirm as a sync option as the deletion confirmation acts on the whole Application already and it's way more convenient in our env to add it on the application level than as annotation on the resources actually deployed.
For consistency I also added Prune/Delete=false support there (separate commit).
And the UI option in when editing the sync policy for the Prune and Delete sync options
Closes https://github.com/argoproj/argo-cd/issues/23380
:x: Preview Environment undeployed from Bunnyshell
Available commands (reply to this comment):
- :rocket:
/bns:deployto deploy the environment
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 60.79%. Comparing base (492f712) to head (4720a94).
Additional details and impacted files
@@ Coverage Diff @@
## master #23370 +/- ##
=======================================
Coverage 60.78% 60.79%
=======================================
Files 351 351
Lines 60439 60468 +29
=======================================
+ Hits 36737 36760 +23
- Misses 20782 20786 +4
- Partials 2920 2922 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Could you create an issue describing what the issue/enhancement is and why this change is needed and link it to this PR and your gitops-engine PR?
Sure! I just did that here: https://github.com/argoproj/argo-cd/issues/23380
The deletion part LGTM. Maybe helpful to add a screenshot or video of the sync option working. Thanks
Maybe helpful to add a screenshot or video of the sync option working. Thanks
Sure, will try to provide a video later today!
(rebasing for the go.mod conflict below and bumping the gitops-engine fork, no other code change)
@pjiang-dev here is the video (I had to fix a dumb typo https://github.com/argoproj/gitops-engine/compare/13f9343d366f59f29905dda9c8ef4e6257a67c67..03789b820ebec73de41af43a35493983c1832e01 in the gitops-engine so thanks for making me double check :see_no_evil:)
https://github.com/user-attachments/assets/4cad277a-b821-46cb-94e8-c28cc1235a82
FYI here is the yaml that I am using in the video above:
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: test-prune-confirm
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/MrFreezeex/test-argocd-confirm.git
targetRevision: "testsyncopt"
path: test-prune
# path: test-empty
destination:
name: in-cluster
namespace: test-prune-confirm
syncPolicy:
automated: {}
syncOptions:
- Prune=confirm
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: test-prune-false
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/MrFreezeex/test-argocd-confirm.git
targetRevision: "testsyncopt"
path: test-prune
# path: test-empty
destination:
name: in-cluster
namespace: test-prune-false
syncPolicy:
automated: {}
syncOptions:
- Prune=false
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: test-delete-confirm
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/MrFreezeex/test-argocd-confirm.git
targetRevision: "testsyncopt"
path: test-delete
destination:
name: in-cluster
namespace: test-delete-confirm
syncPolicy:
automated: {}
syncOptions:
- Delete=confirm
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: test-delete-false
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://github.com/MrFreezeex/test-argocd-confirm.git
targetRevision: "testsyncopt"
path: test-delete
destination:
name: in-cluster
namespace: test-delete-false
syncPolicy:
automated: {}
syncOptions:
- Delete=false
Hi @agaudreault, kind reminder about this PR, would love to have your updated input on the matter whenever you have time do so :pray:
Would also be ace to see this merged - just upgraded Argo on all our clusters only to find out that the option isn't there yet, just the annotation on resources 😁
+1 I really need it
@agaudreault I added the change for the resource precedence as you suggested.
I also included the fix I did here https://github.com/argoproj/argo-cd/pull/23326 in a separate commit as this PR changed a bit the code related to that and the other PR won't really be applicable anymore. We could still keep the other fix PR as a cherry pick to the release branches if necessary. Although AFAIU no one complained about this bug and it's something that I discovered while developing this so it might be just fine to not cherry pick it :man_shrugging:.
Let me know WDYT of this new version :pray:
Hi @agaudreault small reminder about this PR in case it drop of your radar :pray: