mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08:13 +08:00
stats: allow to read stats for paused containers
paused containers still a cgroup we can use to grab the stats. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -30,7 +30,7 @@ func (c *Container) GetContainerStats(previousStats *define.ContainerStats) (*de
|
||||
}
|
||||
}
|
||||
|
||||
if c.state.State != define.ContainerStateRunning {
|
||||
if c.state.State != define.ContainerStateRunning && c.state.State != define.ContainerStatePaused {
|
||||
return stats, define.ErrCtrStateInvalid
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ func (c *Container) GetContainerStats(previousStats *define.ContainerStats) (*de
|
||||
stats.MemLimit = getMemLimit(cgroupStats.Memory.Usage.Limit)
|
||||
stats.MemPerc = (float64(stats.MemUsage) / float64(stats.MemLimit)) * 100
|
||||
stats.PIDs = 0
|
||||
if conState == define.ContainerStateRunning {
|
||||
if conState == define.ContainerStateRunning || conState == define.ContainerStatePaused {
|
||||
stats.PIDs = cgroupStats.Pids.Current
|
||||
}
|
||||
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
|
||||
|
@ -79,6 +79,11 @@ var _ = Describe("Podman pause", func() {
|
||||
Expect(result).To(ExitWithError())
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
Expect(strings.ToLower(podmanTest.GetContainerStatus())).To(ContainSubstring(createdState))
|
||||
|
||||
// check we can read stats for a paused container
|
||||
result = podmanTest.Podman([]string{"stats", "--no-stream", cid})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).To(ExitWithError())
|
||||
})
|
||||
|
||||
It("podman pause a running container by id", func() {
|
||||
|
Reference in New Issue
Block a user