-
Notifications
You must be signed in to change notification settings - Fork 6.2k
feat: add Prune and Delete as application level sync option #23370
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
base: master
Are you sure you want to change the base?
Conversation
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
f5381c1
to
b2ca286
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #23370 +/- ##
=======================================
Coverage 60.15% 60.15%
=======================================
Files 343 343
Lines 59004 59041 +37
=======================================
+ Hits 35494 35517 +23
- Misses 20657 20661 +4
- Partials 2853 2863 +10 ☔ View full report in Codecov by Sentry. |
b2ca286
to
5d5a4c3
Compare
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.
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: #23380 |
The deletion part LGTM. Maybe helpful to add a screenshot or video of the sync option working. Thanks |
docs/user-guide/sync-options.md
Outdated
@@ -14,6 +14,17 @@ metadata: | |||
argocd.argoproj.io/sync-options: Prune=false | |||
``` | |||
|
|||
It also can be enabled at the application level like in the example below: |
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.
Also just one question, if an application's resource has prune=true enabled, but the application has prune=false, which one takes priority? I am assuming resource level should take priority ? Same with the other options.
If not documented somewhere already i think its worth mentioning in the docs
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.
The Prune/Delete=true are not an actual thing, it's just something added in the UI that can act as a default option. Prune=helloworld would be similarly handled technically :p.
For the rest of the options there is not really a priority thing currently, both behavior will apply. For instance if you have Delete=confirm and Delete=false on some resources it will ask you for confirmation and do not delete the resource marked as delete=false (and similarly with prune). I will add clarification for that in docs, thanks!
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.
Done! Let me know if the new doc is more clear!
5d5a4c3
to
5ab9a2b
Compare
Sure, will try to provide a video later today! |
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
As deletion confirmation acts on the whole Application it could makes sense to add it as a sync option rather than a resource annotation. It also could be more convenient to integrate in certain workflows for users. Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
(rebasing for the go.mod conflict below and bumping the gitops-engine fork, no other code change) |
98975a0
to
12498ec
Compare
@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 🙈) recording.mp4 |
FYI here is the yaml that I am using in the video above:
|
Note that setting a Prune sync option on the application level will not override | ||
the same sync option set on a specific resource, both will still be applied. |
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.
Which one has the precedence? What happens if prune=false on the application level, but prune=confirm on the resource?
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.
It will apply both, in this case you will get a confirmation prompt and no resources will be pruned
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.
(This is the current behavior proposed by this PR but I can definitely take a look at figuring out some precedence policy if you want resource overriding app level or the other way around)
It also can be enabled at the application level like in the example below: | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
spec: | ||
syncPolicy: | ||
syncOptions: | ||
- Prune=confirm | ||
``` | ||
|
||
Note that setting a Prune sync option on the application level will not override | ||
the same sync option set on a specific resource, both will still be applied. | ||
|
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.
Instead of repeating the doc, specify that the same value can be use either through the annotation or the sync option.
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.
I don't mind doing that but IIUC adding both like that is consistent with the current doc, for instance ServerSideApply: https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#server-side-apply
ui/src/app/applications/components/application-sync-options/application-sync-options.tsx
Show resolved
Hide resolved
@@ -338,3 +338,5 @@ replace ( | |||
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.33.1 | |||
k8s.io/sample-controller => k8s.io/sample-controller v0.33.1 | |||
) | |||
|
|||
replace github.com/argoproj/gitops-engine => github.com/MrFreezeex/gitops-engine v0.0.0-20250617130229-7f8ccfc83e5f |
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.
Remove when ready to merge
For consistency with Prune/Delete=confirm that are now present as application level sync option add Prune/Delete=false as sync option too. Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
12498ec
to
38e4817
Compare
Checklist:
DO NOT MERGE AS IS, depends on: argoproj/gitops-engine#734
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 #23380