diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-12 12:37:22 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-09-13 08:29:46 -0400 |
commit | 88ebc33840ff07701254e2f6e2484f229f09a6cc (patch) | |
tree | 45cdc572816e7877fe316417a241b79585abe9f7 /pkg/varlinkapi/containers.go | |
parent | b095d8a794edaab3b2d622b6882bfd57fad8375e (diff) | |
download | podman-88ebc33840ff07701254e2f6e2484f229f09a6cc.tar.gz podman-88ebc33840ff07701254e2f6e2484f229f09a6cc.tar.bz2 podman-88ebc33840ff07701254e2f6e2484f229f09a6cc.zip |
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>
Diffstat (limited to 'pkg/varlinkapi/containers.go')
-rw-r--r-- | pkg/varlinkapi/containers.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index 2dcdbc089..93f9d4fe3 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -319,12 +319,14 @@ func (i *LibpodAPI) ExportContainer(call iopodman.VarlinkCall, name, outPath str // GetContainerStats ... func (i *LibpodAPI) GetContainerStats(call iopodman.VarlinkCall, name string) error { - cgroupv2, err := cgroups.IsCgroup2UnifiedMode() - if err != nil { - return call.ReplyErrorOccurred(err.Error()) - } - if rootless.IsRootless() && !cgroupv2 { - return call.ReplyErrRequiresCgroupsV2ForRootless("rootless containers cannot report container stats") + if rootless.IsRootless() { + cgroupv2, err := cgroups.IsCgroup2UnifiedMode() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + if !cgroupv2 { + return call.ReplyErrRequiresCgroupsV2ForRootless("rootless containers cannot report container stats") + } } ctr, err := i.Runtime.LookupContainer(name) if err != nil { |