Skip to content

Commit

Permalink
libpod: Factor out jail name construction from stats_freebsd.go
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <[email protected]>
  • Loading branch information
dfr authored and mheon committed Oct 18, 2022
1 parent e333066 commit f8a7940
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions libpod/container_internal_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,11 @@ func (c *Container) getConmonPidFd() int {
// keeping things simple for now.
return -1
}

func (c *Container) jailName() string {
if c.state.NetNS != nil {
return c.state.NetNS.Name + "." + c.ID()
} else {
return c.ID()
}
}
8 changes: 2 additions & 6 deletions libpod/stats_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ import (
func (c *Container) getPlatformContainerStats(stats *define.ContainerStats, previousStats *define.ContainerStats) error {
now := uint64(time.Now().UnixNano())

jailName := c.ID()
if c.state.NetNS != nil {
jailName = c.state.NetNS.Name + "." + jailName
}
entries, err := rctl.GetRacct("jail:" + jailName)
entries, err := rctl.GetRacct("jail:" + c.jailName())
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
Expand Down

0 comments on commit f8a7940

Please sign in to comment.