diff --git a/oci.go b/oci.go index 3206bb12..abade61e 100644 --- a/oci.go +++ b/oci.go @@ -228,13 +228,9 @@ func processCgroupsPathForResource(ociSpec oci.CompatOCISpec, resource string, i } if !cgroupMountFound { - if isPod { - return "", fmt.Errorf("cgroupsPath %q is absolute, cgroup mount MUST exist", - ociSpec.Linux.CgroupsPath) - } - - // In case of container (CRI-O), if the mount point is not - // provided, we assume this is a relative path. + // According to the OCI spec, an absolute path should be + // interpreted as relative to the system cgroup mount point + // when there is no cgroup mount point. return filepath.Join(cgroupsDirPath, resource, ociSpec.Linux.CgroupsPath), nil } diff --git a/oci_test.go b/oci_test.go index 4a2d822e..4c1a889f 100644 --- a/oci_test.go +++ b/oci_test.go @@ -344,9 +344,9 @@ func TestProcessCgroupsPathRelativePathSuccessful(t *testing.T) { } } -func TestProcessCgroupsPathAbsoluteNoCgroupMountFailure(t *testing.T) { - assert := assert.New(t) +func TestProcessCgroupsPathAbsoluteNoCgroupMountSuccessful(t *testing.T) { absoluteCgroupsPath := "/absolute/cgroups/path" + cgroupsDirPath = "/foo/runtime/base" ociSpec := oci.CompatOCISpec{} @@ -357,9 +357,9 @@ func TestProcessCgroupsPathAbsoluteNoCgroupMountFailure(t *testing.T) { for _, d := range cgroupTestData { ociSpec.Linux.Resources = d.linuxSpec - _, err := processCgroupsPath(ociSpec, true) - assert.Error(err, "This test should fail because no cgroup mount provided (%+v)", d) - assert.False(vcMock.IsMockError(err)) + p := filepath.Join(cgroupsDirPath, d.resource, absoluteCgroupsPath) + + testProcessCgroupsPath(t, ociSpec, []string{p}) } }