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:
Daniel J Walsh
2019-09-12 12:37:22 -04:00
parent b095d8a794
commit 88ebc33840
4 changed files with 32 additions and 7 deletions

View File

@ -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