diff --git a/.changelog/13670.txt b/.changelog/13670.txt new file mode 100644 index 000000000000..04e3541e3dd7 --- /dev/null +++ b/.changelog/13670.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixed a bug where task memory was reported as zero on systems using cgroups v2 +``` diff --git a/ui/app/utils/classes/allocation-stats-tracker.js b/ui/app/utils/classes/allocation-stats-tracker.js index 092357d18542..869eed0009a1 100644 --- a/ui/app/utils/classes/allocation-stats-tracker.js +++ b/ui/app/utils/classes/allocation-stats-tracker.js @@ -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 diff --git a/ui/tests/unit/utils/allocation-stats-tracker-test.js b/ui/tests/unit/utils/allocation-stats-tracker-test.js index 3c319f0ff25c..e4f373108154 100644 --- a/ui/tests/unit/utils/allocation-stats-tracker-test.js +++ b/ui/tests/unit/utils/allocation-stats-tracker-test.js @@ -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'), [