From cac4919bf6d4070e792e9acc0e0d49a745e70ef9 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 1 Nov 2022 21:16:17 +0100 Subject: [PATCH] runtime: add check for valid pod systemd cgroup there is already the same check when using cgroupfs, but not when using the systemd cgroup backend. The check is needed to avoid a confusing error from the OCI runtime. Closes: https://github.com/containers/podman/issues/16376 Signed-off-by: Giuseppe Scrivano --- libpod/runtime_ctr.go | 7 +++++++ test/upgrade/test-upgrade.bats | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index bb30078cb5..ba433901b5 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -382,6 +382,13 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai if err != nil { return nil, fmt.Errorf("retrieving pod %s cgroup: %w", pod.ID(), err) } + expectPodCgroup, err := ctr.expectPodCgroup() + if err != nil { + return nil, err + } + if expectPodCgroup && podCgroup == "" { + return nil, fmt.Errorf("pod %s cgroup is not set: %w", pod.ID(), define.ErrInternal) + } ctr.config.CgroupParent = podCgroup case rootless.IsRootless() && ctr.config.CgroupsMode != cgroupSplit: ctr.config.CgroupParent = SystemdDefaultRootlessCgroupParent diff --git a/test/upgrade/test-upgrade.bats b/test/upgrade/test-upgrade.bats index dca97e324d..9cf3c48127 100644 --- a/test/upgrade/test-upgrade.bats +++ b/test/upgrade/test-upgrade.bats @@ -320,6 +320,10 @@ failed | exited | 17 run_podman pod start mypod is "$output" "[0-9a-f]\\{64\\}" "podman pod start" + # run a container in an existing pod + run_podman run --pod=mypod --ipc=host --rm $IMAGE echo it works + is "$output" ".*it works.*" "podman run --pod" + run_podman pod ps is "$output" ".*mypod.*" "podman pod ps shows name" is "$output" ".*Running.*" "podman pod ps shows running state"