-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add creating status to ensure state.json exists when runc kill. #4645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,3 +242,20 @@ func (n *loadedState) destroy() error { | |
} | ||
return n.c.state.destroy() | ||
} | ||
|
||
type creatingState struct { | ||
c *Container | ||
} | ||
|
||
func (i *creatingState) status() Status { | ||
return Creating | ||
} | ||
|
||
func (i *creatingState) transition(s containerState) error { | ||
return newStateTransitionError(i, s) | ||
} | ||
|
||
func (i *creatingState) destroy() error { | ||
_ = signalAllProcesses(i.c.cgroupManager, unix.SIGKILL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks wrong.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ![]() Between the creation of cgroup and waitForChildExit, the pid of runc init[STAGE_PARENT], runc init[STAGE_CHILD], and runc init[STAGE_INIT] will exist in the cgroup. runc delete does not know which process to send SIGKILL to. Considering the possible existence of processes like runc init PARENT, CHILD, etc., it is necessary to kill the processes in cgroup.procs one by one. When I was contemplating about writing a function to terminate all processes in cgroup.procs, I discovered that signalAllProcesses already does exactly that, so I directly called it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Maybe add a comment, something like // Use signalAllProcesses here because various stages of `runc init` might be in the cgroup. |
||
return destroy(i.c) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This state is awfully similar to the created state. I haven't had a deep look into this, but any reason to not use the created state?
I think if we remove the c.Init assignment as this PR does, and we run the
p.container.UpdateState()
as this PR also does, maybe it will also fix the problem?It seems in that case, the refreshstate will return the created state, the only difference is that the destroy function is
_ = i.c.initProcess.signal(unix.SIGKILL)
. If that is a problem, maybe the signalAllProcesses can work for the other things in the created state too?Am I missing something?