Loading
fix(binarymgr): bound registry lookups and stamp failed update checks
What does this MR do and why?
When gitlab.com is unreachable, glab orbit hangs for about 3 to 7 minutes before it starts the managed binary. This caps package-registry lookups at 15 seconds and records failed update checks, so the timeout is paid once a day instead of on every run. The same applies to glab duo cli, which shares the managed-binary layer.
How to set up and validate locally
- Block outbound TCP to gitlab.com (drop, not reject).
- Run
glab orbitwith a freshGLAB_CONFIG_DIRand--yes. - It should fail after about 15 s, not about 194 s.
Agent context
- Registry metadata lookups (
CheckForUpdateandfetchPackageAsset) get a 15 s context deadline. The binary download itself is unbounded. CheckForUpdatereturnsNewCheckTimeon a failed lookup, andperformUpdateChecksaves it before returning the error.Runstampslast_update_checkafter a fresh download, so the follow-up update check is skipped.- Measured on a blackholed network: fresh install 194 s to 17 s, stale update check 406 s to 37 s (two invocations).
- Registry listing requests 100 packages per page, so the shared 15 s budget covers fewer round trips. A deadline error reads "package registry did not respond within 15s".
- Tests: runner tests for the stamp on a failed check and after a fresh download, and manager tests for the deadline on both lookups, the error text and the page size.
go test ./internal/binarymgr/... ./internal/commands/orbit/...andgolangci-lintpass. - Not done: moving the update check off the exec path.
Edited by Dmitry Gruzd