Skip to content

Commit

Permalink
Merge pull request #24400 from giuseppe/fix-race-reading-cgroup-stats
Browse files Browse the repository at this point in the history
libpod: report cgroups deleted during Stat() call
  • Loading branch information
openshift-merge-bot[bot] authored Oct 29, 2024
2 parents b52e6cc + 1f44d0f commit 364761f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libpod/stats_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package libpod

import (
"errors"
"fmt"
"strings"
"syscall"
Expand Down Expand Up @@ -36,6 +37,11 @@ func (c *Container) getPlatformContainerStats(stats *define.ContainerStats, prev
// Ubuntu does not have swap memory in cgroups because swap is often not enabled.
cgroupStats, err := cgroup.Stat()
if err != nil {
// cgroup.Stat() is not an atomic operation, so it is possible that the cgroup is removed
// while Stat() is running. Try to catch this case and return a more specific error.
if (errors.Is(err, unix.ENOENT) || errors.Is(err, unix.ENODEV)) && !cgroupExist(cgroupPath) {
return fmt.Errorf("cgroup %s does not exist: %w", cgroupPath, define.ErrCtrStopped)
}
return fmt.Errorf("unable to obtain cgroup stats: %w", err)
}
conState := c.state.State
Expand Down

1 comment on commit 364761f

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.