stats: ignore errors from containers without cgroups
Now `podman stats --all` ignores failures from a container that has no cgroups. Closes: https://github.com/containers/podman/issues/24632 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
ceee7cb0a6
commit
6673f5c202
|
|
@ -1633,7 +1633,8 @@ func (ic *ContainerEngine) ContainerStats(ctx context.Context, namesOrIds []stri
|
|||
// update the container state
|
||||
// https://github.com/containers/podman/issues/23334
|
||||
(errors.Is(err, define.ErrCtrRemoved) || errors.Is(err, define.ErrNoSuchCtr) ||
|
||||
errors.Is(err, define.ErrCtrStateInvalid) || errors.Is(err, define.ErrCtrStopped)) {
|
||||
errors.Is(err, define.ErrCtrStateInvalid) || errors.Is(err, define.ErrCtrStopped) ||
|
||||
errors.Is(err, define.ErrNoCgroups)) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -52,6 +52,19 @@ load helpers
|
|||
# --cgroupns=host is required to have full visibility of the cgroup path inside the container
|
||||
run_podman run --cgroups=disabled --cgroupns=host --rm $IMAGE cat /proc/self/cgroup
|
||||
is "$output" $current_cgroup "--cgroups=disabled must not change the current cgroup"
|
||||
|
||||
ctr1="c1-$(safename)"
|
||||
ctr2="c2-$(safename)"
|
||||
|
||||
# verify that "podman stats --all" works when there is a container with --cgroups=disabled
|
||||
run_podman run --cgroups=disabled --name $ctr1 -d $IMAGE top
|
||||
run_podman run --name $ctr2 -d $IMAGE top
|
||||
|
||||
run_podman stats -a --no-stream --no-reset
|
||||
assert "$output" !~ "$ctr1" "ctr1 not in stats output"
|
||||
assert "$output" =~ "$ctr2" "ctr2 in stats output"
|
||||
|
||||
run_podman rm -f -t 0 $ctr1 $ctr2
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
|
|
|||
Loading…
Reference in New Issue