From e171e8248291eb18341420df13dc3317c1a73c07 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2026 06:57:58 +0000 Subject: [PATCH 1/2] 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. Change-source: pulse-maintainer --- .../v6/internal/subsystems/monitoring.md | 9 ++++--- .../monitoring/agent_report_apply_progress.go | 16 +++++------ .../agent_report_apply_progress_test.go | 27 +++++++++++++++++++ internal/monitoring/monitor_alerts.go | 2 +- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md index 05fd629ac0..0bd0068993 100644 --- a/docs/release-control/v6/internal/subsystems/monitoring.md +++ b/docs/release-control/v6/internal/subsystems/monitoring.md @@ -9969,14 +9969,17 @@ dispatcher handing back a claim it never admitted is not a return, and a target removed from the queue stops counting as progress. `TestPollClaimProgressStall`, `TestTaskQueueTracksClaimsForPollStall`, and `TestDeadManMonitoringProgressReportsWedgedPolls` pin these boundaries. -Agent intake is checked the same way, because host, Docker and Kubernetes +Agent intake has separate progress tracking because host, Docker and Kubernetes reports are applied on request goroutines rather than through the poll 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. 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 diff --git a/internal/monitoring/agent_report_apply_progress.go b/internal/monitoring/agent_report_apply_progress.go index 597641337c..3f02334902 100644 --- a/internal/monitoring/agent_report_apply_progress.go +++ b/internal/monitoring/agent_report_apply_progress.go @@ -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) { diff --git a/internal/monitoring/agent_report_apply_progress_test.go b/internal/monitoring/agent_report_apply_progress_test.go index 9b11f63f23..9a577ffbdb 100644 --- a/internal/monitoring/agent_report_apply_progress_test.go +++ b/internal/monitoring/agent_report_apply_progress_test.go @@ -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)) diff --git a/internal/monitoring/monitor_alerts.go b/internal/monitoring/monitor_alerts.go index efaa1c8d80..fea277a281 100644 --- a/internal/monitoring/monitor_alerts.go +++ b/internal/monitoring/monitor_alerts.go @@ -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 { From 93ecdef3c278adeaa9b15a5e4728b23a13d954e3 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2026 07:00:05 +0000 Subject: [PATCH 2/2] 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. Change-source: pulse-maintainer --- docs/release-control/v6/internal/subsystems/monitoring.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md index 0bd0068993..6791ac3e30 100644 --- a/docs/release-control/v6/internal/subsystems/monitoring.md +++ b/docs/release-control/v6/internal/subsystems/monitoring.md @@ -9969,7 +9969,7 @@ dispatcher handing back a claim it never admitted is not a return, and a target removed from the queue stops counting as progress. `TestPollClaimProgressStall`, `TestTaskQueueTracksClaimsForPollStall`, and `TestDeadManMonitoringProgressReportsWedgedPolls` pin these boundaries. -Agent intake has separate progress tracking because host, Docker and Kubernetes +Agent intake is checked the same way, because host, Docker and Kubernetes reports are applied on request goroutines rather than through the poll scheduler, and an agent-only install has an empty queue. `ApplyHostReportWithStatus`, `ApplyDockerReport` and `ApplyKubernetesReport` @@ -9977,7 +9977,8 @@ 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. An apply completion at or after the newest wedged start suppresses the stall only if -that completion is less than three minutes old. Unlike a scheduled poll, +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