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: Support for preserving dependencies charts archives (#16725) #16750

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

raz-amir
Copy link

@raz-amir raz-amir commented Jan 4, 2024

This PR adds a feature to allow keeping the dependency charts tgz files. These files are deleted by default as part of the git clean operation that takes place during the checkout flow in the repo server.
WIth this feature enabled, and with the default exclude pattern, git clean will be executed with the exclude flag
However, keeping the tgz files isn't enough, if the dependency version has advanced, since helm template doesn't check that and it succeeds anyway, and before this feature, for performance reasons, helm dependency build is executed only if helm template fails. Therefore, before running helm template we need to verify that the dependency charts versions are satisfied, so a new call to helm dependency list is added, and if no, helm dependency rebuild will be executed before helm template - just if this exclude feature is enabled.
--preserve-dependencies-charts-archives flag added to argocd-repo-server CLI.

Closes: #16725

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

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (ecbd24d) 49.50% compared to head (78a63ce) 49.32%.
Report is 55 commits behind head on master.

Files Patch % Lines
reposerver/repository/repository.go 91.89% 2 Missing and 1 partial ⚠️
util/git/client.go 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16750      +/-   ##
==========================================
- Coverage   49.50%   49.32%   -0.18%     
==========================================
  Files         271      274       +3     
  Lines       47793    48204     +411     
==========================================
+ Hits        23658    23779     +121     
- Misses      21796    22075     +279     
- Partials     2339     2350      +11     

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

@raz-amir raz-amir changed the title Support for keeping dependency charts tgz files feat: Support for keeping dependency charts tgz files Jan 5, 2024
@raz-amir raz-amir force-pushed the git_clean_exclude branch 2 times, most recently from d369544 to 54ec46b Compare January 7, 2024 08:18
@raz-amir raz-amir changed the title feat: Support for keeping dependency charts tgz files feat: Support for keeping dependency charts tgz files (#16725) Jan 7, 2024
@raz-amir raz-amir changed the title feat: Support for keeping dependency charts tgz files (#16725) feat: Support for preserving dependencies charts archives (#16725) Jan 7, 2024
@raz-amir raz-amir changed the title feat: Support for preserving dependencies charts archives (#16725) feat: Support for preserving dependencies charts archives (https://github.com/argoproj/argo-cd/issues/16725) Jan 7, 2024
@raz-amir raz-amir changed the title feat: Support for preserving dependencies charts archives (https://github.com/argoproj/argo-cd/issues/16725) feat: Support for preserving dependencies charts archives (#16725) Jan 7, 2024
Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Quick glance, just one small change.

@@ -1364,6 +1402,12 @@ func WithCMPTarExcludedGlobs(excludedGlobs []string) GenerateManifestOpt {
}
}

func WithPreserveDependenciesChartsArchives(val bool) GenerateManifestOpt {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a docstring here describing the flag?

Signed-off-by: Raz Amir <[email protected]>
Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

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

Thanks @ramir-savvy !! Overall PR looks good. Just one comment.

@@ -209,6 +211,7 @@ func NewCommand() *cobra.Command {
command.Flags().StringVar(&streamedManifestMaxExtractedSize, "streamed-manifest-max-extracted-size", env.StringFromEnv("ARGOCD_REPO_SERVER_STREAMED_MANIFEST_MAX_EXTRACTED_SIZE", "1G"), "Maximum size of streamed manifest archives when extracted")
command.Flags().StringVar(&helmManifestMaxExtractedSize, "helm-manifest-max-extracted-size", env.StringFromEnv("ARGOCD_REPO_SERVER_HELM_MANIFEST_MAX_EXTRACTED_SIZE", "1G"), "Maximum size of helm manifest archives when extracted")
command.Flags().BoolVar(&disableManifestMaxExtractedSize, "disable-helm-manifest-max-extracted-size", env.ParseBoolFromEnv("ARGOCD_REPO_SERVER_DISABLE_HELM_MANIFEST_MAX_EXTRACTED_SIZE", false), "Disable maximum size of helm manifest archives when extracted")
command.Flags().BoolVar(&preserveDependenciesChartsArchives, "preserve-dependencies-charts-archives", env.ParseBoolFromEnv("ARGOCD_REPO_PRESERVE_DEPENDENCIES_CHARTS_ARCHIVES", false), "Preserve dependencies charts archives during refresh")
Copy link
Member

Choose a reason for hiding this comment

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

As a new environment variable is added, can you add the variable to repo-server deployment?

Reference: https://github.com/argoproj/argo-cd/blob/master/manifests/base/repo-server/argocd-repo-server-deployment.yaml#L26

Copy link
Author

@raz-amir raz-amir Feb 1, 2024

Choose a reason for hiding this comment

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

Thank you @ishitasequeira!
I added the requested change and also added to additional manifest files that have similar functionality - let me know if I should keep or remove them and stay only with the file requested by you.

Copy link
Author

Choose a reason for hiding this comment

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

I removed that question as I just learned that the other files are auto generated

Signed-off-by: Raz Amir <[email protected]>
@crenshaw-dev
Copy link
Member

@ramir-savvy something I thought about: is this change going to allow an effective bypass of repo access restrictions?

For example, if App A (via Project A) has access to Parent chart and Child chart, App A will be able to pull the private Child chart. And the App B (via Project B) which has access to only the Parent chart will automatically get access to the private Child chart, because the chart is saved and cached.

Is my understanding correct?

@jcogilvie
Copy link

This looks like a desirable change to me, but I just wanted to confirm that is there a way to opt into pulling the latest dependency on a particular run.

Say I have chart A that depends on chart B at "~> 1.0.0"

I have 1.0.0 in cache, so dependency is satisfied.

But a bugfix is published in 1.0.1 that I would like to make sure is included going forward. How would I accomplish that? Is that already covered under a force refresh or similar?

@raz-amir
Copy link
Author

@crenshaw-dev , I believe you are right, I overlooked the project separation.
Any suggestion on what can be implemented to overcome this?

@raz-amir
Copy link
Author

@jcogilvie , good point. I think that this one is also a limitation of this feature. Today, as far as I know, there is no way to force the repo refresh. The only way to do this is to restart the repo server.
I am not sure if this is a valid solution too. Maybe just document this?

@crenshaw-dev , will be great to get your input on this one

@raz-amir
Copy link
Author

@crenshaw-dev, did you get the chance to think over the above concerns?
Maybe they can be considered as limitations of this feature (which isn't enabled by default) and documented as such?
Any other ideas will be great.
Thanks

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.

Reduce load on private registry by keeping charts tgz on 'git clean'
4 participants