infra icon indicating copy to clipboard operation
infra copied to clipboard

Add the 'early-return' linter, pass more ctx

Open djeebus opened this issue 2 months ago • 1 comments

Also tweak some integration tests to try and make them less flaky. Success?


[!NOTE] Enable the early-return linter and refactor code and tests to use early returns while stabilizing integration tests with EventuallyWithT and longer timeouts.

  • Linting:
    • Enable revive rule early-return in .golangci.yml.
  • Client Proxy (packages/client-proxy/main.go):
    • Simplify Redis and secure-Redis initialization with early-return on errors; warn and fallback to in-memory catalog when Redis is disabled.
  • Orchestrator NBD (packages/orchestrator/internal/sandbox/nbd/dispatch.go):
    • Refactor request parsing loop to early-break on incomplete headers and flatten command handling.
    • Gate cmdRead/cmdWrite with early shutdown checks and move pendingResponses.Add(1) accordingly.
  • Template Build (.../template/build/phases/steps/builder.go):
    • Early-return when layer is cached; otherwise log and proceed to build.
  • Storage Lock (packages/shared/pkg/storage/lock/file_lock.go):
    • Streamline TTL check: return ErrLockAlreadyHeld when fresh; otherwise clean up stale lock before acquiring.
  • Integration Tests:
    • Replace require.Eventually with require.EventuallyWithT, increase timeouts/poll intervals, reuse ctx, and add retrying teardown to reduce flakiness.

Written by Cursor Bugbot for commit 46746c1e618ff2510c70af2cc18000c5ef633fa7. This will update automatically on new commits. Configure here.

djeebus avatar Nov 20 '25 22:11 djeebus

Feel free to cancel my review, I can't do it when there's merge conflict

jakubno avatar Nov 21 '25 17:11 jakubno