Merge pull request #6470 from mheon/fix_stats_nonet

Properly follow linked namespace container for stats
This commit is contained in:
OpenShift Merge Robot 2020-06-04 14:46:49 +02:00 committed by GitHub
commit 8cf74a79e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -550,7 +550,7 @@ func getContainerNetNS(ctr *Container) (string, error) {
if err = c.syncContainer(); err != nil { if err = c.syncContainer(); err != nil {
return "", err return "", err
} }
return c.state.NetNS.Path(), nil return getContainerNetNS(c)
} }
return "", nil return "", nil
} }

View File

@ -178,4 +178,21 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats).To(ExitWithError()) Expect(stats).To(ExitWithError())
}) })
It("podman stats on net=host post", func() {
// --net=host not supported for rootless pods at present
SkipIfRootless()
podName := "testPod"
podCreate := podmanTest.Podman([]string{"pod", "create", "--net=host", "--name", podName})
podCreate.WaitWithDefaultTimeout()
Expect(podCreate.ExitCode()).To(Equal(0))
ctrRun := podmanTest.Podman([]string{"run", "-d", "--pod", podName, ALPINE, "top"})
ctrRun.WaitWithDefaultTimeout()
Expect(ctrRun.ExitCode()).To(Equal(0))
stats := podmanTest.Podman([]string{"pod", "stats", "--format", "json", "--no-stream", podName})
stats.WaitWithDefaultTimeout()
Expect(stats.ExitCode()).To(Equal(0))
Expect(stats.IsJSONOutputValid()).To(BeTrue())
})
}) })