Show the scheduler dry-run output on the plan page

This commit is contained in:
Michael Lange
2018-08-17 11:22:26 -07:00
parent 1c94fdb175
commit 9b7b465a66
8 changed files with 56 additions and 7 deletions

View File

@@ -77,6 +77,9 @@ export default Watchable.extend({
Job: job.get('_newDefinitionJSON'),
Diff: true,
},
}).then(json => {
json.ID = job.get('id');
this.get('store').pushPayload('job-plan', { jobPlans: [json] });
});
},

View File

@@ -0,0 +1,10 @@
import Component from '@ember/component';
import { or } from '@ember/object/computed';
export default Component.extend({
// Either provide a taskGroup or a failedTGAlloc
taskGroup: null,
failedTGAlloc: null,
placementFailures: or('taskGroup.placementFailures', 'failedTGAlloc'),
});

View File

@@ -1,10 +1,13 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { task } from 'ember-concurrency';
import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error';
import localStorageProperty from 'nomad-ui/utils/properties/local-storage';
export default Controller.extend({
store: service(),
parseError: null,
planError: null,
runError: null,
@@ -30,8 +33,9 @@ export default Controller.extend({
}
try {
const planOutput = yield this.get('model').plan();
this.set('planOutput', planOutput.Diff);
yield this.get('model').plan();
const plan = this.get('store').peekRecord('job-plan', this.get('model.id'));
this.set('planOutput', plan);
} catch (err) {
const error = messageFromAdapterError(err) || 'Could not plan job';
this.set('planError', error);

View File

@@ -0,0 +1,8 @@
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
export default Model.extend({
diff: attr(),
failedTGAllocs: fragmentArray('placement-failure', { defaultValue: () => [] }),
});

View File

@@ -0,0 +1,12 @@
import { get } from '@ember/object';
import { assign } from '@ember/polyfills';
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
normalize(typeHash, hash) {
hash.FailedTGAllocs = Object.keys(hash.FailedTGAllocs || {}).map(key => {
return assign({ Name: key }, get(hash, `FailedTGAllocs.${key}`) || {});
});
return this._super(...arguments);
},
});

View File

@@ -1,7 +1,7 @@
{{#if taskGroup.placementFailures}}
{{#with taskGroup.placementFailures as |failures|}}
{{#if placementFailures}}
{{#with placementFailures as |failures|}}
<h3 class="title is-5" data-test-placement-failure-task-group>
{{taskGroup.name}}
{{placementFailures.name}}
<span class="badge is-light" data-test-placement-failure-coalesced-failures>{{inc failures.coalescedFailures}} unplaced</span>
</h3>
<ul class="simple-list">
@@ -37,4 +37,3 @@
</ul>
{{/with}}
{{/if}}

View File

@@ -71,7 +71,19 @@
<div class="boxed-section">
<div class="boxed-section-head">Job Plan</div>
<div class="boxed-section-body is-dark">
{{job-diff data-test-plan-output diff=planOutput verbose=false}}
{{job-diff data-test-plan-output diff=planOutput.diff verbose=false}}
</div>
</div>
<div class="boxed-section {{if planOutput.failedTGAllocs "is-warning" "is-primary"}}">
<div class="boxed-section-head">Scheduler dry-run</div>
<div class="boxed-section-body">
{{#if planOutput.failedTGAllocs}}
{{#each planOutput.failedTGAllocs as |placementFailure|}}
{{placement-failure failedTGAlloc=placementFailure}}
{{/each}}
{{else}}
All tasks successfully allocated.
{{/if}}
</div>
</div>
<div class="content is-associative">

View File

@@ -108,6 +108,7 @@ function createFixture(obj = {}, name = 'Placement Failure') {
name: name,
placementFailures: assign(
{
name: name,
coalescedFailures: 10,
nodesEvaluated: 0,
nodesAvailable: {