Skip to content

libct: fix restored container status on init exit - #5374

Open
l46983284-cpu wants to merge 1 commit into
opencontainers:mainfrom
l46983284-cpu:5370-restored-state-exit
Open

libct: fix restored container status on init exit#5374
l46983284-cpu wants to merge 1 commit into
opencontainers:mainfrom
l46983284-cpu:5370-restored-state-exit

Conversation

@l46983284-cpu

@l46983284-cpu l46983284-cpu commented Jul 17, 2026

Copy link
Copy Markdown

Fixes #5370.

restoredState.transition accepted stopped/running without assigning c.state, so refreshState left a restored container stuck reporting Running after its init process exited.

With transition now updating c.state, Status()/refreshState correctly leave restoredState when init is gone. Restore must then also assign initProcessStartTime after updateState, matching create; otherwise hasInit() is false for a live restored process and checkpoint tests see stopped immediately.

Adds unit tests covering the transition state assignment for restored and running containers.

@l46983284-cpu
l46983284-cpu force-pushed the 5370-restored-state-exit branch from be54390 to 71bf3db Compare July 28, 2026 20:04
@l46983284-cpu

Copy link
Copy Markdown
Author

Follow-up for the CI residual: restore now sets initProcessStartTime the same way create does, so hasInit() stays true for a live restored process after the restoredState.transition fix. Added a unit test for that path.

Comment thread libcontainer/container_linux_test.go Outdated
Comment on lines +298 to +301
// TestRestoredStatusRequiresInitStartTime covers the checkpoint CI residual of #5370:
// after the restoredState.transition fix, Status() correctly leaves restoredState when
// !hasInit(). Restore must therefore set initProcessStartTime (as create does) so a
// live restored process still reports Running.

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.

This description better suits the commit message. From the perspective of someone reading the code a few years later, they are not very aware of various minor fixes that were made.

I think we can drop this test and squash the rest of the second commit into the first one.

Comment thread libcontainer/container_linux_test.go Outdated
container := &Container{
id: "restored-status",
config: &configs.Config{},
cgroupManager: &mockCgroupManager{

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.

We're removing the mockCgroupManager in #5382.

restoredState.transition accepted stopped/running without assigning
c.state, so refreshState left a restored container stuck reporting
Running after its init process exited.

With transition now updating c.state, Status()/refreshState correctly
leave restoredState when init is gone. Restore must then also assign
initProcessStartTime after updateState, matching create; otherwise
hasInit() is false for a live restored process and checkpoint tests
see stopped immediately (CI residual of opencontainers#5370).

Fixes opencontainers#5370

Signed-off-by: Alex Chen <l46983284@gmail.com>
@l46983284-cpu
l46983284-cpu force-pushed the 5370-restored-state-exit branch from 71bf3db to 0e171a9 Compare July 29, 2026 19:37
@l46983284-cpu l46983284-cpu changed the title libct: fix restoredState status after process exit libct: fix restored container status on init exit Jul 29, 2026
@l46983284-cpu

Copy link
Copy Markdown
Author

Done — dropped the test, squashed everything into a single commit, and moved the rationale into the commit message. Also good timing on #5382 then.

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.

runc state reports a CRIU-restored container as running after its process has exited

2 participants