libct: fix restoredState status after process exit#5374
Open
l46983284-cpu wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After
runc restore, if the container process later exits,runc statekept reportingrunninginstead ofstopped. Normalrun/startcontainers already reportstoppedcorrectly in the same situation.refreshState()tries to move tostoppedStatewhen init is gone, butrestoredState.transitionaccepted that transition without assigningc.state. BecauserestoredState.status()hardcodesRunning, 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