Commit ac52ced
committed
Surface lastExitCode on ContainerSnapshot
Adds an optional lastExitCode: Int32? field to ContainerSnapshot,
populated in ContainersService.handleContainerExit when the container
transitions to .stopped. The exit code is taken from the existing
ExitMonitor callback's ExitStatus value.
This unblocks Container-Compose's depends_on:
condition: service_completed_successfully
which currently has to fall back to a stopped-only check because the
SDK doesn't surface the underlying process exit code.
Wire format note: ContainerSnapshot is marshaled as Codable JSON over
XPC. Adding an optional field is forward-compatible; older clients
will silently ignore the new key, and newer clients reading from older
servers will decode lastExitCode as nil.
Scope: in-memory only. The exit code lives in the in-memory ContainerState
snapshot for the duration of apiserver uptime. A daemon restart resets
all snapshots to .stopped without exit codes (existing behavior). A
follow-up patch can add bundle persistence (exit_status.json) if needed
to survive restarts.
Files:
- Sources/ContainerResource/Container/ContainerSnapshot.swift: new
field + init parameter (default nil for backward compat at all
existing construction sites).
- Sources/Services/ContainerAPIService/Server/Containers/ContainersService.swift:
one assignment in handleContainerExit's terminal state block.1 parent 0c06aa7 commit ac52ced
2 files changed
Lines changed: 8 additions & 1 deletion
File tree
- Sources
- ContainerResource/Container
- Services/ContainerAPIService/Server/Containers
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | | - | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
| 1014 | + | |
1014 | 1015 | | |
1015 | 1016 | | |
1016 | 1017 | | |
| |||
0 commit comments