arun2dot0 opened a new pull request, #842:
URL: https://github.com/apache/pekko-management/pull/842

   ## Fixes #216
   
   `KubernetesApiSpec` has been intermittently failing in CI with:
   
   ```
   - should be able to be created *** FAILED ***
     LeaseTimeoutException: Timed out removing lease [lease-1]. It is not known 
if the remove happened. Is the API server up?
   ```
   
   ### Root cause
   
   Every request inside `AbstractKubernetesApiImpl.makeRequest` is raced 
against `apiServerRequestTimeout`:
   
   ```scala
   val timeout = after(settings.apiServerRequestTimeout, ...)(Future.failed(new 
LeaseTimeoutException(...)))
   Future.firstCompletedOf(Seq(strictResponse, timeout))
   ```
   
   The spec hard-coded `apiServerRequestTimeout = 1.second` for **all** 
clients. The first HTTP request the suite makes (the `removeLease` call in *"be 
able to be created"*) pays Pekko HTTP connection-pool/JIT warm-up cost. On a 
loaded CI runner that first request can exceed 1s, so the timeout future wins 
the race and the test fails with a spurious `LeaseTimeoutException` — which is 
exactly the reported failure, observed at ~1.4s.
   
   The earlier mitigation (#314) doubled the ScalaFutures `PatienceConfig`, but 
that only governs how long `futureValue` *waits* for a future to settle — it 
does not extend the internal `apiServerRequestTimeout` deadline that actually 
fires. That's why the flake recurred "within 1.5s" despite the patch.
   
   Locally, even on a warm machine, the first functional request already takes 
~0.8s against the 1s deadline, while every subsequent request is 7–16ms (warm 
pool) — confirming this is a cold-start-on-first-request problem.
   
   ### Fix
   
   Decouple the functional tests from the deliberate timeout tests:
   
   - Functional and auth tests now use a generous `apiServerRequestTimeout` 
(10s). This is only a ceiling that never fires while requests succeed, so those 
tests stay fast but tolerate first-request warm-up and CI variance.
   - The four deliberate *"timeout on …"* tests get their own short-timeout 
(1s) client (`underTestTimeouts` / `timeoutSettings`), so they still fail fast; 
their relative `* 2` stub delays scale off the short value.
   
   ### Verification
   
   - Reproduced the exact failure deterministically by injecting a 1.5s delay 
on the first request: `FAILED (1 second, 382 ms) … Timed out removing lease`.
   - With the fix, that same injected 1.5s delay now passes (the 10s deadline 
absorbs it).
   - Full suite green; the four timeout tests still complete in ~1s each, 
confirming they correctly use the short timeout.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to