Skip to content

Commit

Permalink
Merge pull request #4410 from lifubang/feat-add-ErrCgroupNotExist
Browse files Browse the repository at this point in the history
Add ErrCgroupNotExist
  • Loading branch information
kolyshkin authored Sep 24, 2024
2 parents a1acfcf + 10c951e commit 47756ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ func (c *Container) Signal(s os.Signal) error {
// https://github.com/opencontainers/runc/pull/4395#pullrequestreview-2291179652
return c.signal(s)
}
// For not rootless container, if there is no init process and no cgroup,
// it means that the container is not running.
if errors.Is(err, ErrCgroupNotExist) && !c.hasInit() {
err = ErrNotRunning
}
return fmt.Errorf("unable to kill all processes: %w", err)
}
return nil
Expand Down
15 changes: 8 additions & 7 deletions libcontainer/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package libcontainer
import "errors"

var (
ErrExist = errors.New("container with given ID already exists")
ErrInvalidID = errors.New("invalid container ID format")
ErrNotExist = errors.New("container does not exist")
ErrPaused = errors.New("container paused")
ErrRunning = errors.New("container still running")
ErrNotRunning = errors.New("container not running")
ErrNotPaused = errors.New("container not paused")
ErrExist = errors.New("container with given ID already exists")
ErrInvalidID = errors.New("invalid container ID format")
ErrNotExist = errors.New("container does not exist")
ErrPaused = errors.New("container paused")
ErrRunning = errors.New("container still running")
ErrNotRunning = errors.New("container not running")
ErrNotPaused = errors.New("container not paused")
ErrCgroupNotExist = errors.New("cgroup not exist")
)
4 changes: 1 addition & 3 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,9 @@ func setupPersonality(config *configs.Config) error {

// signalAllProcesses freezes then iterates over all the processes inside the
// manager's cgroups sending the signal s to them.
//
// signalAllProcesses returns ErrNotRunning when the cgroup does not exist.
func signalAllProcesses(m cgroups.Manager, s unix.Signal) error {
if !m.Exists() {
return ErrNotRunning
return ErrCgroupNotExist
}
// Use cgroup.kill, if available.
if s == unix.SIGKILL {
Expand Down

0 comments on commit 47756ed

Please sign in to comment.