mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Drain stop and update and notifications
This commit is contained in:
@@ -49,6 +49,7 @@ export default Component.extend({
|
||||
|
||||
drain: task(function*(close) {
|
||||
if (!this.client) return;
|
||||
const isUpdating = this.client.isDraining;
|
||||
|
||||
let deadline;
|
||||
try {
|
||||
@@ -71,7 +72,7 @@ export default Component.extend({
|
||||
} else {
|
||||
yield this.client.drain(spec);
|
||||
}
|
||||
this.onDrain();
|
||||
this.onDrain(isUpdating);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,10 @@ export default Controller.extend(Sortable, Searchable, {
|
||||
sortedAllocations: alias('listSearched'),
|
||||
|
||||
eligibilityError: null,
|
||||
stopDrainError: null,
|
||||
showDrainNotification: false,
|
||||
showDrainUpdateNotification: false,
|
||||
showDrainStoppedNotification: false,
|
||||
|
||||
preemptions: computed('model.allocations.@each.wasPreempted', function() {
|
||||
return this.model.allocations.filterBy('wasPreempted');
|
||||
@@ -67,6 +70,18 @@ export default Controller.extend(Sortable, Searchable, {
|
||||
}
|
||||
}).drop(),
|
||||
|
||||
stopDrain: task(function*() {
|
||||
try {
|
||||
this.set('flagAsDraining', false);
|
||||
yield this.model.cancelDrain();
|
||||
this.set('showDrainStoppedNotification', true);
|
||||
} catch (err) {
|
||||
this.set('flagAsDraining', true);
|
||||
const error = messageFromAdapterError(err) || 'Could not stop drain';
|
||||
this.set('stopDrainError', error);
|
||||
}
|
||||
}).drop(),
|
||||
|
||||
triggerDrainNotification: observer('model.isDraining', function() {
|
||||
if (!this.model.isDraining && this.flagAsDraining) {
|
||||
this.set('showDrainNotification', true);
|
||||
@@ -83,5 +98,9 @@ export default Controller.extend(Sortable, Searchable, {
|
||||
setPreemptionFilter(value) {
|
||||
this.set('onlyPreemptions', value);
|
||||
},
|
||||
|
||||
drainNotify(isUpdating) {
|
||||
this.set('showDrainUpdateNotification', isUpdating);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -112,4 +112,8 @@ export default Model.extend({
|
||||
forceDrain(drainSpec) {
|
||||
return this.store.adapterFor('node').forceDrain(this, drainSpec);
|
||||
},
|
||||
|
||||
cancelDrain() {
|
||||
return this.store.adapterFor('node').cancelDrain(this);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -35,6 +35,13 @@ export default Route.extend(WithWatchers, {
|
||||
return this._super(...arguments);
|
||||
},
|
||||
|
||||
resetController(controller) {
|
||||
controller.setProperties({
|
||||
eligibilityError: null,
|
||||
stopDrainError: null,
|
||||
});
|
||||
},
|
||||
|
||||
startWatchers(controller, model) {
|
||||
if (model) {
|
||||
controller.set('watchModel', this.watch.perform(model));
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
.section {
|
||||
padding: 1.5rem;
|
||||
max-width: 1200px;
|
||||
|
||||
&.with-headspace {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.full-width-section {
|
||||
|
||||
@@ -1,9 +1,55 @@
|
||||
{{title "Client " (or model.name model.shortId)}}
|
||||
<section class="section">
|
||||
<section class="section with-headspace">
|
||||
{{#if eligibilityError}}
|
||||
<div data-test-eiligibility-error class="notification is-danger">
|
||||
<h3 class="title is-4" data-test-eiligibility-error-title>Eligibility Error</h3>
|
||||
<p data-test-eligibility-error-message>{{eligibilityError}}</p>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div data-test-eligibility-error class="notification is-danger">
|
||||
<h3 class="title is-4" data-test-eligibility-error-title>Eligibility Error</h3>
|
||||
<p data-test-eligibility-error-message>{{eligibilityError}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-centered is-minimum">
|
||||
<button data-test-eligibility-error-dismiss class="button is-danger" onclick={{action (mut eligibilityError) ""}}>Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if stopDrainError}}
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div data-test-stop-drain-error class="notification is-danger">
|
||||
<h3 class="title is-4" data-test-stop-drain-error-title>Stop Drain Error</h3>
|
||||
<p data-test-stop-drain-error-message>{{stopDrainError}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-centered is-minimum">
|
||||
<button data-test-stop-drain-error-dismiss class="button is-danger" onclick={{action (mut eligibilityError) ""}}>Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if showDrainStoppedNotification}}
|
||||
<div class="notification is-info">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<h3 class="title is-4">Drain Stopped</h3>
|
||||
<p>The drain has been stopped and the node has been set to ineligible.</p>
|
||||
</div>
|
||||
<div class="column is-centered is-minimum">
|
||||
<button class="button is-info" onclick={{action (mut showDrainStoppedNotification) false}}>Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if showDrainUpdateNotification}}
|
||||
<div class="notification is-info">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<h3 class="title is-4">Drain Updated</h3>
|
||||
<p>The new drain specification has been applied.</p>
|
||||
</div>
|
||||
<div class="column is-centered is-minimum">
|
||||
<button class="button is-info" onclick={{action (mut showDrainUpdateNotification) false}}>Okay</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if showDrainNotification}}
|
||||
@@ -48,7 +94,18 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="toolbar-item is-right-aligned is-top-aligned">
|
||||
{{drain-popover client=model}}
|
||||
{{#if model.isDraining}}
|
||||
{{two-step-button
|
||||
idleText="Stop Drain"
|
||||
cancelText="Cancel"
|
||||
confirmText="Yes, Stop"
|
||||
confirmationMessage="Are you sure you want to stop this drain?"
|
||||
awaitingConfirmation=stopDrain.isRunning
|
||||
onConfirm=(perform stopDrain)}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="toolbar-item is-right-aligned is-top-aligned">
|
||||
{{drain-popover client=model onDrain=(action "drainNotify")}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#popover-menu
|
||||
label=(if client.isDraining "Update" "Drain")
|
||||
triggerClass=(if drain.isRunning "is-loading") as |m|}}
|
||||
triggerClass=(concat "is-small " (if drain.isRunning "is-loading")) as |m|}}
|
||||
<form onsubmit={{action (queue (action preventDefault) (perform drain m.actions.close))}} class="form is-small">
|
||||
<h4 class="group-heading">Drain Options</h4>
|
||||
<div class="field">
|
||||
|
||||
Reference in New Issue
Block a user