Expire agent intake progress while a report is still wedged (#5982)

**Expire agent intake progress while a report is still wedged**

One successful sibling apply should not let the external watchdog report
healthy indefinitely when another apply is still blocked and no more
reports land. Bound the grace period to the existing three-minute stall
threshold without marking an idle agent intake stale. Refs #5089.

**Keep separate watchdog contract edits composable**

Preserve the transition after the poll-claim paragraph so the reviewed
breaker-deferral note can land independently. Call out exactly where the
intake rule differs.

---
Fleet candidate `20261205T065448Z-core-runtime` from the `core-runtime`
lane. Reviewed tip `93ecdef3c278adeaa9b15a5e4728b23a13d954e3` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
pulse-triage[bot]
2026-12-05 08:13:29 +00:00
committed by GitHub
4 changed files with 42 additions and 11 deletions
@@ -9996,8 +9996,12 @@ scheduler, and an agent-only install has an empty queue.
`ApplyHostReportWithStatus`, `ApplyDockerReport` and `ApplyKubernetesReport`
record each apply's start and, on an error-free return, its completion in
`agentReportApplyProgress`, under a lock never held during the apply. An apply
running for `agentReportApplyStallAfter` (three minutes) is wedged; when no
apply has completed since the most recently wedged one started,
running for `agentReportApplyStallAfter` (three minutes) is wedged. An apply
completion at or after the newest wedged start suppresses the stall only if
that completion is less than three minutes old. This is where the rules differ:
unlike a scheduled poll,
report intake has no next scheduled run to wait for, so one older completion
must not hide an apply that is still stuck. When there is an intake stall,
`deadManMonitoringProgress` reports the earliest of the loop marker, the poll
stall time and the intake stall time. A rejected report is not progress, an
apply that panics still leaves the in-flight set, and no apply in flight is
@@ -51,13 +51,13 @@ func (p *agentReportApplyProgress) end(id uint64, at time.Time, completed bool)
}
}
// stall reports whether agent intake has stopped, using the same rule as the
// poll-claim check: an apply running for at least after is wedged, and intake
// is stalled when some apply is wedged and none has completed since the most
// recently wedged one started. Another agent's report completing since then
// keeps intake healthy, so one stuck report does not flap the watchdog while
// others still land. No applies in flight is never a stall. The returned time
// is the latest evidence that intake was moving.
// stall reports whether agent intake has stopped. An apply running for at
// least after is wedged. A successful completion since the newest wedged
// apply started shows that intake is still moving, but only for after.
// Unlike scheduled polling, intake has no next scheduled run to wait for.
// Without an expiry, a single completion can mask a wedge forever. No
// applies in flight is never a stall. The returned time is the latest
// evidence that intake was moving.
func (p *agentReportApplyProgress) stall(now time.Time, after time.Duration) (time.Time, bool) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -75,7 +75,7 @@ func (p *agentReportApplyProgress) stall(now time.Time, after time.Duration) (ti
if !wedged {
return time.Time{}, false
}
if !p.returnedAt.IsZero() && !p.returnedAt.Before(newestWedged) {
if !p.returnedAt.IsZero() && !p.returnedAt.Before(newestWedged) && now.Sub(p.returnedAt) < after {
return time.Time{}, false
}
if p.returnedAt.After(oldest) {
@@ -80,6 +80,33 @@ func TestAgentReportApplyProgressStall(t *testing.T) {
}
})
t.Run("a sibling completion expires while an apply is still stuck", func(t *testing.T) {
var p agentReportApplyProgress
hung := p.begin(now.Add(-2 * after))
other := p.begin(now.Add(-time.Second))
p.end(other, now, true)
if _, stalled := p.stall(now.Add(after-time.Nanosecond), after); stalled {
t.Fatal("a recent successful apply should keep intake healthy")
}
rejected := p.begin(now.Add(after - time.Second))
p.end(rejected, now.Add(after), false)
at, stalled := p.stall(now.Add(after), after)
if !stalled || !at.Equal(now) {
t.Fatalf("after successful completion expires: stall = %v at %v, want true at %v", stalled, at, now)
}
other = p.begin(now.Add(after))
p.end(other, now.Add(after+time.Second), true)
if _, stalled := p.stall(now.Add(after+time.Second), after); stalled {
t.Fatal("a new successful apply did not restore healthy intake")
}
p.end(hung, now.Add(2*after), false)
if _, stalled := p.stall(now.Add(3*after), after); stalled {
t.Fatal("an idle intake should not be reported as wedged")
}
})
t.Run("failed return does not clear a stall", func(t *testing.T) {
var p agentReportApplyProgress
p.begin(now.Add(-after - time.Hour))
+1 -1
View File
@@ -129,7 +129,7 @@ const deadManPollStallGrace = 2 * time.Minute
// monitor loop's own ticker proves the loop is scheduling, but not that polls
// return or that agent reports are applied: when every claimed poll has been
// out past its timeout and none has come back, or agent report applies are
// wedged and none has completed since, report the earliest such progress
// wedged without a recent completion, report the earliest such progress
// instead so the watchdog signals a stall rather than a healthy heartbeat.
func (m *Monitor) deadManMonitoringProgress() time.Time {
if m == nil {