Merge pull request #13670 from hashicorp/ui-memory-cgroupsv2

ui: fix zero memory utilization bug on systems using cgroups v2
This commit is contained in:
Seth Hoenig
2022-08-03 13:18:57 -05:00
committed by GitHub
3 changed files with 17 additions and 3 deletions

3
.changelog/13670.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed a bug where task memory was reported as zero on systems using cgroups v2
```

View File

@@ -49,7 +49,11 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percent: percent(cpuUsed, this.reservedCPU),
});
const memoryUsed = frame.ResourceUsage.MemoryStats.RSS;
const memoryUsed =
frame.ResourceUsage.MemoryStats.Usage ||
frame.ResourceUsage.MemoryStats.RSS ||
0;
this.memory.pushObject({
timestamp,
used: memoryUsed,
@@ -80,7 +84,11 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percentStack: percentCpuTotal + aggregateCpu,
});
const taskMemoryUsed = taskFrame.ResourceUsage.MemoryStats.RSS;
const taskMemoryUsed =
taskFrame.ResourceUsage.MemoryStats.Usage ||
taskFrame.ResourceUsage.MemoryStats.RSS ||
0;
const percentMemoryTotal = percent(
taskMemoryUsed / 1024 / 1024,
this.reservedMemory

View File

@@ -54,6 +54,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 400) * 1024 * 1024,
Usage: (step + 400) * 1024 * 1024,
},
},
Tasks: {
@@ -64,6 +65,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 100) * 1024 * 1024,
Usage: (step + 100) * 1024 * 1024,
},
},
Timestamp: refDate + step,
@@ -75,6 +77,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 50) * 1024 * 1024,
Usage: (step + 50) * 1024 * 1024,
},
},
Timestamp: refDate + step * 10,
@@ -86,6 +89,7 @@ module('Unit | Util | AllocationStatsTracker', function () {
},
MemoryStats: {
RSS: (step + 51) * 1024 * 1024,
Usage: (step + 51) * 1024 * 1024,
},
},
Timestamp: refDate + step * 100,
@@ -251,7 +255,6 @@ module('Unit | Util | AllocationStatsTracker', function () {
],
'One frame of memory'
);
assert.deepEqual(
tracker.get('tasks'),
[