Skip to content

libct: fix restoredState status after process exit#5374

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

libct: fix restoredState status after process exit#5374
l46983284-cpu wants to merge 1 commit into
opencontainers:mainfrom
l46983284-cpu:5370-restored-state-exit

Conversation

@l46983284-cpu

Copy link
Copy Markdown

Summary

After runc restore, if the container process later exits, runc state kept reporting running instead of stopped. Normal run/start containers already report stopped correctly in the same situation.

refreshState() tries to move to stoppedState when init is gone, but restoredState.transition accepted that transition without assigning c.state. Because restoredState.status() hardcodes Running, the container stayed "running" forever.

This PR assigns the new state in restoredState.transition, matching the other state types, and adds a unit test for the restored→stopped path (no root/CRIU required).

Fixes #5370

Test plan

  • go test ./libcontainer/ -run 'TestRestoredStateExitedReportsStopped|TestRunningStateExitedReportsStopped|TestRestoredStateTransition|TestState' -count=1
  • Existing state-machine tests still pass

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

Assign the new state like the other state types, and add a unit test
that covers the restored-to-stopped path without needing root or CRIU.

Fixes opencontainers#5370

Signed-off-by: Alex Chen <l46983284@gmail.com>
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

1 participant