Skip to content

Commit 52629ac

Browse files
api: fix allocation stats to exclude non running tasks from usage (#27317)
1 parent e6b7a57 commit 52629ac

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changelog/27317.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
api: only include running tasks in allocation resource usage
3+
```

client/allocrunner/alloc_runner.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,9 +1314,11 @@ func (ar *allocRunner) LatestAllocStats(taskFilter string) (*cstructs.AllocResou
13141314

13151315
if usage := tr.LatestResourceUsage(); usage != nil {
13161316
astat.Tasks[name] = usage
1317-
astat.ResourceUsage.Add(usage.ResourceUsage)
1318-
if usage.Timestamp > astat.Timestamp {
1319-
astat.Timestamp = usage.Timestamp
1317+
if tr.IsRunning() {
1318+
astat.ResourceUsage.Add(usage.ResourceUsage)
1319+
if usage.Timestamp > astat.Timestamp {
1320+
astat.Timestamp = usage.Timestamp
1321+
}
13201322
}
13211323
}
13221324
}

0 commit comments

Comments
 (0)