Repository navigation
ci: retry transient Go module-server errors, and pin the security tools - #635
Merged
Merged
Conversation
…ls (#633) Go does not retry a module fetch. A single HTTP/2 stream error from proxy.golang.org or sum.golang.org failed five correct PRs in October (#582, #631, #622, #614, #632) before anything compiled. Each module that failed had just been bumped on main, and the Security Scan failures came from uncached @latest tool installs. .github/scripts/go-retry.sh runs a go command and splits failures three ways. A transient answer (stream INTERNAL_ERROR, 5xx, timeout, reset) is retried with backoff, and each retry is printed. A missing module, or any other error, fails on the first attempt. A checksum mismatch / SECURITY ERROR is checked first and never retried, even beside a transient-looking line, so a corrupted download can't be retried until a lucky attempt hides it. Still transient after three attempts is a failure: a build can't proceed without its modules. Every job that sets up Go (18 across ci.yml, security.yml, release.yml and live-aws.yml) fetches modules through it as the step after setup-go. security.yml's existing bare 'go mod download' is replaced. gosec, govulncheck and go-licenses are pinned (v2.29.0, v1.9.0, v1.6.0) rather than @latest and installed through it; govulncheck had already moved from v1.8.0 under @latest with no commit. The MinIO and substrate installs go through it too. Tests: - TestGoRetryScriptRetriesOnlyTransientModuleServerErrors runs the real script against a stub go, asserting the number of attempts as well as the exit status. Removing the checksum guard, retrying everything, and never retrying each fail the cases they should. - TestEveryGoJobFetchesModulesThroughTheRetry walks every workflow: a retry download after setup-go with no go before it, no bare go install, no @latest. Floor of 15 Go jobs. Deleting a job's download step, adding @latest back, a bare go install, and a go build before the download each fail naming the job and step. Against real go, with a local proxy that 502s the first two requests into an empty GOMODCACHE: two visible retries, then success. A nonexistent version 404s and fails in 2s with no retry. Pinned govulncheck v1.9.0 reports no vulnerabilities, and go-licenses v1.6.0 passes.
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.
Fixes #633.
The problem
Go doesn't retry a module fetch. One HTTP/2
stream error … INTERNAL_ERRORfromproxy.golang.orgorsum.golang.orgfailed five correct PRs this month (#582, #631, #622, #614, #632) before anything compiled. Each module that failed had just been bumped onmain. The Security Scan failures came from uncachedgo install …@latest..github/scripts/go-retry.shgoresultINTERNAL_ERROR, 5xx, timeout, resetSECURITY ERRORWiring
ci.yml,security.yml,release.ymlandlive-aws.yml, fetch modules through it as the step right aftersetup-go.security.yml's barego mod downloadis replaced.gosecv2.29.0,govulncheckv1.9.0 andgo-licensesv1.6.0 are pinned, not@latest, and installed through the retry. Under@latest,govulncheckhad already moved from v1.8.0 with no commit. A security gate that can change its verdict on an unchanged tree isn't a gate.Tests
TestGoRetryScriptRetriesOnlyTransientModuleServerErrorsruns the real script against a stubgoand checks the number of attempts as well as the exit status. Removing the checksum guard, retrying everything, and never retrying each fail exactly the cases they should.TestEveryGoJobFetchesModulesThroughTheRetrywalks every workflow: a retry download aftersetup-gowith nogobefore it, no barego install, and no@latest. Floor of 15 Go jobs.testjob's download step deletedci.yml job "test" runs go in step "Build" before modules are fetchedgovulncheck@latestbackgo installfor substratego buildadded before the download (live-aws)Against real Go
Using a local proxy that answers 502 to the first two requests and forwards the rest to
proxy.golang.org, with an emptyGOMODCACHE:A nonexistent
v0.99.99returns404 Not Foundand fails in 2 s with no retry. Pinnedgovulncheckv1.9.0 reports no vulnerabilities, andgo-licensesv1.6.0 passes.🤖 Generated with Claude Code