Skip to content

Commit 03244ef

Browse files
authored
Merge pull request #3217 from kolyshkin/delete-paused
runc delete -f: fix for cg v1 + paused container
2 parents 206c16a + 6806b2c commit 03244ef

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libcontainer/container_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,14 @@ func (c *linuxContainer) Signal(s os.Signal, all bool) error {
393393
if err := c.initProcess.signal(s); err != nil {
394394
return fmt.Errorf("unable to signal init: %w", err)
395395
}
396+
if status == Paused {
397+
// For cgroup v1, killing a process in a frozen cgroup
398+
// does nothing until it's thawed. Only thaw the cgroup
399+
// for SIGKILL.
400+
if s, ok := s.(unix.Signal); ok && s == unix.SIGKILL {
401+
_ = c.cgroupManager.Freeze(configs.Thawed)
402+
}
403+
}
396404
return nil
397405
}
398406
return ErrNotRunning

tests/integration/delete.bats

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ function teardown() {
5050
[ "$status" -eq 0 ]
5151
}
5252

53+
@test "runc delete --force [paused container]" {
54+
runc run -d --console-socket "$CONSOLE_SOCKET" ct1
55+
[ "$status" -eq 0 ]
56+
testcontainer ct1 running
57+
58+
runc pause ct1
59+
runc delete --force ct1
60+
[ "$status" -eq 0 ]
61+
}
62+
5363
@test "runc delete --force in cgroupv1 with subcgroups" {
5464
requires cgroups_v1 root cgroupns
5565
set_cgroups_path

0 commit comments

Comments
 (0)