Repository navigation
Simplify Helix JobMonitor waiting vs running status reporting after main refactor merge - #16973
Conversation
The Helix API distinguishes between work items that are 'Waiting' (queued, no agent assigned) and 'Running' (actively executing). The monitor's status line previously rolled both into 'running', which was misleading when diagnosing slow builds. Changes: - Add QueuedJobs/QueuedWorkItems to JobWorkItemStatusCounts record - GetStatusCounts now splits work items by Helix state: - State 'Running' → counted as running (actively executing) - State 'Waiting' → counted as queued (in Helix queue, no agent) - Other non-completed states → counted as running - A job is 'queued' if all its work items are in Waiting state; it is 'running' if any work item is Running or in a terminal state - GetJobStatus (verbose mode) now returns 'Queued' instead of 'Running' when all work items are in Waiting state - Status log line now shows: 'N running / N queued / N waiting' for both jobs and work items Example before: 1 running / 0 waiting work items (even when queued for hours) Example after: 0 running / 1 queued / 0 waiting work items
- GetJobStatus now uses All(Waiting) logic to match GetStatusCounts: a job is 'Queued' only when every work item is in Waiting state; any Finished/Failed/TimedOut item makes the job 'Running' - Replace two LINQ Count() calls with a single foreach loop for O(n) work item state classification instead of O(2n)
There was a problem hiding this comment.
Pull request overview
This pull request refines Helix JobMonitor’s status aggregation so that Helix work items in the Waiting state are counted as waiting work items (instead of being lumped into running work items) while keeping the job-level status behavior unchanged (jobs with assigned work items still report as running).
Changes:
- Update JobMonitor’s status counting to bucket work items by
WorkItemSummary.State, treatingWaitingas waiting and all other non-terminal states as running. - Add a unit test to validate that waiting work items are reported in the waiting bucket even when the parent job is reported as running.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs | Adjusts work item aggregation logic to count Waiting work items separately from running work items. |
| src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs | Adds coverage asserting waiting work items are counted as waiting while the job remains running. |
Co-authored-by: Michael Simons <[email protected]>
| int jobWaitingCount = 0; | ||
| foreach (WorkItemSummary wi in workItems) | ||
| { | ||
| if (string.Equals(wi.State, "Waiting", StringComparison.OrdinalIgnoreCase)) |
|
@copilot the |
Merged |
Summary
Refines work item status counting in the Helix JobMonitor so that work items in the
WaitingHelix state are reported in the waiting bucket rather than being lumped into running, and carries that behavior forward through the latestmainrefactor.Problem
Previously, once a job had any work items assigned, all of them were counted as running regardless of their actual Helix state. This made it impossible to distinguish between work items actively executing vs. those queued but not yet picked up by a machine.
After
mainrefactoredJobMonitorRunnerstatus/reporting responsibilities, this behavior also needed to be preserved in the new reporting path.Changes
Stateis checked:Runningor other non-waiting states → running bucketWaiting→ waiting bucketRunning(the job itself is active even if individual work items haven't started)main, resolvedJobMonitorRunnerconflicts, and applied the waiting/running bucketing behavior in the refactoredStatusReportercounting flowLoopStatus_WaitingWorkItems_CountedAsWaitingWhileJobIsRunningcontinues to validate the new bucketing behaviorExample
(When work items are in Helix Waiting state, they now appear in the waiting bucket instead of running)
To double check: