-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2358 from vincent99/master
Drain should be bulkable and make more sense
- Loading branch information
Showing
5 changed files
with
118 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,48 @@ | ||
import { inject as service } from '@ember/service'; | ||
import { get, set } from '@ember/object'; | ||
import { get } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import Component from '@ember/component'; | ||
import ModalBase from 'shared/mixins/modal-base'; | ||
import layout from './template'; | ||
import { eachLimit } from 'async'; | ||
|
||
export default Component.extend(ModalBase, { | ||
growl: service(), | ||
|
||
layout, | ||
classNames: ['large-modal'], | ||
|
||
model: alias('modalService.modalOpts.originalModel'), | ||
aggressive: false, | ||
usePodGracePeriod: true, | ||
gracePeriod: 30, | ||
unlimitedTimeout: false, | ||
timeout: 60, | ||
|
||
didReceiveAttrs() { | ||
const options = { | ||
force: false, | ||
ignoreDaemonSets: true, | ||
deleteLocalData: false, | ||
gracePeriod: -1, | ||
timeout: 60, | ||
}; | ||
|
||
set(this, 'options', options); | ||
}, | ||
resources: alias('modalService.modalOpts.resources'), | ||
|
||
actions: { | ||
save(cb) { | ||
get(this, 'model').doAction('drain', get(this, 'options')) | ||
.then(() => { | ||
this.send('cancel'); | ||
}) | ||
.finally(() => { | ||
cb(); | ||
}); | ||
drain() { | ||
const aggressive = get(this, 'aggressive'); | ||
|
||
const opts = { | ||
deleteLocalData: aggressive, | ||
force: aggressive, | ||
ignoreDaemonSets: true, | ||
gracePeriod: get(this, 'usePodGracePeriod') ? -1 : get(this, 'gracePeriod'), | ||
timeout: get(this, 'unlimitedTimeout') ? 0 : get(this, 'timeout'), | ||
}; | ||
|
||
const resources = get(this, 'resources').slice(); | ||
|
||
eachLimit(resources, 5, (resource, cb) => { | ||
if ( !resource ) { | ||
return cb(); | ||
} | ||
|
||
resource.doAction('drain', opts).finally(cb); | ||
}); | ||
|
||
this.send('cancel'); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,73 @@ | ||
<h2> | ||
{{t 'modalDrainNode.title' nodeName=model.displayName}} | ||
</h2> | ||
<div class="container-header-text"> | ||
<h3> | ||
{{#if (eq resources.length 1)}} | ||
{{t 'modalDrainNode.titleOne' name=resources.firstObject.displayName}} | ||
{{else}} | ||
{{t 'modalDrainNode.titleMultiple' count=resources.length}} | ||
{{/if}} | ||
</h3> | ||
<hr/> | ||
</div> | ||
|
||
<section class="p-20"> | ||
<label class="acc-label">{{t 'modalDrainNode.drain'}}</label> | ||
<section class="p-20 pt-0"> | ||
<div class="row"> | ||
<div class="col span-12"> | ||
<div class="checkbox" style="position: absolute"> | ||
<label> | ||
{{input type="checkbox" classNames="form-control" checked=options.force}} | ||
{{t 'modalDrainNode.force.helpText'}} | ||
<div class="col span-11-of-23"> | ||
<label class="acc-label">{{t 'modalDrainNode.mode'}}</label> | ||
<div> | ||
<label class="radio mt-0"> | ||
{{radio-button selection=aggressive value=false}} | ||
{{t 'modalDrainNode.safe.label'}} | ||
<p class="help-block">{{t 'modalDrainNode.safe.helpText'}}</p> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-5"> | ||
<div class="col span-12"> | ||
<div class="checkbox" style="position: absolute"> | ||
<label> | ||
{{input type="checkbox" classNames="form-control" checked=options.ignoreDaemonSets}} | ||
{{t 'modalDrainNode.ignoreDaemonSets.helpText'}} | ||
<div> | ||
<label class="radio text-error"> | ||
{{radio-button selection=aggressive value=true}} | ||
{{t 'modalDrainNode.aggressive.label'}} | ||
<p class="help-block text-error">{{t 'modalDrainNode.aggressive.helpText' htmlSafe=true}}</p> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-5"> | ||
<div class="col span-12"> | ||
<div class="checkbox" style="position: absolute"> | ||
<label> | ||
{{input type="checkbox" classNames="form-control" checked=options.deleteLocalData}} | ||
{{t 'modalDrainNode.deleteLocalData.helpText'}} | ||
<div class="col span-11-of-23 offset-1-of-23"> | ||
<label class="acc-label">{{t 'modalDrainNode.gracePeriod.title'}}</label> | ||
<div> | ||
<label class="radio mt-0"> | ||
{{radio-button selection=usePodGracePeriod value=true}} | ||
{{t 'modalDrainNode.gracePeriod.default'}} | ||
</label> | ||
</div> | ||
<div> | ||
<label class="radio"> | ||
{{radio-button selection=usePodGracePeriod value=false}} | ||
{{t 'modalDrainNode.gracePeriod.custom'}} | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-20"> | ||
<div class="col span-6"> | ||
<label class="acc-label">{{t 'modalDrainNode.gracePeriod.label'}}</label> | ||
<div class="input-group"> | ||
{{input-integer value=options.gracePeriod classNames="form-control" placeholder=(t 'modalDrainNode.gracePeriod.placeholder')}} | ||
{{input-integer value=gracePeriod disabled=usePodGracePeriod min=1 classNames="form-control" placeholder=(t 'modalDrainNode.gracePeriod.placeholder')}} | ||
<span class="input-group-addon bg-default">{{t 'generic.seconds'}}</span> | ||
</div> | ||
<p class="help-block">{{t 'modalDrainNode.gracePeriod.helpText'}}</p> | ||
</div> | ||
|
||
<div class="col span-6"> | ||
<label class="acc-label">{{t 'modalDrainNode.timeout.label'}}</label> | ||
|
||
<label class="acc-label mt-10">{{t 'modalDrainNode.timeout.title'}}</label> | ||
<div> | ||
<label class="radio mt-0"> | ||
{{radio-button selection=unlimitedTimeout value=true}} | ||
{{t 'modalDrainNode.timeout.default'}} | ||
</label> | ||
</div> | ||
<div> | ||
<label class="radio"> | ||
{{radio-button selection=unlimitedTimeout value=false}} | ||
{{t 'modalDrainNode.timeout.custom'}} | ||
</label> | ||
</div> | ||
<div class="input-group"> | ||
{{input-integer min=1 max=10800 value=options.timeout classNames="form-control" placeholder=(t 'modalDrainNode.timeout.placeholder')}} | ||
{{input-integer min=1 max=10800 disabled=unlimitedTimeout value=timeout classNames="form-control" placeholder=(t 'modalDrainNode.timeout.placeholder')}} | ||
<span class="input-group-addon bg-default">{{t 'generic.seconds'}}</span> | ||
</div> | ||
<p class="help-block">{{t 'modalDrainNode.timeout.helpText'}}</p> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
{{#unless options.ignoreDaemonSets}} | ||
{{banner-message color='bg-info' message=(t 'modalDrainNode.ignoreDaemonSets.warning')}} | ||
{{/unless}} | ||
|
||
{{save-cancel editing=true editLabel="modalDrainNode.action" save="save" cancel="cancel"}} | ||
{{save-cancel editing=true editLabel="modalDrainNode.action" save="drain" cancel="cancel"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters