Skip to content

Commit

Permalink
never ignore cgroup destroy error for runc-delete
Browse files Browse the repository at this point in the history
Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information
lifubang committed Oct 10, 2023
1 parent 4aee905 commit 9b7b013
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ func killContainer(container *libcontainer.Container) error {
for i := 0; i < 100; i++ {
time.Sleep(100 * time.Millisecond)
if err := container.Signal(unix.Signal(0)); err != nil {
destroy(container)
return nil
return destroy(container)
}
}
return errors.New("container init still running")
Expand Down Expand Up @@ -72,7 +71,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
}
switch s {
case libcontainer.Stopped:
destroy(container)
return destroy(container)
case libcontainer.Created:
return killContainer(container)
default:
Expand All @@ -81,7 +80,5 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
}
return fmt.Errorf("cannot delete container %s that is not stopped: %s", id, s)
}

return nil
},
}
3 changes: 3 additions & 0 deletions libcontainer/state_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type containerState interface {

func destroy(c *Container) error {
err := c.cgroupManager.Destroy()
if err != nil {
return err
}
if c.intelRdtManager != nil {
if ierr := c.intelRdtManager.Destroy(); err == nil {
err = ierr
Expand Down
6 changes: 2 additions & 4 deletions utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ func newProcess(p specs.Process) (*libcontainer.Process, error) {
return lp, nil
}

func destroy(container *libcontainer.Container) {
if err := container.Destroy(); err != nil {
logrus.Error(err)
}
func destroy(container *libcontainer.Container) error {
return container.Destroy()
}

// setupIO modifies the given process config according to the options.
Expand Down

0 comments on commit 9b7b013

Please sign in to comment.