8000
Skip to content

fix(downloader): prevent concurrent file access errors on Windows#31128

Merged
joejulian merged 1 commit intohelm:mainfrom
orgads:win-parallel
Feb 11, 2026
Merged

fix(downloader): prevent concurrent file access errors on Windows#31128
joejulian merged 1 commit intohelm:mainfrom
orgads:win-parallel

Conversation

@orgads
Copy link
Copy Markdown
Contributor
@orgads orgads commented Aug 11, 2025

What this PR does / why we need it:
When multiple processes try to download the same chart version concurrently (e.g., via Terraform), they can race to write the destination file. On Windows, this results in 'Access Denied' errors because the file cannot be renamed while another process has a handle to the destination.

This commit introduces 'PlatformAtomicWriteFile' to the fileutil package. On Unix-like systems, it simply delegates to AtomicWriteFile, maintaining existing behavior. On Windows, it coordinates writes using a lock file (.lock). It acquires the lock, then performs the atomic write.

Crucially, this implementation ensures that existing files are overwritten (rather than skipped). This ensures that if a chart is republished with the same version, the local cache is correctly updated, preventing stale data issues.

Fixes #31633

Signed-off-by: Orgad Shaneh orgad.shaneh@audiocodes.com

Special notes for your reviewer:

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

Copy link
Copy Markdown
Contributor
@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

You might want to wait for feedback on other maintainers, but maybe make a LockedAtomicWirteFile to fileutils instead of this and definitely don't use a goto in that.

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Aug 11, 2025

You might want to wait for feedback on other maintainers, but maybe make a LockedAtomicWirteFile to fileutils instead of this and definitely don't use a goto in that.

Thank you! Done.

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Aug 21, 2025

ping?

Comment thread internal/fileutil/fileutil.go Outdated
@orgads orgads force-pushed the win-parallel branch 2 times, most recently from 1285e06 to f678f68 Compare August 24, 2025 09:55
@orgads orgads requested a review from TerryHowe August 24, 2025 11:32
@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Sep 1, 2025

ping

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Sep 1, 2025

Please review this. It hits me all the time when working on Windows. See hashicorp/terraform-provider-helm#1683.

Comment thread internal/fileutil/fileutil.go Outdated
Comment thread internal/fileutil/fileutil.go Outdated
@orgads orgads force-pushed the win-parallel branch 3 times, most recently from 5bb0120 to 436aaf1 Compare September 7, 2025 06:53
TerryHowe
TerryHowe previously approved these changes Sep 7, 2025
Copy link
Copy Markdown
Contributor
@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Nov 9, 2025

ping?

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Nov 16, 2025

Anybody? @gjenkins8 @robertsirc @scottrigby?

@SeanKilleen
Copy link
Copy Markdown

Especially with the Helm 4.0 announcement, it would be great to get this in so that the basics of Helm continue to work solidly for everyone. I hit this issue multiple times per day.

I noticed it's linked to an issue that appears to be auto-closed. I wonder if a new issue being opened and linked to this would get it the attention it deserves?

@TerryHowe
Copy link
Copy Markdown
Contributor

Closes: #31633

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Dec 11, 2025

Closes: #31633

Updated the commit message and the PR description.

@banjoh banjoh added the bug Categorizes issue or PR as related to a bug. label Dec 11, 2025
Copy link
Copy Markdown
Contributor
@banjoh banjoh left a comment

Choose a reason for hiding this comment

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

LGTM

banjoh
banjoh previously approved these changes Dec 11, 2025
@TerryHowe TerryHowe added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Dec 13, 2025
@SeanKilleen
Copy link
Copy Markdown
SeanKilleen commented Dec 29, 2025

What is the process for this PR to be reviewed and approved by one additional person?

Asking because there was a comment on the issue that the PR is stale, but it's already received one approval and is just pending (presumably) 1 more approval.

Asking as the non-author, because I have hit this issue 4 times now during attempted Helm deployments this morning and am very much looking forward to the symptom being resolved. :)

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Dec 30, 2025

I just gave up and switched to WSL. It works much better.

@SeanKilleen
Copy link
Copy Markdown

I just gave up and switched to WSL. It works much better.

I'd consider that except I'm working with a team whose understanding and familiarity with WSL varies. Hopefully this PR can get the one additional approval it needs and get things resolved. 🤞

Comment thread pkg/downloader/chart_downloader.go Outdated
@SeanKilleen
Copy link
Copy Markdown
SeanKilleen commented Jan 23, 2026

Hi all -- I see @gjenkins8 reviewed this and added a comment and @orgads responded in a few hours. That was 3 weeks ago. Coming back to this thread because I was once again blocked on a deployment and had to repeat it 5 times due to the locking issue.

Is there a way we can come to agreement on this? The point @orgads raises makes sense to be in general, and it seems that all the environments would benefit from the change. However, I'm not an expert in this specific stack.

@TerryHowe TerryHowe dismissed their stale review January 24, 2026 14:05

I like George's suggestion

@orgads
Copy link
Copy Markdown
Contributor Author
orgads commented Jan 25, 2026

Rebased and separated Windows/non-Windows.

Comment thread internal/fileutil/fileutil_unix.go Outdated
Copy link
Copy Markdown
Contributor
@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

This breaks existing behavior. It will leave stale chart/provenance data if a chart is republished with the same version/name

When multiple processes try to download the same chart version
concurrently (e.g., via Terraform), they can race to write the
destination file. On Windows, this results in 'Access Denied'
errors because the file cannot be renamed while another process
has a handle to the destination.

This commit introduces 'PlatformAtomicWriteFile' to the fileutil
package. On Unix-like systems, it simply delegates to AtomicWriteFile,
maintaining existing behavior. On Windows, it coordinates writes using
a lock file (.lock). It acquires the lock, then performs the atomic
write.

Crucially, this implementation ensures that existing files are
overwritten (rather than skipped). This ensures that if a chart is
republished with the same version, the local cache is correctly updated,
preventing stale data issues.

Fixes helm#31633

Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
Copy link
Copy Markdown
Contributor
@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

Copy link
Copy Markdown
Contributor
@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

I don't have a windows system atm to test this, but looks good

6D38
@SeanKilleen
Copy link
Copy Markdown

Thank you @joejulian and @TerryHowe for giving this the reviews it needs. Thank you to @orgads for continuing to work on this and get it across the finish line 🎉

It seems like there's nothing blocking this at this point from being merged and getting into the release cycle. I and other Helm users on Windows will be grateful for that!

@joejulian joejulian added this to the 4.1.2 milestone Feb 11, 2026
@joejulian joejulian merged commit 14e0b8f into helm:main Feb 11, 2026
5 checks passed
@orgads orgads deleted the win-parallel branch February 11, 2026 05:39
@scottrigby scottrigby added needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. picked Indicates that a PR has been cherry-picked into the next release candidate. and removed Has One Approval This PR has one approval. It still needs a second approval to be merged. needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. labels Mar 10, 2026
@scottrigby scottrigby modified the milestones: 4.1.2, 4.1.3 Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. picked Indicates that a PR has been cherry-picked into the next release candidate. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concurrency issues pulling charts since Helm 3.7.2

7 participants

0