Repository navigation
shim-runc-v2: record exit status in bundle - #14113
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The behavioral change is well-scoped, exercised by new unit/integration tests, and only a minor log-message wording nit was found.
Pull request overview
This PR fixes incorrect/ambiguous duplicate task exit/delete events when a shim is cleaned up via the shim delete path by persisting the actual runc.Exit (pid/status/timestamp) into the bundle state directory and reusing it during forced cleanup.
Changes:
- Record init-process exit status/time into
exitstatus.jsonin the bundle (shim side) when the init exits. - Teach shim-delete cleanup to prefer the recorded exit status (falling back to SIGKILL semantics when unavailable).
- Add/extend integration tests to assert correct exit/delete event contents (including multi-container shared-shim cases), vendoring
protocmp/cmpoptsto make protobuf comparisons robust.
File summaries
| File | Description |
|---|---|
cmd/containerd-shim-runc-v2/task/service.go |
Persist init exit status/timestamp into the bundle on init exit. |
cmd/containerd-shim-runc-v2/runc/util.go |
Add atomic write/read helpers for exitstatus.json in the bundle dir. |
cmd/containerd-shim-runc-v2/runc/util_test.go |
Unit tests for exitstatus read/write validation and corruption handling. |
cmd/containerd-shim-runc-v2/manager/manager_linux.go |
Prefer recorded exit status during forced cleanup (shim-delete path), with fallback behavior retained. |
integration/release_upgrade_linux_test.go |
Refactor shim bundle client builder to support non-k8s.io namespaces. |
integration/release_upgrade_exit_status_linux_test.go |
Add upgrade regression test coverage around shim exit-status handling. |
integration/issue7496_shutdown_linux_test.go |
Strengthen event assertions (exit/delete payloads) and add multi-container shared-shim exit-status preservation coverage. |
vendor/modules.txt |
Update vendored module package list for newly required packages. |
vendor/google.golang.org/protobuf/testing/protocmp/xform.go |
Vendored protocmp support (protobuf-aware cmp transforms). |
vendor/google.golang.org/protobuf/testing/protocmp/util.go |
Vendored protocmp utility options (ignore/sort/filter). |
vendor/google.golang.org/protobuf/testing/protocmp/reflect.go |
Vendored protocmp reflective message/list/map adapters. |
vendor/google.golang.org/protobuf/internal/msgfmt/format.go |
Vendored protobuf message formatter used by protocmp. |
vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go |
Vendored cmpopts helpers used by protocmp/tests. |
vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go |
Vendored cmpopts struct filtering utilities. |
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go |
Vendored cmpopts sorting transformers. |
vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go |
Vendored cmpopts ignore options. |
vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go |
Vendored cmpopts equate/comparer helpers. |
Review details
- Files reviewed: 7/17 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2d80347 to
0a95d5b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Exit status persistence is currently coupled to delayed init-exit publication, leaving a window where a shim can terminate before writing exitstatus.json, reintroducing the incorrect fallback status.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 7/17 changed files
- Comments generated: 1
- Review effort level: Lite
The task plugin may send duplicate task events to a subscriber. The second event is generated by the shim delete command and currently it doesn't know when container exited and what its exit code is. So, it always returns 137 as exit code. It may leave subscribers unsure which event they should trust (see containerd#6429). This patch stores exit status into bundle state dir. The bundle state dir is recommended to be tmpfs. Ideally, the write syscall won't take too long. Signed-off-by: Wei Fu <[email protected]>
0a95d5b to
3264a09
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new exit-status recording currently overwrites the exit timestamp with a time.Now()-derived value, which can make the persisted exit metadata inaccurate and should be corrected before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 7/17 changed files
- Comments generated: 1
- Review effort level: Lite
|
@AkihiroSuda could you please take a look on this? thanks |
The task plugin may send duplicate task events to a subscriber. The second event is generated by the shim delete command and currently it doesn't know when container exited and what its exit code is. So, it always returns 137 as exit code. It may leave subscribers unsure which event they should trust (see #6429).
This patch stores exit status into bundle state dir. The bundle state dir is recommended to be tmpfs. Ideally, the write syscall won't take too long.
Follow-up: #14020