Skip to content

Commit 17c61e3

Browse files
committed
Fix cgroups path for base OCI spec
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent df8d6c5 commit 17c61e3

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/server/container_create.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ func (c *criService) runtimeSpec(id string, baseSpecFile string, opts ...oci.Spe
313313
return nil, errors.Wrap(err, "failed to clone OCI spec")
314314
}
315315

316-
if err := oci.ApplyOpts(ctx, nil, container, &spec, opts...); err != nil {
316+
// Fix up cgroups path
317+
applyOpts := append([]oci.SpecOpts{oci.WithNamespacedCgroup()}, opts...)
318+
319+
if err := oci.ApplyOpts(ctx, nil, container, &spec, applyOpts...); err != nil {
317320
return nil, errors.Wrap(err, "failed to apply OCI options")
318321
}
319322

pkg/server/container_create_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
3030

3131
"github.com/containerd/cri/pkg/config"
32+
"github.com/containerd/cri/pkg/constants"
3233
"github.com/containerd/cri/pkg/containerd/opts"
3334
)
3435

@@ -401,4 +402,6 @@ func TestBaseRuntimeSpec(t *testing.T) {
401402
// Make sure original base spec not changed
402403
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
403404
assert.Equal(t, c.baseOCISpecs["/etc/containerd/cri-base.json"].Hostname, "old")
405+
406+
assert.Equal(t, filepath.Join("/", constants.K8sContainerdNamespace, "id1"), out.Linux.CgroupsPath)
404407
}

0 commit comments

Comments
 (0)