From 272c83e169526038e869cd9796fce3ca906d0a9f Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 31 Mar 2020 20:00:11 -0700 Subject: [PATCH] libct/cgroups: use errors.Unwrap Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/utils.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 7808c093..8a53cb09 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -576,7 +576,7 @@ func WriteCgroupProc(dir string, pid int) error { // EINVAL might mean that the task being added to cgroup.procs is in state // TASK_NEW. We should attempt to do so again. - if isEINVAL(err) { + if errors.Unwrap(err) == unix.EINVAL { time.Sleep(30 * time.Millisecond) continue } @@ -586,15 +586,6 @@ func WriteCgroupProc(dir string, pid int) error { return err } -func isEINVAL(err error) bool { - switch err := err.(type) { - case *os.PathError: - return err.Err == unix.EINVAL - default: - return false - } -} - // Since the OCI spec is designed for cgroup v1, in some cases // there is need to convert from the cgroup v1 configuration to cgroup v2 // the formula for BlkIOWeight is y = (1 + (x - 10) * 9999 / 990)