mirror of
https://github.com/containers/podman.git
synced 2025-09-26 16:25:00 +08:00
Merge pull request #8648 from mheon/fix_7883
Make `podman stats` slirp check more robust
This commit is contained in:
@ -900,10 +900,9 @@ func (r *Runtime) reloadContainerNetwork(ctr *Container) ([]*cnitypes.Result, er
|
|||||||
|
|
||||||
func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) {
|
func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) {
|
||||||
var netStats *netlink.LinkStatistics
|
var netStats *netlink.LinkStatistics
|
||||||
// rootless v2 cannot seem to resolve its network connection to
|
// With slirp4netns, we can't collect statistics at present.
|
||||||
// collect statistics. For now, we allow stats to at least run
|
// For now, we allow stats to at least run by returning nil
|
||||||
// by returning nil
|
if rootless.IsRootless() || ctr.config.NetMode.IsSlirp4netns() {
|
||||||
if rootless.IsRootless() {
|
|
||||||
return netStats, nil
|
return netStats, nil
|
||||||
}
|
}
|
||||||
netNSPath, netPathErr := getContainerNetNS(ctr)
|
netNSPath, netPathErr := getContainerNetNS(ctr)
|
||||||
|
@ -128,6 +128,16 @@ var _ = Describe("Podman stats", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman stats on container with forced slirp4netns", func() {
|
||||||
|
// This will force the slirp4netns net mode to be tested as root
|
||||||
|
session := podmanTest.Podman([]string{"run", "-d", "--net", "slirp4netns", ALPINE, "top"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
session = podmanTest.Podman([]string{"stats", "--no-stream", "-a"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
})
|
||||||
|
|
||||||
// Regression test for #8265
|
// Regression test for #8265
|
||||||
It("podman stats with custom memory limits", func() {
|
It("podman stats with custom memory limits", func() {
|
||||||
// Run thre containers. One with a memory limit. Make sure
|
// Run thre containers. One with a memory limit. Make sure
|
||||||
|
Reference in New Issue
Block a user