From 9aa1ed805ac409e83bf67eefea40c28120a8ae0e Mon Sep 17 00:00:00 2001 From: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:24:07 +0800 Subject: [PATCH] runtime: add SingleContainer when obtaining OCI Spec When creating a cgroup, add a SingleContainer when obtaining the OCI Spec to apply to ctr, podman, etc. Fixes: #5240 Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com> --- src/runtime/virtcontainers/sandbox.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/runtime/virtcontainers/sandbox.go b/src/runtime/virtcontainers/sandbox.go index d921988292..548c6f8300 100644 --- a/src/runtime/virtcontainers/sandbox.go +++ b/src/runtime/virtcontainers/sandbox.go @@ -2576,11 +2576,12 @@ func (s *Sandbox) GetPatchedOCISpec() *specs.Spec { return nil } - // get the container associated with the PodSandbox annotation. In Kubernetes, this - // represents the pause container. In Docker, this is the container. - // On Linux, we derive the group path from this container. + // Get the container associated with the PodSandbox annotation. + // In Kubernetes, this represents the pause container. + // In CRI-compliant runtimes like Containerd, this is the container. + // On Linux, we derive the cgroup path from this container. for _, cConfig := range s.config.Containers { - if cConfig.Annotations[annotations.ContainerTypeKey] == string(PodSandbox) { + if ContainerType(cConfig.Annotations[annotations.ContainerTypeKey]).IsSandbox() { return cConfig.CustomSpec } }