From 62e03415df5169083b04bd2de95ac8549c6f2b03 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 3 Apr 2019 14:20:20 -0600 Subject: [PATCH] virtcontainers: skip cgroup namespace check Old kernels, like 3.x, does not support cgroup namespace. Skip the test that checks this namespace if its path in /proc doesn't exist. Depends-on: github.com/kata-containers/tests#1414 fixes #228 Signed-off-by: Julio Montes --- virtcontainers/pkg/nsenter/nsenter_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtcontainers/pkg/nsenter/nsenter_test.go b/virtcontainers/pkg/nsenter/nsenter_test.go index 8d277520c6..d0dfa5a97a 100644 --- a/virtcontainers/pkg/nsenter/nsenter_test.go +++ b/virtcontainers/pkg/nsenter/nsenter_test.go @@ -84,6 +84,12 @@ func TestGetFileFromNSWrongNSPathFailure(t *testing.T) { func TestGetFileFromNSSuccessful(t *testing.T) { for nsType := range CloneFlagsTable { nsFilePath := fmt.Sprintf("/proc/self/ns/%s", string(nsType)) + if _, err := os.Stat(nsFilePath); os.IsNotExist(err) { + // some namespaces, like cgroup, are too new for longterm distros with + // old kernels. + t.Logf("Namespace '%s' is not supported in this kernel. Update your kernel to a version >4.0", string(nsType)) + continue + } nsFile, err := getFileFromNS(nsFilePath) assert.Nil(t, err, "Should have succeeded: %v", err) assert.NotNil(t, nsFile, "The file handler should not be nil")