summaryrefslogtreecommitdiff
path: root/pkg/cgroups/cgroups_test.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-01-26 10:51:01 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2021-01-27 15:16:24 -0500
commit89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a (patch)
tree15d09d9451aa8187f7e265f9fab29c511d5df9fe /pkg/cgroups/cgroups_test.go
parent14cc4aaf0a364bf0f4f7f77ec5f58fd79b1cb99e (diff)
downloadpodman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.tar.gz
podman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.tar.bz2
podman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.zip
Don't fail if one of the cgroups is not setup
It is fairly common for certain cgroups controllers to not be enabled on a system. We should Warn when this happens versus failing, when doing podman stats command. This way users can get information from the other controllers. Fixes: https://github.com/containers/podman/issues/8588 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/cgroups/cgroups_test.go')
-rw-r--r--pkg/cgroups/cgroups_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/cgroups/cgroups_test.go b/pkg/cgroups/cgroups_test.go
new file mode 100644
index 000000000..54315f7be
--- /dev/null
+++ b/pkg/cgroups/cgroups_test.go
@@ -0,0 +1,32 @@
+package cgroups
+
+import (
+ "testing"
+
+ "github.com/containers/podman/v2/pkg/rootless"
+ spec "github.com/opencontainers/runtime-spec/specs-go"
+)
+
+func TestCreated(t *testing.T) {
+ // tests only works in rootless mode
+ if rootless.IsRootless() {
+ return
+ }
+
+ var resources spec.LinuxResources
+ cgr, err := New("machine.slice", &resources)
+ if err != nil {
+ t.Error(err)
+ }
+ if err := cgr.Delete(); err != nil {
+ t.Error(err)
+ }
+
+ cgr, err = NewSystemd("machine.slice")
+ if err != nil {
+ t.Error(err)
+ }
+ if err := cgr.Delete(); err != nil {
+ t.Error(err)
+ }
+}