Skip to content

[ci] Bound logcat capture time - #12471

Merged
simonrozsival merged 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-bound-logcat-capture
Aug 21, 2026
Merged

simonrozsival merged 2 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-bound-logcat-capture

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

adb logcat -d waits indefinitely when an earlier pipeline step fails before an emulator is available. Because logcat capture runs under always(), this can block the remaining tasks until the entire job times out.

Skip capture when adb devices reports no connected device. Also apply a one-minute task timeout so a device disconnect between the check and capture cannot hang the job.

  • Useful description of why the change is necessary.
  • Links to issues fixed - N/A
  • Unit tests - N/A; YAML-only pipeline behavior change

The unconditional logcat capture can wait forever when an earlier step fails before an emulator is available.  This blocks the remaining pipeline tasks until the entire job times out.

Skip capture when adb reports no connected device and give the task a one-minute timeout to handle a device disconnecting between the check and capture.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d2b3073e-c161-4458-9eb2-1fd1760e68f5
Copilot AI lite review requested due to automatic review settings August 20, 2026 21:43

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 updates the Azure Pipelines APK instrumentation template to prevent the “capture logcat” step (run under always()) from hanging indefinitely when no emulator/device is available, by adding a device-presence guard and enforcing a short step timeout.

Changes:

  • Switch logcat capture to a multi-line script with a pre-check that skips capture when adb devices reports no connected device.
  • Add timeoutInMinutes: 1 to bound the logcat capture step runtime even if the device disconnects or adb logcat stalls.
  • Keep the step best-effort (always() + continueOnError: true) so diagnostics collection doesn’t block later publishing steps.

Comment thread build-tools/automation/yaml-templates/apk-instrumentation.yaml Outdated
The logcat guard treats every unsuccessful device check as an empty device list, which can produce a misleading diagnostic when adb itself fails.

Preserve and print the adb devices output, and report a nonzero exit code separately from the no-connected-device case.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: d2b3073e-c161-4458-9eb2-1fd1760e68f5
@simonrozsival
simonrozsival enabled auto-merge (squash) August 21, 2026 08:19
@simonrozsival
simonrozsival merged commit 015dc44 into dotnet:main Aug 21, 2026
44 checks passed
simonrozsival added a commit that referenced this pull request Sep 18, 2026
----

`adb logcat -d` can stall even after `adb devices` reports a connected emulator. Azure Pipelines then applies the one-minute task timeout added by #12471, records an error, and converts the task to `SucceededWithIssues` because it uses `continueOnError`. The final `fail-on-issue.yaml` step intentionally turns that status into a job failure. This occurred in builds [1583273](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1583273) and [1585745](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1585745). The log-volume reduction in #12620 does not prevent adb or emulator communication from stalling.

Add a reusable PowerShell helper that bounds device discovery to 10 seconds and logcat collection to 45 seconds. It redirects logcat directly to the existing artifact path, preserving complete output on success and partial output on timeout, kills timed-out process trees with a bounded grace period, emits an explicit Azure warning, and exits successfully for capture-only failures.

The pipeline keeps `condition: always()` but no longer relies on task-level timeout or `continueOnError`, so diagnostic capture cannot change `Agent.JobStatus`. `fail-on-issue.yaml` remains unchanged and continues to gate unrelated build and test failures.

Related: #12704
Prior mitigations: #12471, #12620

- [x] Useful description of *why the change is necessary*.
- [x] Links to issues fixed
- [ ] Unit tests - N/A; the production helper runs in every APK instrumentation lane.
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants