helmfile/pkg
Aditya Menon e89bb56b62
fix: add double-check locking for in-memory chart cache
When multiple workers concurrently process releases using the same chart,
they all check the in-memory cache before acquiring locks. If none have
populated the cache yet, all workers miss and try to download.

Previously, even after acquiring the exclusive lock, the code would
re-download the chart when needsRefresh=true (the default). This caused
multiple "Pulling" messages in tests like oci_chart_pull_once.

The fix adds a second in-memory cache check AFTER acquiring the lock.
This implements proper double-check locking:

1. Check cache (outside lock) → miss
2. Acquire lock
3. Check cache again (inside lock) → hit if another worker populated it
4. If still miss, download and add to cache

This ensures only one worker downloads the chart, while others use
the cached version populated by the first worker.

Changes:
- Add in-memory cache double-check in getOCIChart() after acquiring lock
- Add in-memory cache double-check in forcedDownloadChart() after acquiring lock

This fixes the oci_chart_pull_once and oci_chart_pull_direct test failures
where charts were being pulled multiple times instead of once.

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>
2025-11-27 11:08:48 +01:00
..
app fix: replace 60s timeout with reader-writer locks for OCI chart caching 2025-11-27 11:08:47 +01:00
argparser fix #1095 (#1100) 2023-11-01 11:55:55 +08:00
cluster 🐛 Fix four critical issues: environment merging, kubeVersion detection, lookup() with kustomize, and Helm 4 color flags (#2276) 2025-11-21 08:32:54 +08:00
config feat: add Helm 4 support while maintaining Helm 3 compatibility (#2262) 2025-11-19 07:49:30 +08:00
environment Fix four critical bugs: array merging (#2281), AWS SDK logging (#2270), helmDefaults skip flags (#2269), and OCI chart versions (#2247) (#2288) 2025-11-22 09:27:51 +08:00
envvar Fix AWS SDK debug logging by making it configurable (issue #2270) (#2290) 2025-11-24 18:27:04 +08:00
errors build(deps): bump golangci/golangci-lint-action from 6 to 7 (#1975) 2025-03-28 07:52:06 +08:00
event feat: include func support (#1187) 2023-12-04 21:51:01 +08:00
exectest fix: resolve issues #2295, #2296, #2297 and OCI registry login 2025-11-27 11:08:47 +01:00
filesystem refactor(filesystem): add CopyDir method and optimize Fetch function (#2111) 2025-07-28 16:10:25 -04:00
hcllang feat: update go version and adjust dependencies in Dockerfile and go.mod (#1722) 2024-09-30 09:21:44 -04:00
helmexec 🐛 Fix four critical issues: environment merging, kubeVersion detection, lookup() with kustomize, and Helm 4 color flags (#2276) 2025-11-21 08:32:54 +08:00
maputil Fix four critical bugs: array merging (#2281), AWS SDK logging (#2270), helmDefaults skip flags (#2269), and OCI chart versions (#2247) (#2288) 2025-11-22 09:27:51 +08:00
plugins Fix AWS SDK debug logging by making it configurable (issue #2270) (#2290) 2025-11-24 18:27:04 +08:00
policy build(deps): bump golangci/golangci-lint-action from 6 to 7 (#1975) 2025-03-28 07:52:06 +08:00
remote Fix AWS SDK debug logging by making it configurable (issue #2270) (#2290) 2025-11-24 18:27:04 +08:00
runtime refactor(yaml): switch yaml library import paths from gopkg.in to go.yaml.in (#2114) 2025-08-01 11:28:39 +08:00
state fix: add double-check locking for in-memory chart cache 2025-11-27 11:08:48 +01:00
testhelper perf(app): Parallelize helmfile.d rendering and eliminate chdir race conditions (#2261) 2025-11-15 16:19:41 +08:00
testutil feat: add Helm 4 support while maintaining Helm 3 compatibility (#2262) 2025-11-19 07:49:30 +08:00
tmpl refactor(yaml): switch yaml library import paths from gopkg.in to go.yaml.in (#2114) 2025-08-01 11:28:39 +08:00
yaml refactor(yaml): switch yaml library import paths from gopkg.in to go.yaml.in (#2114) 2025-08-01 11:28:39 +08:00