mirror of
https://github.com/opencontainers/runc.git
synced 2025-04-18 19:44:09 +03:00
This issue was originally reported in podman PR 25792. When calling runc pause/unpause for an ordinary user, podman do not provide --systemd-cgroups option, and shouldUseRootlessCgroupManager returns true. This results in a warning: $ podman pause sleeper WARN[0000] runc pause may fail if you don't have the full access to cgroups sleeper Actually, it does not make sense to call shouldUseRootlessCgroupManager at this point, because we already know if we're rootless or not, from the container state.json (same for systemd). Also, busctl binary is not available either in this context, so shouldUseRootlessCgroupManager would not work properly. Finally, it doesn't really matter if we use systemd or not, because we use fs/fs2 manager to freeze/unfreeze, and it will return something like EPERM (or tell that cgroups is not configured, for a true rootless container). So, let's only print the warning after pause/unpause failed, if the error returned looks like a permission error. Same applies to "runc ps". Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var pauseCommand = cli.Command{
|
|
Name: "pause",
|
|
Usage: "pause suspends all processes inside the container",
|
|
ArgsUsage: `<container-id>
|
|
|
|
Where "<container-id>" is the name for the instance of the container to be
|
|
paused. `,
|
|
Description: `The pause command suspends all processes in the instance of the container.
|
|
|
|
Use runc list to identify instances of containers and their current status.`,
|
|
Action: func(context *cli.Context) error {
|
|
if err := checkArgs(context, 1, exactArgs); err != nil {
|
|
return err
|
|
}
|
|
container, err := getContainer(context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = container.Pause()
|
|
if err != nil {
|
|
maybeLogCgroupWarning("pause", err)
|
|
return err
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
var resumeCommand = cli.Command{
|
|
Name: "resume",
|
|
Usage: "resumes all processes that have been previously paused",
|
|
ArgsUsage: `<container-id>
|
|
|
|
Where "<container-id>" is the name for the instance of the container to be
|
|
resumed.`,
|
|
Description: `The resume command resumes all processes in the instance of the container.
|
|
|
|
Use runc list to identify instances of containers and their current status.`,
|
|
Action: func(context *cli.Context) error {
|
|
if err := checkArgs(context, 1, exactArgs); err != nil {
|
|
return err
|
|
}
|
|
container, err := getContainer(context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = container.Resume()
|
|
if err != nil {
|
|
maybeLogCgroupWarning("resume", err)
|
|
return err
|
|
}
|
|
return nil
|
|
},
|
|
}
|