Skip to content

Record Docker die and stop events with parity - #41770

Merged
beena352 merged 5 commits into
microsoft:masterfrom
beena352:users/beenachauhan/events-die-stop
Oct 2, 2026
Merged

beena352 merged 5 commits into
microsoft:masterfrom
beena352:users/beenachauhan/events-die-stop

Conversation

@beena352

@beena352 beena352 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Make wslc events report Docker container exit and stop events separately. Keep kill and stop events available after container cleanup, and preserve the requested image name for -P containers and after recovery.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Docker's die event is now reported as die, with its exit code. Docker's separate stop event is recorded without changing container state. kill and stop are recorded at session level, so they remain available even if the container is auto-removed. Docker attributes such as signal are preserved, while WSLC's private metadata label is removed.
The requested image name is saved in the container metadata. This keeps image information correct for -P containers and after recovery. Older containers without the new field continue to use Docker's image value.

Validation Steps Performed

Copilot AI balanced review requested due to automatic review settings October 2, 2026 02:19

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.

Copilot review overview

🟢 Approval recommended

The implementation is coherent across event tracking, recovery, metadata compatibility, and automated coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Separates Docker die and stop events while preserving action metadata and requested image names across recovery.

Changes:

  • Records kill and stop at session scope and reports exits as die.
  • Persists requested image names in container metadata.
  • Adds unit and end-to-end coverage for event parity, cleanup, filtering, and recovery.
File Description
test/​windows/​WSLCTests.cpp Expands event and recovery tests.
test/​windows/​wslc/​e2e/​WSLCE2EEventsTests.cpp Updates CLI event expectations.
src/​windows/​wslcsession/​WSLCSession.h Declares session-level action tracking.
src/​windows/​wslcsession/​WSLCSession.cpp Records container actions in the event store.
src/​windows/​wslcsession/​WSLCContainerMetadata.h Persists the requested image name.
src/​windows/​wslcsession/​WSLCContainer.h Exposes event-attribute normalization.
src/​windows/​wslcsession/​WSLCContainer.cpp Reports die and restores requested images.
src/​windows/​wslcsession/​DockerEventTracker.h Adds container-action callback support.
src/​windows/​wslcsession/​DockerEventTracker.cpp Routes kill and stop independently.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@beena352
beena352 marked this pull request as ready for review October 2, 2026 17:06
@beena352
beena352 requested review from a team as code owners October 2, 2026 17:06

@dkbennett David Bennett (dkbennett) left a comment

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.

Looks good but one parity gap remains:

Docker's die event includes execDuration, but WSLC drops it: DockerEventTracker forwards only the exit code, and RecordEvent reconstructs the attributes. The new kill/stop path preserves Docker attributes. Consider sharing attribute normalization across these paths and asserting execDuration against the underlying Docker event.

If goal of this PR is parity should fix that.

Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread src/windows/wslcsession/DockerEventTracker.cpp Outdated
Copilot AI balanced review requested due to automatic review settings October 2, 2026 20: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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment on lines +163 to +164
const auto execDuration =
lines[2].substr(execDurationValueStart, lines[2].find(L',', execDurationValueStart) - execDurationValueStart);
// Docker can report 'stop' before 'die', so it's published with the exit transition instead.
if (m_state == WslcContainerStateRunning)
{
m_pendingStopAttributes = attributes;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Doing this could unfortunately create a race if we receive stop that actually mapped to a previously running instance.

We could in theory have a Start() arrive after a kill, and if the stop notification from docker arrives after the start(), we could end up in a situation where we'll emit a "broken" stop.

Interestingly, this also seems to be a race inside docker, so for now I think we're OK to merge as-is.

I did some thinking and I haven't found an "easy" solution that wouldn't require a bigger change. Let's revisit if this turns out to be an issue later

@beena352
beena352 merged commit a4b297c into microsoft:master Oct 2, 2026
9 checks passed
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.

4 participants