Skip to content

Commit 47756ed

Browse files
authored
Merge pull request #4410 from lifubang/feat-add-ErrCgroupNotExist
Add ErrCgroupNotExist
2 parents a1acfcf + 10c951e commit 47756ed

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

libcontainer/container_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ func (c *Container) Signal(s os.Signal) error {
394394
// https://github.com/opencontainers/runc/pull/4395#pullrequestreview-2291179652
395395
return c.signal(s)
396396
}
397+
// For not rootless container, if there is no init process and no cgroup,
398+
// it means that the container is not running.
399+
if errors.Is(err, ErrCgroupNotExist) && !c.hasInit() {
400+
err = ErrNotRunning
401+
}
397402
return fmt.Errorf("unable to kill all processes: %w", err)
398403
}
399404
return nil

libcontainer/error.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package libcontainer
33
import "errors"
44

55
var (
6-
ErrExist = errors.New("container with given ID already exists")
7-
ErrInvalidID = errors.New("invalid container ID format")
8-
ErrNotExist = errors.New("container does not exist")
9-
ErrPaused = errors.New("container paused")
10-
ErrRunning = errors.New("container still running")
11-
ErrNotRunning = errors.New("container not running")
12-
ErrNotPaused = errors.New("container not paused")
6+
ErrExist = errors.New("container with given ID already exists")
7+
ErrInvalidID = errors.New("invalid container ID format")
8+
ErrNotExist = errors.New("container does not exist")
9+
ErrPaused = errors.New("container paused")
10+
ErrRunning = errors.New("container still running")
11+
ErrNotRunning = errors.New("container not running")
12+
ErrNotPaused = errors.New("container not paused")
13+
ErrCgroupNotExist = errors.New("cgroup not exist")
1314
)

libcontainer/init_linux.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,9 @@ func setupPersonality(config *configs.Config) error {
695695

696696
// signalAllProcesses freezes then iterates over all the processes inside the
697697
// manager's cgroups sending the signal s to them.
698-
//
699-
// signalAllProcesses returns ErrNotRunning when the cgroup does not exist.
700698
func signalAllProcesses(m cgroups.Manager, s unix.Signal) error {
701699
if !m.Exists() {
702-
return ErrNotRunning
700+
return ErrCgroupNotExist
703701
}
704702
// Use cgroup.kill, if available.
705703
if s == unix.SIGKILL {

0 commit comments

Comments
 (0)