Skip to content
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

feat: add enable field for automatedSync #21999

Merged
merged 13 commits into from
Mar 21, 2025

Conversation

anandrkskd
Copy link
Contributor

@anandrkskd anandrkskd commented Feb 25, 2025

Adding enable field to explicitly set in automatedSync in SyncPolicy

Fixes #21647

This PR add a boolean field named enable in Spec.SyncPolicy.Automated for explicitly enabling or disabling automatedSync.
These changes don't affect the current behaviour.
This field can be set using

spec:
  syncPolicy:
    automated:
      enable: true

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

Copy link

bunnyshell bot commented Feb 25, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@anandrkskd
Copy link
Contributor Author

@andrii-korotkov-verkada can you also recommend what would be the best place for documenting this change, I was able to find one doc that might be a good place to mentaion this change.

@andrii-korotkov-verkada
Copy link
Contributor

Yeah, that doc looks good

@anandrkskd anandrkskd force-pushed the add-enable-field-in-automatedSync branch 2 times, most recently from 29f8a81 to 6538e23 Compare March 5, 2025 04:41
@anandrkskd anandrkskd changed the title add enable field for automatedSync feat: add enable field for automatedSync Mar 5, 2025
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 57.14286% with 9 lines in your changes missing coverage. Please review.

Project coverage is 55.89%. Comparing base (2ce593b) to head (36510cf).
Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
server/application/application.go 0.00% 0 Missing and 4 partials ⚠️
cmd/util/app.go 0.00% 3 Missing ⚠️
...cationset/controllers/applicationset_controller.go 0.00% 1 Missing ⚠️
cmd/argocd/commands/app.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21999      +/-   ##
==========================================
+ Coverage   55.87%   55.89%   +0.01%     
==========================================
  Files         343      343              
  Lines       57331    57332       +1     
==========================================
+ Hits        32034    32044      +10     
+ Misses      22649    22639      -10     
- Partials     2648     2649       +1     

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

@anandrkskd anandrkskd marked this pull request as ready for review March 10, 2025 06:49
@anandrkskd anandrkskd requested review from a team as code owners March 10, 2025 06:49
Copy link
Contributor

@andrii-korotkov-verkada andrii-korotkov-verkada left a comment

Choose a reason for hiding this comment

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

Mostly lgtm, but seems like we can simplify by returning bool instead of pointer to bool

@anandrkskd
Copy link
Contributor Author

Lint tests are failing with these errors

Error: controller/appcontroller_test.go:616:102: context.Background() could be replaced by t.Context() in TestAutoSyncEnabledSetToTrue (usetesting)
  	app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(test.FakeArgoCDNamespace).Get(context.Background(), "my-app", metav1.GetOptions{})
  	                                                                                                    ^
  Error: controller/appcontroller_test.go:744:103: context.Background() could be replaced by t.Context() in TestSkipAutoSync (usetesting)
  		app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(test.FakeArgoCDNamespace).Get(context.Background(), "my-app", metav1.GetOptions{})

when I tried fixing this I didnt see any methods in t named Context. Is this expected?

@aali309
Copy link
Contributor

aali309 commented Mar 11, 2025

Lint tests are failing with these errors

Error: controller/appcontroller_test.go:616:102: context.Background() could be replaced by t.Context() in TestAutoSyncEnabledSetToTrue (usetesting)
  	app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(test.FakeArgoCDNamespace).Get(context.Background(), "my-app", metav1.GetOptions{})
  	                                                                                                    ^
  Error: controller/appcontroller_test.go:744:103: context.Background() could be replaced by t.Context() in TestSkipAutoSync (usetesting)
  		app, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(test.FakeArgoCDNamespace).Get(context.Background(), "my-app", metav1.GetOptions{})

when I tried fixing this I didnt see any methods in t named Context. Is this expected?

This golangci-lint issue can be fixed by updating golangci-lint version to 1.24.1 and running make lint-local

@anandrkskd
Copy link
Contributor Author

This golangci-lint issue can be fixed by updating golangci-lint version to 1.24.1 and running make lint-local

I can not see any 1.24.1 release on the golangci-lint releases page

Adding enable field to explicitly set in automatedSync in SyncPolicy

Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
Signed-off-by: Anand Kumar Singh <[email protected]>
@anandrkskd anandrkskd force-pushed the add-enable-field-in-automatedSync branch from 3ff96eb to 8b0c6ca Compare March 17, 2025 05:52
Signed-off-by: Anand Kumar Singh <[email protected]>
@anandrkskd anandrkskd force-pushed the add-enable-field-in-automatedSync branch from 8b0c6ca to e140abc Compare March 17, 2025 07:26
Copy link
Member

@anandf anandf left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. I have some nits, PTAL.

Signed-off-by: Anand Kumar Singh <[email protected]>
@anandrkskd anandrkskd force-pushed the add-enable-field-in-automatedSync branch from a5cc14a to 36510cf Compare March 19, 2025 19:49
Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM

@jannfis jannfis merged commit 432a0cd into argoproj:master Mar 21, 2025
27 checks passed
@ChristianCiach
Copy link
Contributor

ChristianCiach commented Mar 21, 2025

Is it too late to change the name of the flag from enable to enabled? It is conventional to name such a flag enabled. For example, there are countless of examples of attributes called .enabled in https://github.com/argoproj/argo-cd/blob/master/manifests/install.yaml, but not a single one called .enable. The Go-code also calls this flag Is...Enabled everywhere, so this is bound to cause confusion later.

@anandrkskd
Copy link
Contributor Author

Is it too late to change the name of the flag from enable to enabled? It is conventional to name such a flag enabled. For example, there are countless of examples of attributes called .enabled in https://github.com/argoproj/argo-cd/blob/master/manifests/install.yaml, but not a single one called .enable. The Go-code also calls this flag Is...Enabled everywhere, so this is bound to cause confusion later.

I can create a new PR updating the field name to beenabled

@anandrkskd
Copy link
Contributor Author

Opened up a PR to update field name.

PaulSonOfLars pushed a commit to PaulSonOfLars/argo-cd that referenced this pull request Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A dedicated field to enable or disable application syncPolicy
6 participants