Prevent creation of clusters with node p

This commit is contained in:
Neil MacDougall 2022-05-10 12:09:37 +01:00
parent 21bbd7e1c7
commit 62b1f6caa0
3 changed files with 32 additions and 0 deletions

View File

@ -214,6 +214,10 @@ export default Component.extend({
}
}
if (this.uniqueHostNameError) {
errors.push(intl.t('clusterNew.nodePools.errors.hostnamePrefix'));
}
get(this, 'nodePools').forEach((pool) => {
// ClusterId is required but not known yet
if ( !get(pool, 'clusterId') ) {
@ -262,6 +266,25 @@ export default Component.extend({
return templates;
}),
uniqueHostNameError: computed('nodePools.@each.hostnamePrefix', function() {
// Host name prefixes must be unique
const nodePools = get(this, 'nodePools');
const names = {};
let isError = false;
nodePools.map((p) => {
const { hostnamePrefix = '' } = p;
if (names[hostnamePrefix]) {
isError = true;
} else {
names[hostnamePrefix] = true;
}
});
return isError;
}),
etcdOk: computed('nodePools.@each.{quantity,etcd}', function() {
let count = this._nodeCountFor('etcd');

View File

@ -53,6 +53,12 @@
<p class="help-block">{{t "clusterNew.rke.helptext"}}</p>
{{/if}}
{{#if uniqueHostNameError}}
{{#banner-message icon="icon-alert" color="bg-error"}}
<p>{{t "clusterNew.nodePools.errors.hostnamePrefix" }}</p>
{{/banner-message}}
{{/if}}
<div class="mt-20">
<button class="btn bg-primary icon-btn" type="button" {{action "addPool" }}>
<i class="icon icon-plus text-small" />

View File

@ -4318,6 +4318,9 @@ clusterNew:
label: Cluster Name
placeholder: e.g. sandbox
required: '"Cluster Name" is required'
nodePools:
errors:
hostnamePrefix: Node pools must have unique name prefixes
nodes:
detail: Customize the nodes that will be created
title: Node Options