Skip to content

Commit 94dc2be

Browse files
authored
Merge pull request #4757 from HirazawaUi/fix-unable-delete
Preventing containers from being unable to be deleted
2 parents ff2494b + 1b39997 commit 94dc2be

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libcontainer/process_linux.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,20 @@ 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+
// If the runc-create process terminates due to SIGKILL before
561+
// reaching this line of code, we won't encounter the cgroup freezing issue.
562+
_, err = p.container.updateState(nil)
563+
if err != nil {
564+
return fmt.Errorf("unable to store init state before creating cgroup: %w", err)
565+
}
566+
553567
defer func() {
554568
if retErr != nil {
555569
// Find out if init is killed by the kernel's OOM killer.

0 commit comments

Comments
 (0)