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

Write safely to the shared plugin cache #32928

Closed
wants to merge 4 commits into from
Closed

Conversation

finnag
Copy link

@finnag finnag commented Mar 28, 2023

Change terraform to write safely to the shared plugin cache. Also, if a write fails, but the existing contents are correct, we now consider that a success.

Terraform currently fails terraform init if an executable it is trying to write is running
("text file busy"), or if it cannot write to the file for some other reason. There is also a race condition while it is writing the files that other readers can get partial content, or that partial content is left in the cache.

Fixes #25849, #31964, #32901, #32915

Target Release

1.4.x

Draft CHANGELOG entry

ENHANCEMENTS

  • The plugin cache now supports multiple simultaneous users

finnag added 4 commits March 28, 2023 11:55
Doing a clean verbatim import first, will simplify and
make atomic in future commits.
Also remove some now dead code, and move functions around a bit.
If we fail to rename over the old file, compare the files.

If the new file we are trying to rename over the old one
has identical contents, we can still call it a success.

This can happen in various scenarios, possibly with
prepopulated cache directories or different users sharing
the same directory.
@crw crw added the bug label Mar 28, 2023
@crw
Copy link
Contributor

crw commented Mar 28, 2023

Thanks for this submission! I'll raise it in triage.

@crw
Copy link
Contributor

crw commented Apr 4, 2023

Hi @finnag, thanks for this submission. At triage it was decided that this fix would be better applied directly to go-getter rather than have the code ported here. Although in general it has been more difficult to build and include new releases of go-getter, if you would like to pursue this in that repo I will do my best to move it forward. Thanks for your contribution!

@crw crw closed this Apr 4, 2023
@crw crw added the upstream label Apr 4, 2023
@jgournet
Copy link

Thank you for this fix !
Just mentioning: it does help a lot with the original issue, but we still get "text file is busy" errors, as seen in this ticket:
hashicorp/terraform-cdk#2741

@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parallel init failure when using plugin cache
3 participants