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: Introduce diff normalizer knobs and allow for ignoring aggregated cluster roles (#2382) #3076

Merged
merged 17 commits into from
May 13, 2020

Conversation

jannfis
Copy link
Member

@jannfis jannfis commented Feb 3, 2020

This PR introduces options for the diff normalizer to allow tuning its behaviour for well-known K8s behaviours.

The first use case is to ignore the rules in aggregated cluster roles, which are dynamically determined by K8s at runtime and would be out-of-sync always. This will fix #2382

A new setting resource.compareoptions is introduced in argocd-cm, which hold knobs to control behaviour of the diff normalizer.

By setting ignoreAggregratedRoles in resource.compareoptions to true, the rules will not be considered for determining the sync state of the role.

The default value of ignoreAggregratedRoles will be false to not change behaviour from previous versions of ArgoCD.

The new knob can be set like follows in argocd-cm:

resource.compareoptions: |
    ignoreAggregatedRoles: true

It's only valid system wide, not on a per-application basis.

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).
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Optional. My organization is added to the README.
  • I've signed the CLA and my build is green (troubleshooting builds).

compareOptions, err := m.settingsMgr.GetResourceCompareOptions()
if err != nil {
log.Warnf("Could not get compare options from ConfigMap (assuming defaults): %v", err)
compareOptions = diff.GetDefaultDiffOptions()
Copy link
Member Author

Choose a reason for hiding this comment

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

Since CompareAppState does not return faulty (no error return value), I deliberately chose to use default compare options if we can not get the options from the settings manager.

@codecov
Copy link

codecov bot commented Feb 3, 2020

Codecov Report

Merging #3076 into master will decrease coverage by 5.38%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3076      +/-   ##
==========================================
- Coverage   44.47%   39.09%   -5.39%     
==========================================
  Files         184       49     -135     
  Lines       21006     1407   -19599     
  Branches      275      238      -37     
==========================================
- Hits         9342      550    -8792     
+ Misses      10625      854    -9771     
+ Partials     1039        3    -1036     
Impacted Files Coverage Δ
ui/src/app/applications/components/utils.tsx 49.83% <0.00%> (ø)
ui/src/app/shared/services/projects-service.ts 19.71% <0.00%> (ø)
util/dex/config.go
util/rand/rand.go
util/util.go
util/hook/helm/type.go
util/hook/helm/hook.go
util/app/path/path.go
controller/cache/node.go
cmd/argocd/commands/project.go
... and 122 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f822d09...cc48d7f. Read the comment docs.

@jannfis jannfis marked this pull request as ready for review February 3, 2020 07:56
@jannfis
Copy link
Member Author

jannfis commented Feb 3, 2020

@jessesuen This is the second attempt to introduce #2382, and I followed your (absolutely correct) suggestions from previous PR #2422 (which probably was way overengineered). I think the current approach is better and more simple.

@alexmt I understand that this change interferes a little with changes in #3066 - it's up to you wether we merge this one first and adapt changes in #3066, or merge #3066 first and then adapt changes here for further merging.

@jannfis jannfis requested a review from alexmt March 6, 2020 20:44
@jannfis jannfis force-pushed the feat/2382-aggr-cluster-roles2 branch from 90b950f to a5d17ab Compare March 6, 2020 21:21
@jannfis jannfis requested a review from jessesuen March 13, 2020 20:14
Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Support for aggregated ClusterRoles
2 participants