mirror of
https://github.com/containers/podman.git
synced 2025-07-02 16:57:24 +08:00
libpod: Factor out jail name construction from stats_freebsd.go
[NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
@ -279,3 +279,11 @@ func (c *Container) getConmonPidFd() int {
|
|||||||
// keeping things simple for now.
|
// keeping things simple for now.
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Container) jailName() string {
|
||||||
|
if c.state.NetNS != nil {
|
||||||
|
return c.state.NetNS.Name + "." + c.ID()
|
||||||
|
} else {
|
||||||
|
return c.ID()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,13 +20,9 @@ import (
|
|||||||
func (c *Container) getPlatformContainerStats(stats *define.ContainerStats, previousStats *define.ContainerStats) error {
|
func (c *Container) getPlatformContainerStats(stats *define.ContainerStats, previousStats *define.ContainerStats) error {
|
||||||
now := uint64(time.Now().UnixNano())
|
now := uint64(time.Now().UnixNano())
|
||||||
|
|
||||||
jailName := c.ID()
|
entries, err := rctl.GetRacct("jail:" + c.jailName())
|
||||||
if c.state.NetNS != nil {
|
|
||||||
jailName = c.state.NetNS.Name + "." + jailName
|
|
||||||
}
|
|
||||||
entries, err := rctl.GetRacct("jail:" + jailName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to read accounting for %s: %w", jailName, err)
|
return fmt.Errorf("unable to read accounting for %s: %w", c.jailName(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current total usage is less than what was previously
|
// If the current total usage is less than what was previously
|
||||||
|
Reference in New Issue
Block a user