Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Add optional memory max to task details ribbon #10459

Merged
merged 7 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/app/models/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fragmentArray } from 'ember-data-model-fragments/attributes';
export default class Resources extends Fragment {
@attr('number') cpu;
@attr('number') memory;
@attr('number') memoryMax;
@attr('number') disk;
@attr('number') iops;
@fragmentArray('network', { defaultValue: () => [] }) networks;
Expand Down
1 change: 1 addition & 0 deletions ui/app/models/task-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class TaskGroup extends Fragment {

@sumAggregation('tasks', 'reservedCPU') reservedCPU;
@sumAggregation('tasks', 'reservedMemory') reservedMemory;
@sumAggregation('tasks', 'reservedMemoryMax') reservedMemoryMax;
@sumAggregation('tasks', 'reservedDisk') reservedDisk;

@attr('number') reservedEphemeralDisk;
Expand Down
1 change: 1 addition & 0 deletions ui/app/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class Task extends Fragment {
}

@attr('number') reservedMemory;
@attr('number') reservedMemoryMax;
@attr('number') reservedCPU;
@attr('number') reservedDisk;
@attr('number') reservedEphemeralDisk;
Expand Down
1 change: 1 addition & 0 deletions ui/app/serializers/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default class Task extends ApplicationSerializer {
const resources = hash.Resources;
if (resources) {
hash.ReservedMemory = resources.MemoryMB;
hash.ReservedMemoryMax = resources.MemoryMaxMB;
hash.ReservedCPU = resources.CPU;
hash.ReservedDisk = resources.DiskMB;
hash.ReservedEphemeralDisk = hash.EphemeralDisk.SizeMB;
Expand Down
8 changes: 7 additions & 1 deletion ui/app/templates/jobs/job/task-group.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@

<span class="pair" data-test-task-group-tasks><span class="term"># Tasks</span> {{this.model.tasks.length}}</span>
<span class="pair" data-test-task-group-cpu><span class="term">Reserved CPU</span> {{format-scheduled-hertz this.model.reservedCPU}}</span>
<span class="pair" data-test-task-group-mem><span class="term">Reserved Memory</span> {{format-scheduled-bytes this.model.reservedMemory start="MiB"}}</span>
<span class="pair" data-test-task-group-mem>
<span class="term">Reserved Memory</span>
{{format-scheduled-bytes this.model.reservedMemory start="MiB"}}
{{#if this.model.reservedMemoryMax}}
({{format-scheduled-bytes this.model.reservedMemoryMax start="MiB"}})
backspace marked this conversation as resolved.
Show resolved Hide resolved
{{/if}}
</span>
<span class="pair" data-test-task-group-disk><span class="term">Reserved Disk</span> {{format-scheduled-bytes this.model.reservedEphemeralDisk start="MiB"}}</span>
{{#if this.model.scaling}}
<span class="pair" data-test-task-group-min><span class="term">Count Range</span>
Expand Down
11 changes: 10 additions & 1 deletion ui/mirage/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const HOSTS = provide(100, () => {
export const STORAGE_PROVIDERS = ['ebs', 'zfs', 'nfs', 'cow', 'moo'];

export function generateResources(options = {}) {
return {
const resources = {
Cpu: {
CpuShares: options.CPU || faker.helpers.randomize(CPU_RESERVATIONS),
},
Expand All @@ -37,6 +37,15 @@ export function generateResources(options = {}) {
Networks: generateNetworks(options.networks),
Ports: generatePorts(options.networks),
};

if (faker.random.boolean()) {
const higherMemoryReservations = MEMORY_RESERVATIONS.filter(mb => mb > resources.Memory.MemoryMB);
resources.Memory.MemoryMaxMB = faker.helpers.randomize(higherMemoryReservations) || resources.Memory.MemoryMB + 1;
} else {
resources.Memory.MemoryMaxMB = 0;
}

return resources;
}

export function generateNetworks(options = {}) {
Expand Down
1 change: 1 addition & 0 deletions ui/mirage/factories/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default Factory.extend({
return {
CPU: resources.Cpu.CpuShares,
MemoryMB: resources.Memory.MemoryMB,
MemoryMaxMB: resources.Memory.MemoryMaxMB,
DiskMB: resources.Disk.DiskMB,
};
},
Expand Down
10 changes: 9 additions & 1 deletion ui/tests/acceptance/task-group-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module('Acceptance | task group detail', function(hooks) {
test('/jobs/:id/:task-group should list high-level metrics for the allocation', async function(assert) {
const totalCPU = tasks.mapBy('resources.CPU').reduce(sum, 0);
const totalMemory = tasks.mapBy('resources.MemoryMB').reduce(sum, 0);
const totalMemoryMax = tasks.mapBy('resources.MemoryMaxMB').reduce(sum, 0);
const totalDisk = taskGroup.ephemeralDisk.SizeMB;

await TaskGroup.visit({ id: job.id, name: taskGroup.name });
Expand All @@ -92,9 +93,16 @@ module('Acceptance | task group detail', function(hooks) {
`Reserved CPU ${formatScheduledHertz(totalCPU, 'MHz')}`,
'Aggregated CPU reservation for all tasks'
);

let totalMemoryMaxAddendum = '';

if (totalMemoryMax) {
totalMemoryMaxAddendum = ` (${formatScheduledBytes(totalMemoryMax, 'MiB')})`;
backspace marked this conversation as resolved.
Show resolved Hide resolved
}

assert.equal(
TaskGroup.mem,
`Reserved Memory ${formatScheduledBytes(totalMemory, 'MiB')}`,
`Reserved Memory ${formatScheduledBytes(totalMemory, 'MiB')}${totalMemoryMaxAddendum}`,
'Aggregated Memory reservation for all tasks'
);
assert.equal(
Expand Down