Skip to content

Commit

Permalink
Merge pull request #5812 from hashicorp/fix-allocresources-reference
Browse files Browse the repository at this point in the history
Fallback to `alloc.TaskResources` for old allocs
  • Loading branch information
Mahmood Ali committed Jun 11, 2019
2 parents 2213cd5 + 7a01a96 commit f0c9b60
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,15 @@ func (tr *TaskRunner) UpdateStats(ru *cstructs.TaskResourceUsage) {
func (tr *TaskRunner) setGaugeForMemory(ru *cstructs.TaskResourceUsage) {
alloc := tr.Alloc()
var allocatedMem float32
if taskRes := alloc.AllocatedResources.Tasks[tr.taskName]; taskRes != nil {
// Convert to bytes to match other memory metrics
allocatedMem = float32(taskRes.Memory.MemoryMB) * 1024 * 1024
if alloc.AllocatedResources != nil {
if taskRes := alloc.AllocatedResources.Tasks[tr.taskName]; taskRes != nil {
// Convert to bytes to match other memory metrics
allocatedMem = float32(taskRes.Memory.MemoryMB) * 1024 * 1024
}
} else if taskRes := alloc.TaskResources[tr.taskName]; taskRes != nil {
// COMPAT(0.11) Remove in 0.11 when TaskResources is removed
allocatedMem = float32(taskRes.MemoryMB) * 1024 * 1024

}

if !tr.clientConfig.DisableTaggedMetrics {
Expand Down

0 comments on commit f0c9b60

Please sign in to comment.