Skip to content

Conversation

@MrFreezeex
Copy link
Contributor

@MrFreezeex MrFreezeex commented Jun 12, 2025

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).

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

@bunnyshell
Copy link

bunnyshell bot commented Jun 12, 2025

❌ Preview Environment undeployed from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch 2 times, most recently from f5381c1 to b2ca286 Compare June 12, 2025 12:50
@codecov
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ 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     

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

@MrFreezeex MrFreezeex marked this pull request as ready for review June 12, 2025 15:07
@MrFreezeex MrFreezeex requested review from a team as code owners June 12, 2025 15:07
@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch from b2ca286 to 5d5a4c3 Compare June 12, 2025 15:16
Copy link
Contributor

@pjiang-dev pjiang-dev left a 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?

@MrFreezeex
Copy link
Contributor Author

MrFreezeex commented Jun 13, 2025

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

@MrFreezeex MrFreezeex requested a review from pjiang-dev June 13, 2025 08:23
@pjiang-dev
Copy link
Contributor

The deletion part LGTM. Maybe helpful to add a screenshot or video of the sync option working. Thanks

@pjiang-dev pjiang-dev added the ready-for-review An approver should give a final review and merge the PR label Jun 13, 2025
@github-project-automation github-project-automation bot moved this to Ready for final review in Argo CD Review Jun 13, 2025
argocd.argoproj.io/sync-options: Prune=false
```
It also can be enabled at the application level like in the example below:
Copy link
Contributor

@pjiang-dev pjiang-dev Jun 13, 2025

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

Copy link
Contributor Author

@MrFreezeex MrFreezeex Jun 16, 2025

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!

Copy link
Contributor Author

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!

@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch from 5d5a4c3 to 5ab9a2b Compare June 16, 2025 11:13
@MrFreezeex
Copy link
Contributor Author

Maybe helpful to add a screenshot or video of the sync option working. Thanks

Sure, will try to provide a video later today!

@MrFreezeex
Copy link
Contributor Author

(rebasing for the go.mod conflict below and bumping the gitops-engine fork, no other code change)

@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch 2 times, most recently from 98975a0 to 12498ec Compare June 17, 2025 13:38
@MrFreezeex
Copy link
Contributor Author

@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

@MrFreezeex
Copy link
Contributor Author

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

Comment on lines 52 to 65
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.

Copy link
Member

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.

Copy link
Contributor Author

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

@github-project-automation github-project-automation bot moved this from Ready for final review to Changes Requested in Argo CD Review Jun 17, 2025
@agaudreault agaudreault added this to the v3.2 milestone Jun 17, 2025
@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch from 12498ec to 38e4817 Compare June 17, 2025 14:58
@MrFreezeex MrFreezeex requested a review from agaudreault June 19, 2025 20:48
@MrFreezeex
Copy link
Contributor Author

MrFreezeex commented Jul 7, 2025

Hi @agaudreault, kind reminder about this PR, would love to have your updated input on the matter whenever you have time do so 🙏

@shearn89
Copy link

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 😁

@sharovmerk
Copy link

+1 I really need it

@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch 3 times, most recently from fc8fca0 to a42b925 Compare September 26, 2025 13:44
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.

Waiting for changes over the resource annotation precedence. Other than that, feature looks good 👍

@MrFreezeex MrFreezeex force-pushed the sync-option-confirm branch 4 times, most recently from 36ccce0 to 3d4d8d1 Compare October 10, 2025 18:35
@MrFreezeex MrFreezeex marked this pull request as draft October 12, 2025 09:39
This will facilitate adding logic on sync options that can be defined
both at the app and resource level and the resource level should
override the app level option.

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
Add support for Delete sync options on the application level. The
Delete sync option at the application level is only changing the
"default behavior" for resources deployed by this application.

The behavior is still to process this at the resource level and the resource
level always override the app level Delete option.

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
Add support for Prune sync options on the application level. The
Prune sync option at the application level is only changing the
"default behavior" for resources deployed by this application.

The behavior is still to process this at the resource level and the resource
level always override the app level Prune option.

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
Prune=confirm was correctly wired everywhere but the UI was still
relying on Delete=confirm to show the "Confirm Pruning" button. Meaning
that if an app was containing Prune=confirm resource and no resources
Delete=confirm the button would never show up in the UI!

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
@MrFreezeex MrFreezeex marked this pull request as ready for review October 13, 2025 13:43
@MrFreezeex
Copy link
Contributor Author

MrFreezeex commented Oct 13, 2025

@agaudreault I added the change for the resource precedence as you suggested.

I also included the fix I did here #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 🤷‍♂️.

Let me know WDYT of this new version 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review An approver should give a final review and merge the PR

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

Add deletion confirmation as an application level sync option

5 participants