From 9b7b0132e4a0a46d8f5abf93bb752ac9d43d8c48 Mon Sep 17 00:00:00 2001 From: lifubang Date: Tue, 10 Oct 2023 11:34:09 +0800 Subject: [PATCH] never ignore cgroup destroy error for runc-delete Signed-off-by: lifubang --- delete.go | 7 ++----- libcontainer/state_linux.go | 3 +++ utils_linux.go | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/delete.go b/delete.go index 682101ccad8..38c6f88200e 100644 --- a/delete.go +++ b/delete.go @@ -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") @@ -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: @@ -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 }, } diff --git a/libcontainer/state_linux.go b/libcontainer/state_linux.go index 8d8f31d3678..aa406767126 100644 --- a/libcontainer/state_linux.go +++ b/libcontainer/state_linux.go @@ -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 diff --git a/utils_linux.go b/utils_linux.go index 0f787cb3387..e0a00f01cdd 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -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.