mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #4719 from kolyshkin/1.3-4709
[1.3] runc pause/unpause/ps: get rid of excessive warning
This commit is contained in:
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -28,13 +27,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 {
|
||||
@@ -43,6 +35,7 @@ var psCommand = cli.Command{
|
||||
|
||||
pids, err := container.Processes()
|
||||
if err != nil {
|
||||
maybeLogCgroupWarning("ps", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user