Skip to content

Commit

Permalink
reuse existing function and typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Apr 2, 2021
1 parent f14921d commit 13a9e4b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
3 changes: 2 additions & 1 deletion command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/posener/complete"
)
Expand Down Expand Up @@ -589,7 +590,7 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str
// Nomad uses RSS as the top-level metric to report, for historical reasons,
// but it's not always measured (e.g. with cgroup-v2)
usage := ms.RSS
if usage == 0 && !stringsContain(ms.Measured, "RSS") {
if usage == 0 && !helper.SliceStringContains(ms.Measured, "RSS") {
usage = ms.Usage
}
memUsage = fmt.Sprintf("%v/%v", humanize.IBytes(usage), memUsage)
Expand Down
11 changes: 0 additions & 11 deletions command/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,3 @@ func (w *uiErrorWriter) Close() error {
}
return nil
}

// stringsContains returns true if s is present in the vs string slice
func stringsContain(vs []string, s string) bool {
for _, v := range vs {
if v == s {
return true
}
}

return false
}
2 changes: 1 addition & 1 deletion drivers/docker/util/stats_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
func DockerStatsToTaskResourceUsage(s *docker.Stats) *cstructs.TaskResourceUsage {
measuredMems := DockerCgroupV1MeasuredMemStats

// use a simple heauristic to check if cgroup-v2 is used.
// use a simple heuristic to check if cgroup-v2 is used.
// go-dockerclient doesn't distinguish between 0 and not-present value
if s.MemoryStats.Stats.Rss == 0 && s.MemoryStats.MaxUsage == 0 && s.MemoryStats.Usage != 0 {
measuredMems = DockerCgroupV2MeasuredMemStats
Expand Down

0 comments on commit 13a9e4b

Please sign in to comment.