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

fix: overrides should not appear in the manifest cache key #9601

Merged
merged 4 commits into from Jun 15, 2022

Conversation

crenshaw-dev
Copy link
Collaborator

@crenshaw-dev crenshaw-dev commented Jun 7, 2022

Currently, git-based parameter overrides appear in the manifest cache key.

That's a problem, because parameter overrides aren't known when the cache get occurs. Overrides shouldn't be in the cache key, because getting parameter overrides is a repo operation, and the entire point of the cache is to avoid repo operations.

So this change makes sure that overrides do not become part of the cache key. Changes to overrides will still bust the cache, because the changes will cause a change in the revision component of the key.

Case for cherry-picking: we have a 2.4 user who's spending a lot of money on git fetches. I think this is a fairly safe change, and it would help them out.

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
@@ -985,7 +989,7 @@ func mergeSourceParameters(source *v1alpha1.ApplicationSource, path, appName str
overrides = append(overrides, filepath.Join(path, fmt.Sprintf(appSourceFile, appName)))
}

var merged v1alpha1.ApplicationSource = *source.DeepCopy()
var merged = *source.DeepCopy()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The explicit type was redundant.

@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #9601 (6647e03) into master (0d0d09f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 6647e03 differs from pull request most recent head 33bb894. Consider uploading reports for the commit 33bb894 to get more accurate results

@@           Coverage Diff           @@
##           master    #9601   +/-   ##
=======================================
  Coverage   45.83%   45.83%           
=======================================
  Files         222      222           
  Lines       26405    26406    +1     
=======================================
+ Hits        12102    12103    +1     
  Misses      12652    12652           
  Partials     1651     1651           
Impacted Files Coverage Δ
reposerver/repository/repository.go 61.42% <100.00%> (+0.04%) ⬆️

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 0d0d09f...33bb894. Read the comment docs.

@crenshaw-dev crenshaw-dev marked this pull request as draft June 8, 2022 15:33
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
@crenshaw-dev crenshaw-dev marked this pull request as ready for review June 8, 2022 17:09
@crenshaw-dev crenshaw-dev added the cherry-pick/2.4 Candidate for cherry picking into the 2.4 release branch label Jun 8, 2022
@crenshaw-dev crenshaw-dev requested a review from leoluz June 8, 2022 18:02
Copy link
Collaborator

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

LGTM

@leoluz leoluz merged commit 91de2f3 into argoproj:master Jun 15, 2022
@crenshaw-dev crenshaw-dev deleted the overrides-in-cache-key branch June 15, 2022 15:46
@crenshaw-dev
Copy link
Collaborator Author

Cherry-picked onto release-2.4 for release with 2.4.3.

crenshaw-dev added a commit that referenced this pull request Jun 22, 2022
* fix: overrides should not appear in the manifest cache key

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix Helm regression

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix test

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix test again

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
@arloliu
Copy link

arloliu commented Jun 29, 2022

I think the plugin environment modification should invalidate the cache too. (e.g. argocd app set <app_name> --plugin-env ...)
When we change the plugin environments on the fly, the current manifest doesn't be invalidated, and it will cause the app to stay in the synced state, the following app sync operation will not take the new environment variable.

@crenshaw-dev
Copy link
Collaborator Author

@arloliu I'm surprised that plugin env vars aren't breaking the cache. They're part of the ApplicationSource object. Is there an issue already created for the problem you're hitting?

@arloliu
Copy link

arloliu commented Jun 29, 2022

It's the problem I met these days.
I tested it with a simple CMP shell script and directory app.
the behavior is:

  1. argocd app set <app_name> --plugin-env TEST_ENV=test
  2. argocd app sync <app_name>

the CMP will receive the TEST_ENV when executing generate procedure in step 2, but the app will not sync with the new manifest even CMP produces a new manifest.(e.g. change replicas number)

And if we use the following steps.

  1. argocd app set <app_name> --plugin-env TEST_ENV=test
  2. argocd app get <app_name> --hard-refresh
  3. argocd app sync <app_name>

The cache will be invalidated in step 2, and step 3 will use the manifest that CMP generated, but the problem is, step 2 also cleans the TEST_ENV before it invokes CMP generate.

BTW, the step 2 invokes CMP generate 3 times if the app's git repo had updated.

@crenshaw-dev
Copy link
Collaborator Author

Can you create an issue with those reprod. steps?

BTW, the step 2 invokes CMP generate 3 times if the app's git repo had updated.

Can you create an additional issue for this? :-)

@arloliu
Copy link

arloliu commented Jun 29, 2022

sure, I'll create a issue for it.
the cache is a bit weird, it remembers all histories of plugin env.
that's said:
if we never set TEST_ENV plugin env.

  1. set TEST_ENV=a it invokes CMP generate
  2. set TEST_ENV=b it invokes CMP generate
  3. set TEST_ENV=a again, it will not invoke CMP generate
    But it should invoke CMP because `TEST_ENV value already changed.

@crenshaw-dev
Copy link
Collaborator Author

That's exceptionally strange. Definitely something we want to sort out.

@arloliu
Copy link

arloliu commented Jul 1, 2022

Thanks for your help, I fill the info. and created a issue here:
#9844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/2.4 Candidate for cherry picking into the 2.4 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants