Skip to content

Simplify Helix JobMonitor waiting vs running status reporting after main refactor merge - #16973

Merged
premun merged 8 commits into
mainfrom
copilot/fix-helix-job-monitor-status
Jun 8, 2026
Merged

premun merged 8 commits into
mainfrom
copilot/fix-helix-job-monitor-status

Conversation

Copilot AI commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refines work item status counting in the Helix JobMonitor so that work items in the Waiting Helix state are reported in the waiting bucket rather than being lumped into running, and carries that behavior forward through the latest main refactor.

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 main refactored JobMonitorRunner status/reporting responsibilities, this behavior also needed to be preserved in the new reporting path.

Changes

  • Work item classification: Instead of counting all work items in an active job as running, each work item's State is checked:
    • Running or other non-waiting states → running bucket
    • Waiting → waiting bucket
  • Job-level status unchanged: A job with assigned work items is still reported as Running (the job itself is active even if individual work items haven't started)
  • Main refactor integration: Merged main, resolved JobMonitorRunner conflicts, and applied the waiting/running bucketing behavior in the refactored StatusReporter counting flow
  • Test coverage: LoopStatus_WaitingWorkItems_CountedAsWaitingWhileJobIsRunning continues to validate the new bucketing behavior

Example

Before: 0 processed / 0 completed / 1 running / 0 waiting jobs
        0 processed / 0 completed / 2 running / 0 waiting work items

After:  0 processed / 0 completed / 1 running / 0 waiting jobs
        0 processed / 0 completed / 0 running / 2 waiting work items

(When work items are in Helix Waiting state, they now appear in the waiting bucket instead of running)

To double check:

Copilot AI self-assigned this Jun 5, 2026
Copilot AI review requested due to automatic review settings June 5, 2026 15:54
Copilot AI removed the request for review from Copilot June 5, 2026 15:54
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
Copilot AI requested review from Copilot and removed request for Copilot June 5, 2026 16:02
- 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)
Copilot AI requested review from Copilot and removed request for Copilot June 5, 2026 16:06
Copilot AI changed the title [WIP] Fix Helix Job Monitor status to distinguish queued from running jobs Helix Job Monitor: distinguish queued vs actively running work items in status output Jun 5, 2026
Copilot AI requested a review from MichaelSimons June 5, 2026 16:08
Copilot AI requested review from Copilot and removed request for Copilot June 5, 2026 16:54
Copilot AI changed the title Helix Job Monitor: distinguish queued vs actively running work items in status output Simplify Helix JobMonitor waiting vs running status reporting Jun 5, 2026
@MichaelSimons
MichaelSimons marked this pull request as ready for review June 5, 2026 17:31
@MichaelSimons
MichaelSimons requested a review from mmitche June 5, 2026 17:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, treating Waiting as 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]>
Copilot AI review requested due to automatic review settings June 5, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings June 5, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

int jobWaitingCount = 0;
foreach (WorkItemSummary wi in workItems)
{
if (string.Equals(wi.State, "Waiting", StringComparison.OrdinalIgnoreCase))
@premun

premun commented Jun 8, 2026

Copy link
Copy Markdown
Member

@copilot the main branch has refactored the JobMonitorRunner class. Can you merge main and resolve conflicts?

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the main branch has refactored the JobMonitorRunner class. Can you merge main and resolve conflicts?

Merged main into this branch and resolved the JobMonitorRunner conflict while preserving the waiting-vs-running work item counting behavior in the refactored StatusReporter path. Addressed in commit ceb1f9bcf.

Copilot AI changed the title Simplify Helix JobMonitor waiting vs running status reporting Simplify Helix JobMonitor waiting vs running status reporting after main refactor merge Jun 8, 2026
Copilot finished work on behalf of premun June 8, 2026 07:53
Copilot AI requested a review from premun June 8, 2026 07:53
@premun
premun merged commit 2b0144c into main Jun 8, 2026
10 checks passed
@premun
premun deleted the copilot/fix-helix-job-monitor-status branch June 8, 2026 08:51
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helix Job Monitor status: running does not distinguish queued vs actively executing

4 participants