mirror of
https://github.com/containers/podman.git
synced 2025-05-21 09:05:56 +08:00
Report errors when trying to pause rootless containers
If you are running a rootless container on cgroupV1 you can not pause the container. We need to report the proper error if this happens. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
"github.com/containers/libpod/libpod/events"
|
||||
"github.com/containers/libpod/pkg/cgroups"
|
||||
"github.com/containers/libpod/pkg/rootless"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -163,6 +165,16 @@ func (p *Pod) Pause() (map[string]error, error) {
|
||||
return nil, define.ErrPodRemoved
|
||||
}
|
||||
|
||||
if rootless.IsRootless() {
|
||||
cgroupv2, err := cgroups.IsCgroup2UnifiedMode()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to determine cgroupversion")
|
||||
}
|
||||
if !cgroupv2 {
|
||||
return nil, errors.Wrap(define.ErrNoCgroups, "can not pause pods containing rootless containers with cgroup V1")
|
||||
}
|
||||
}
|
||||
|
||||
allCtrs, err := p.runtime.state.PodContainers(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user