fix(lifecycle): make agentctl health retry delay cancelable
Replace `time.Sleep(retryDelay)` in `waitForHealth` (container.go) and
`waitForAgentctlHealthWith` (executor_docker.go) with a cancelable
`select { <-ctx.Done() | <-time.After(retryDelay) }`. Also skip the
final retry's sleep — the loop only re-enters when `i+1 < maxRetries`,
so the extra delay was just added latency on aborted launches.
Cancellation now propagates within ≤500 ms instead of waiting for the
next probe iteration to observe `ctx.Err()`.
This commit is contained in:
@@ -270,7 +270,16 @@ func (cm *ContainerManager) waitForHealth(ctx context.Context, ctl *agentctl.Con
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
time.Sleep(retryDelay)
|
||||
// Cancelable wait that also skips the final retry's sleep — the loop
|
||||
// only re-enters if i+1 < maxRetries, so the extra delay was just
|
||||
// added latency on aborted launches.
|
||||
if i+1 < maxRetries {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-time.After(retryDelay):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if lastErr != nil {
|
||||
|
||||
@@ -495,7 +495,13 @@ func waitForAgentctlHealthWith(ctx context.Context, ctl healthChecker, maxRetrie
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
time.Sleep(retryDelay)
|
||||
if i+1 < maxRetries {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-time.After(retryDelay):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if lastErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user