mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Show the scheduler dry-run output on the plan page
This commit is contained in:
@@ -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] });
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
10
ui/app/components/placement-failure.js
Normal file
10
ui/app/components/placement-failure.js
Normal 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'),
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
8
ui/app/models/job-plan.js
Normal file
8
ui/app/models/job-plan.js
Normal 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: () => [] }),
|
||||
});
|
||||
12
ui/app/serializers/job-plan.js
Normal file
12
ui/app/serializers/job-plan.js
Normal 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);
|
||||
},
|
||||
});
|
||||
@@ -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}}
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -108,6 +108,7 @@ function createFixture(obj = {}, name = 'Placement Failure') {
|
||||
name: name,
|
||||
placementFailures: assign(
|
||||
{
|
||||
name: name,
|
||||
coalescedFailures: 10,
|
||||
nodesEvaluated: 0,
|
||||
nodesAvailable: {
|
||||
|
||||
Reference in New Issue
Block a user