open-nomad/ui/app/models/task-group.js
Michael Lange 1bd6a69067
UI: Support for CSI (#7446)
Closes #7197 #7199

Note: Test coverage is limited to adapter and serializer unit tests. All
acceptance tests have been stubbed and all features have been manually
tested end-to-end.

This represents Phase 1 of #6993 which is the core workflow of CSI in
the UI. It includes a couple new pages for viewing all external volumes
as well as the allocations associated with each. It also updates
existing volume related views on job and allocation pages to handle both
Host Volumes and CSI Volumes.
2020-03-25 07:51:26 -05:00

48 lines
1.6 KiB
JavaScript

import { computed } from '@ember/object';
import Fragment from 'ember-data-model-fragments/fragment';
import attr from 'ember-data/attr';
import { fragmentOwner, fragmentArray } from 'ember-data-model-fragments/attributes';
import sumAggregation from '../utils/properties/sum-aggregation';
const maybe = arr => arr || [];
export default Fragment.extend({
job: fragmentOwner(),
name: attr('string'),
count: attr('number'),
tasks: fragmentArray('task'),
services: fragmentArray('service'),
volumes: fragmentArray('volume-definition'),
drivers: computed('tasks.@each.driver', function() {
return this.tasks.mapBy('driver').uniq();
}),
allocations: computed('job.allocations.@each.taskGroup', function() {
return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.name);
}),
reservedCPU: sumAggregation('tasks', 'reservedCPU'),
reservedMemory: sumAggregation('tasks', 'reservedMemory'),
reservedDisk: sumAggregation('tasks', 'reservedDisk'),
reservedEphemeralDisk: attr('number'),
placementFailures: computed('job.latestFailureEvaluation.failedTGAllocs.[]', function() {
const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs');
return placementFailures && placementFailures.findBy('name', this.name);
}),
queuedOrStartingAllocs: computed('summary.{queuedAllocs,startingAllocs}', function() {
return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs');
}),
summary: computed('job.taskGroupSummaries.[]', function() {
return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.name);
}),
});