Skip to content

feat: Implement caching for pulling OCI charts#2171

Merged
yxxhero merged 1 commit into
helmfile:mainfrom
mustdiechik:oci_cache
Sep 13, 2025
Merged

feat: Implement caching for pulling OCI charts#2171
yxxhero merged 1 commit into
helmfile:mainfrom
mustdiechik:oci_cache

Conversation

@mustdiechik

Copy link
Copy Markdown
Contributor

To avoid pulling chart from OCI registries for each time.

It is pain for large releases and high network latency.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements caching for OCI charts by modifying the chart pulling mechanism to use a persistent cache directory instead of temporary directories. The goal is to improve performance for large releases and high network latency scenarios by avoiding repeated chart downloads.

Key changes:

  • Modified getOCIChart function to accept full ChartPrepareOptions instead of just the output directory template
  • Introduced persistent cache directory using os.TempDir() + "/helmfile-oci-cache"
  • Added logic to conditionally clear cached charts based on SkipDeps and SkipRefresh options

Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go
Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go Outdated
@yxxhero

yxxhero commented Sep 8, 2025

Copy link
Copy Markdown
Member

@mustdiechik did you test this locally? and maybe we should add some docs for this feature?

@mustdiechik mustdiechik marked this pull request as draft September 9, 2025 06:46
@mustdiechik mustdiechik force-pushed the oci_cache branch 3 times, most recently from 445cca1 to f7e776c Compare September 10, 2025 05:08
@mustdiechik mustdiechik marked this pull request as ready for review September 10, 2025 05:08
@mustdiechik mustdiechik force-pushed the oci_cache branch 2 times, most recently from 2f9e5e1 to aeea415 Compare September 10, 2025 11:34
@mustdiechik

Copy link
Copy Markdown
Contributor Author

@mustdiechik did you test this locally? and maybe we should add some docs for this feature?

Yes, I tested build on working repos and via 'make test".
I think this behavior does not need to be documented, bc current behavior is logical (looks like helm):

  • pull chart/version once for releases which used this chart
  • be able to use a chart from cache (--skip-...)
    Please check current version.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go Outdated
Comment thread pkg/state/state.go Outdated
}

pathElems = append(pathElems, release.Name, chartName, safeVersionPath(chartVersion))
pathElems = append(pathElems, release.Chart, safeVersionPath(release.Version))

Copilot AI Sep 11, 2025

Copy link

Choose a reason for hiding this comment

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

Using release.Chart directly in the path may cause issues when the chart name contains special characters or path separators. The original code used chartName which was likely sanitized. Consider extracting just the chart name portion from release.Chart or applying path sanitization.

Suggested change
pathElems = append(pathElems, release.Chart, safeVersionPath(release.Version))
_, chartName := st.GetRepositoryAndNameFromChartName(release.Chart)
pathElems = append(pathElems, chartName, safeVersionPath(release.Version))

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@mustdiechik

Copy link
Copy Markdown
Contributor Author

@yxxhero fixed concurrency issue. tested with go run --race ... , now there are not any problems with it on big OCI repos.

@mustdiechik mustdiechik marked this pull request as draft September 11, 2025 14:12
@mustdiechik mustdiechik marked this pull request as ready for review September 12, 2025 04:54
@yxxhero yxxhero merged commit d646b3c into helmfile:main Sep 13, 2025
13 checks passed
@mustdiechik mustdiechik deleted the oci_cache branch September 14, 2025 00:28
KATechDev pushed a commit to KATechDev/helmfile that referenced this pull request Oct 1, 2025
Signed-off-by: Ruslan Khizhnyak <[email protected]>
Co-authored-by: Ruslan Khizhnyak <[email protected]>
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.

3 participants