mirror of https://github.com/containers/podman.git
pod: ps does not race with rm
the "pod ps" command first retrieves the list of all pods, then iterates over the list to inspect each pod. This introduce a race since a pod could be deleted in the meanwhile by another process. Solve it by ignoring the define.ErrNoSuchPod error. Closes: https://github.com/containers/podman/issues/14736 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
0cabd8006b
commit
0e03a64f99
|
@ -483,6 +483,9 @@ func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOpti
|
|||
for _, p := range pds {
|
||||
r, err := ic.listPodReportFromPod(p)
|
||||
if err != nil {
|
||||
if errors.Is(err, define.ErrNoSuchPod) || errors.Is(err, define.ErrNoSuchCtr) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
reports = append(reports, r)
|
||||
|
|
|
@ -495,7 +495,22 @@ spec:
|
|||
local actual2=$(< /sys/fs/cgroup/$path2/cpu.max)
|
||||
is "$actual2" "500000 100000" "resource limits set properly"
|
||||
run_podman --cgroup-manager=cgroupfs pod rm $name2
|
||||
}
|
||||
|
||||
@test "podman pod ps doesn't race with pod rm" {
|
||||
# create a few pods
|
||||
for i in {0..10}; do
|
||||
run_podman pod create
|
||||
done
|
||||
|
||||
# and delete them
|
||||
$PODMAN pod rm -a &
|
||||
|
||||
# pod ps should not fail while pods are deleted
|
||||
run_podman pod ps -q
|
||||
|
||||
# wait for pod rm -a
|
||||
wait
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
|
Loading…
Reference in New Issue