Skip to content

Commit 29dcef9

Browse files
HirazawaUikolyshkin
authored andcommitted
Preventing containers from being unable to be deleted
Signed-off-by: HirazawaUi <695097494plus@gmail.com>
1 parent 8d90e3d commit 29dcef9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libcontainer/process_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,18 @@ func (p *initProcess) start() (retErr error) {
550550
return fmt.Errorf("unable to start init: %w", err)
551551
}
552552

553+
// If the runc-create process is terminated due to receiving SIGKILL signal,
554+
// it may lead to the runc-init process leaking due
555+
// to issues like cgroup freezing,
556+
// and it cannot be cleaned up by runc delete/stop
557+
// because the container lacks a state.json file.
558+
// This typically occurs when higher-level
559+
// container runtimes terminate the runc create process due to context cancellation or timeout.
560+
_, err = p.container.updateState(nil)
561+
if err != nil {
562+
return fmt.Errorf("unable to store init state before creating cgroup: %w", err)
563+
}
564+
553565
defer func() {
554566
if retErr != nil {
555567
// Find out if init is killed by the kernel's OOM killer.

0 commit comments

Comments
 (0)