Skip to content

Commit

Permalink
Merge pull request #24701 from giuseppe/stats-ignore-no-cgroups
Browse files Browse the repository at this point in the history
stats: ignore errors from containers without cgroups
  • Loading branch information
openshift-merge-bot[bot] authored Nov 28, 2024
2 parents 18191d6 + 6673f5c commit b3c0268
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/system/420-cgroups.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b3c0268

Please sign in to comment.