Repository navigation
fix: isolate trivy's cache per run to stop the checks-bundle race - #166
Merged
Merged
Conversation
trunk runs 'trivy config' once per file in parallel, all sharing one
--cache-dir. On a cold or day-old cache every process downloads and
unpacks the checks bundle into the same directory, and one can read it
mid-replace ('load checks: ... no such file'), failing Linting at random
(it broke on main right after #165). Backport the trunk-io/plugins
v1.10.0 definition that uses a per-run ${tmpdir} instead.
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.
Summary
Linting failed on
mainright after #165 merged (run 43820249859), although the same check passed on the PR:Cause: trunk runs
trivy configonce per file, in parallel, and every run shares one--cache-dir. When the checks bundle is missing or more than a day old, each process downloads and unpacks it into the same directory. One process can then read files that another is replacing. That makes the failure random: it depends on how many YAML/Docker files change and on timing.Fix: a 7-line override in
.trunk/trunk.yamlbackports the trunk-io/plugins v1.10.0 definition, which gives each run its own--cache-dir ${tmpdir}. We pin plugins v1.6.6, so this changes only the trivyconfigcommand and leaves every other linter alone. Drop the override when the plugins ref is bumped.Testing
trivy configruns sharing a cold cache crashed with the same "load checks ... no such file" error in 2 of 12 rounds.unknown flag: --bogus-flag. The trivy command line showed a per-run temp--cache-dir.trunk checkpasses on the change.