Merge pull request #4709 from kolyshkin/pause-warn

runc pause/unpause/ps: get rid of excessive warning
This commit is contained in:
Rodrigo Campos
2025-04-09 07:15:51 -03:00
committed by GitHub
3 changed files with 20 additions and 25 deletions
+12 -17
View File
@@ -1,7 +1,6 @@
package main
import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -19,18 +18,16 @@ Use runc list to identify instances of containers and their current status.`,
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
rootlessCg, err := shouldUseRootlessCgroupManager(context)
if err != nil {
return err
}
if rootlessCg {
logrus.Warnf("runc pause may fail if you don't have the full access to cgroups")
}
container, err := getContainer(context)
if err != nil {
return err
}
return container.Pause()
err = container.Pause()
if err != nil {
maybeLogCgroupWarning("pause", err)
return err
}
return nil
},
}
@@ -48,17 +45,15 @@ Use runc list to identify instances of containers and their current status.`,
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
rootlessCg, err := shouldUseRootlessCgroupManager(context)
if err != nil {
return err
}
if rootlessCg {
logrus.Warn("runc resume may fail if you don't have the full access to cgroups")
}
container, err := getContainer(context)
if err != nil {
return err
}
return container.Resume()
err = container.Resume()
if err != nil {
maybeLogCgroupWarning("resume", err)
return err
}
return nil
},
}
+1 -8
View File
@@ -10,7 +10,6 @@ import (
"strconv"
"strings"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -29,13 +28,6 @@ var psCommand = cli.Command{
if err := checkArgs(context, 1, minArgs); err != nil {
return err
}
rootlessCg, err := shouldUseRootlessCgroupManager(context)
if err != nil {
return err
}
if rootlessCg {
logrus.Warn("runc ps may fail if you don't have the full access to cgroups")
}
container, err := getContainer(context)
if err != nil {
@@ -44,6 +36,7 @@ var psCommand = cli.Command{
pids, err := container.Processes()
if err != nil {
maybeLogCgroupWarning("ps", err)
return err
}
+7
View File
@@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"
"io/fs"
"net"
"os"
"path/filepath"
@@ -448,3 +449,9 @@ func setupPidfdSocket(process *libcontainer.Process, sockpath string) (_clean fu
conn.Close()
}, nil
}
func maybeLogCgroupWarning(op string, err error) {
if errors.Is(err, fs.ErrPermission) {
logrus.Warn("runc " + op + " failure might be caused by lack of full access to cgroups")
}
}