fix(df): fail closed when the policy API stops answering
Description
If the Dependency Firewall API accepts the connection and never answers (for example behind a stalled load balancer), a package manager under glab df hangs until the user presses Ctrl-C. It should fail closed after policy.CheckTimeout (60s), as that constant's doc comment promises.
The callers do pass a 60s deadline. CachingChecker then runs the shared check under context.WithoutCancel, so that one caller walking away doesn't cancel the check for every caller waiting on the same coordinate. WithoutCancel also drops the deadline, and the API client has no overall or response-header timeout, so nothing ends the call.
CachingChecker now puts the caller's deadline back on the shared check and still ignores the caller's cancellation. A stalled check ends at the deadline as policy check failed: … context deadline exceeded, which blocks the package. As with any other failure, the entry is dropped, so a later request retries it.
This affects every ecosystem that goes through the MITM proxy, and the Go module gate in !4168 (merged). It was found in review of !4168 (merged).
How has this been tested?
TestCacheStalledCheckFailsClosedAtCallerDeadline: a checker that returns only when its context ends. It hung past the 5s guard before the fix, and now returns Blocked at the 50ms deadline.TestCacheCallerCancellationDoesNotEndSharedCheckpins the existing behaviour this must keep: a cancelled caller doesn't fail the shared check. Passing the caller's context straight through would break it.glab df npm install left-pad@1.3.0against a fake GitLab API that accepts connections and never answers:
| Build | Result |
|---|---|
main |
still hung when timeout killed it at 150s |
| this branch | exit 1 after 61s: npm error 403 … policy check failed: dependency firewall evaluation failed: context deadline exceeded |