Skip to content

Commit

Permalink
Merge pull request #6470 from mheon/fix_stats_nonet
Browse files Browse the repository at this point in the history
Properly follow linked namespace container for stats
  • Loading branch information
openshift-merge-robot authored Jun 4, 2020
2 parents 9d13872 + 42505f6 commit 8cf74a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func getContainerNetNS(ctr *Container) (string, error) {
if err = c.syncContainer(); err != nil {
return "", err
}
return c.state.NetNS.Path(), nil
return getContainerNetNS(c)
}
return "", nil
}
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/pod_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,21 @@ var _ = Describe("Podman pod stats", func() {
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())
})
})

0 comments on commit 8cf74a7

Please sign in to comment.