Repository navigation
Conversation
Macbet
changed the base branch from
fix/client-drop-webflux
to
fix/tofu-release-pagination
November 18, 2026 04:20
Member
|
@Macbet I dont think this is need it, the library is only used for the executor component, the executor component is only running 1 job each time so there are not concurrent request in reality |
alfespa17
force-pushed
the
fix/downloader-atomic-install
branch
from
November 18, 2026 22:45
46ca8b2 to
b507dce
Compare
…t jobs Concurrent jobs needing the same uncached version streamed into the same archive and unzipped into the same binary, so another job could exec a partially written file, and a JVM killed mid-unzip left a truncated binary that was treated as installed forever. - Download to a unique <archive>.<uuid>.part and rename it when complete. - Extract into a unique temp directory next to the version directory and rename the directory (or just the binary, if the directory exists) into place once the binary is complete and executable. - Serialize installs of a version with an interruptible per-version lock and a FileChannel lock in the download directory, so executors sharing a volume download it once. Jobs that waited behind a failed install fail with its cause instead of each retrying in turn. - Under the lock, delete leftovers of killed installs, but only those older than the download timeout plus 5 minutes, since some shared file systems don't enforce the lock across hosts. - Merge the two unzip methods, mark only the product binary executable, reject entries that escape the extraction directory (zip slip) and archive file names from the index that are not plain file names. - Delete an archive that fails to extract for any reason, so it is not retried on every run. Behaviour change: a found binary without the exec bit is no longer chmod-ed and reused, it is reinstalled. Only interrupted older installs leave one, and it may be truncated. Pre-seeded caches (air-gapped hosts, baked images) must have +x on the binaries.
- Ignore unknown fields in the Terraform index models like the Tofu ones already do, so a new field in HashiCorp's index.json or a mirror no longer breaks every Terraform download. - Map x86_64/amd64 to amd64 and x86/i386-i686 to 386. Intel macOS reports x86_64 and failed with "Invalid Terraform Version". - Drop the terraformDirectory field: it was never read, and the tofu setup overwrote it with the tofu path.
alfespa17
force-pushed
the
fix/downloader-atomic-install
branch
from
November 18, 2026 22:54
b507dce to
b094bba
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Concurrent jobs that need the same uncached version both streamed into the same
download/<file>.zipand unzipped into the sameterraform/<version>/terraform. That caused three failures:isUsableBinary()could chmod it and return it while it was still being written. The result was exec of a partial binary, or "Text file busy".terraformReleasesUrlortofuReleasesUrl, or a tampered mirror.Change
Atomic install
<archive>.<uuid>.part, then moves into place with an atomic move.tofu/v1.x.y/.Locking
FileChannel.lock()on a per-version lock file for pods sharing a volume.Cleanup
.part,.tmp) are swept under the lock. Only entries older than the download timeout plus 5 min are removed, so it is safe even where locks are not enforced across hosts. Matching uses prefix and suffix, not a glob.Zip-slip and index validation
..or absolute paths, are rejected.Robustness
@JsonIgnoreProperties(ignoreUnknown = true)on the Terraform index models, so a new field inindex.jsonno longer breaks every download.x86_64maps toamd64andi386/i686to386. Intel macOS no longer fails with "Invalid Terraform Version".chmodruns on every non-Windows OS, and only the product binary is made executable.Behaviour change
A found binary without the exec bit is no longer chmod'ed and reused. It is reinstalled instead, because it may be a truncated leftover. Pre-seeded caches (air-gapped installs, baked images) must have
+x. Terrakube's executor already sets+xitself before calling the library.Tests
New tests in
TerraformDownloaderTest:All behaviour tests fail on the previous code.
Docker
verify(temurin 17,--init), together with #120: 68/68 in terraform-client. Downloader tests 3× with--cpus=1. Real installs of terraform 1.9.8 and tofu 1.13.9 succeeded, and the second call hits the fast path in 0 ms.