Skip to content

JobMonitor: emit failed work item errors as Azure DevOps task.logissue entries - #16879

Closed
mmitche with Copilot wants to merge 29 commits into
mainfrom
copilot/add-job-monitor-timeline-logging
Closed

mmitche with Copilot wants to merge 29 commits into
mainfrom
copilot/add-job-monitor-timeline-logging

Conversation

Copilot AI commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Failed Helix work item details were previously easy to miss in Azure DevOps timeline issue surfacing. This change emits explicit Azure DevOps error issue commands (##vso[task.logissue type=error]) for failed work items (including console links), while preserving error-level logging.

To double check:

  • Problem addressed

    • Failed work item console-link output is emitted in Azure DevOps issue-command format so it is surfaced in timeline errors.
    • Fixed a regression in LogFailedWorkItemConsoleLinks(...) where the method was left in a broken/non-compiling state.
    • Restored explicit _logger.LogError(...) emission in the same task.logissue format expected by timeline surfacing.
  • Code changes

    • /src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs
      • LogFailedWorkItemConsoleLinks(...) writes failed work item messages to stderr using:
        • ##vso[task.logissue type=error]❌ Work item ...
        • ##vso[task.logissue type=error]Console: ...
      • Restores the missing message construction and removes the orphaned/dangling argument list that caused compilation errors.
      • Uses _logger.LogError(...) with an explicit ##vso[task.logissue type=error]...{nl}##vso[task.logissue type=error]Console: ... template and structured arguments (WorkItemName, JobName, State, ConsoleOutputUri).
    • /src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs
      • CompletedHelixJob_LogsFailedWorkItemConsoleLinks validates error messages contain ##vso[task.logissue type=error].
  • Example

    Console.Error.WriteLine($"##vso[task.logissue type=error]❌ Work item '{workItem.Name}' in job '{helixJob.DisplayName}' failed ({state}).");
    Console.Error.WriteLine($"##vso[task.logissue type=error]Console: {consoleOutputText}");
    
    _logger.LogError("##vso[task.logissue type=error]❌ Work item '{WorkItemName}' in job '{JobName}' failed ({State}).{nl}##vso[task.logissue type=error]Console: {ConsoleOutputUri}",
        workItem.Name,
        helixJob.DisplayName,
        state,
        Environment.NewLine,
        consoleOutputText);
  • The right tests are in and the right validation has happened. Guidance: https://github.com/dotnet/arcade/blob/main/Documentation/Validation.md

Copilot AI requested review from Copilot and removed request for Copilot May 23, 2026 01:43
Copilot AI requested review from Copilot and removed request for Copilot May 23, 2026 01:48
Copilot AI changed the title [WIP] Add job monitor errors to AzDO build timeline JobMonitor: promote failed work item console links to error timeline entries May 23, 2026
Copilot AI requested a review from mmitche May 23, 2026 01:52
premun
premun previously approved these changes May 25, 2026
@premun
premun marked this pull request as ready for review May 25, 2026 09:00
Copilot AI review requested due to automatic review settings May 25, 2026 09:00
@premun

premun commented May 25, 2026

Copy link
Copy Markdown
Member

@copilot the timeline still doesn't have the error about the failed work item. Maybe you need to use the ##[error] notation (or how is it exactly)?

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 PR improves Helix JobMonitor diagnostics in Azure DevOps by emitting failed work item console-link details at error level so they surface in timeline error reporting, rather than being easy-to-miss informational output.

Changes:

  • Promoted per-failed-work-item console-link logging from LogInformation to LogError.
  • Updated the test logger to capture error-level messages and added an assertion verifying the failed work item message is logged as an error.

Reviewed changes

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

File Description
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs Logs failed work item console links via LogError to improve visibility in Azure DevOps timeline error surfacing.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs Extends the recording logger to track error messages and asserts the failure console-link output is emitted at error level.

Copilot AI commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the timeline still doesn't have the error about the failed work item. Maybe you need to use the ##[error] notation (or how is it exactly)?

Addressed in 8ab2acf. Failed work items now emit explicit Azure DevOps error lines using ##[error] (for both the failure summary line and the console-link line), and tests were updated to assert those lines are written.

Assert.Contains(logger.Messages, message =>
message.Contains($"Work item 'wi-fail' in job 'helix-linux' failed (Finished, exit code 1).{Environment.NewLine}Console: https://helix.example/wi-fail/console", StringComparison.Ordinal));
Assert.Contains(logger.ErrorMessages, message =>
message.Contains($"Work item 'wi-fail' in job 'helix-linux' failed (Finished, exit code 1).{Environment.NewLine}Console: https://helix.example/wi-fail/console", StringComparison.Ordinal));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot Validate that the error messages contain: '##vso[task.logissue type=error]'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 967c155 and 9b337ee. The failed work item error assertions now validate ##vso[task.logissue type=error], and the monitor now writes those task.logissue error lines directly to stderr for Azure DevOps parsing.

@mmitche

mmitche commented May 26, 2026

Copy link
Copy Markdown
Member

When writing the error, you need to put in '##vso[task.logissue type=error]'. to get it to show in the timeline.

Copilot AI review requested due to automatic review settings June 1, 2026 14:48

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 3 out of 3 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings June 1, 2026 15:10

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 3 out of 3 changed files in this pull request and generated 2 comments.

@premun

premun commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

The last run is green though there is a failing test RetryOnEntryWithCrashes_ResubmitsOnlyLatestFailedWork (and the timeline has an error):

image

@premun

premun commented Jun 2, 2026

Copy link
Copy Markdown
Member

So looks like we were using the job name only as a key in the dictionary, while if you sent work to two queues from one job, it would share the same dictionary key

Copilot AI review requested due to automatic review settings June 2, 2026 12:16
@premun

premun commented Jun 2, 2026

Copy link
Copy Markdown
Member

I pushed too many fixes in this unrelated PR. I will ask AI to split them into their own smaller PRs, this is getting out of hand, apologies

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 3 out of 3 changed files in this pull request and generated 5 comments.

Copilot AI review requested due to automatic review settings June 2, 2026 16:09

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 3 comments.

Comment on lines +737 to +741
_logger.LogError("##vso[task.logissue type=error]❌ Helix Job: {JobName} Work Item: '{WorkItemName}' Failed: {State} Console: {ConsoleOutputUri}",
helixJob.DisplayName,
FormatWorkItemState(workItem),
Environment.NewLine,
GetConsoleOutputText(workItem.ConsoleOutputUri));
workItem.Name,
state,
consoleOutputText);
Comment on lines 2634 to +2638
Assert.Contains(logger.Messages, message =>
message.Contains($"Work item 'wi-fail' in job 'helix-linux' failed (Finished, exit code 1).{Environment.NewLine}Console: https://helix.example/wi-fail/console", StringComparison.Ordinal));
message.Contains("##vso[task.logissue type=error]❌ Helix Job: helix-linux Work Item: 'wi-fail' Failed: Finished, exit code 1 Console: https://helix.example/wi-fail/console", StringComparison.Ordinal));
Assert.Contains(logger.ErrorMessages, message =>
message.Contains("##vso[task.logissue type=error]", StringComparison.Ordinal)
&& message.Contains("❌ Helix Job: helix-linux Work Item: 'wi-fail' Failed: Finished, exit code 1 Console: https://helix.example/wi-fail/console", StringComparison.Ordinal));
Comment on lines +151 to +155
// and are already unwinding. We only observe them best-effort: if this is the
// self-timeout case the monitor is relaunched and re-uploads any results that
// didn't make it, so we must not block shutdown waiting on them, nor let their
// cancellation/faults escape and skip the cleanup above.
await ObservePendingTestResultUploadsAsync();
@mmitche mmitche closed this Jun 2, 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.

Job Monitor errors and failed work item info should make it into the timeline

5 participants