From 687a25fcad6159d1e513fec04af53844a1d25f9c Mon Sep 17 00:00:00 2001 From: loganhz Date: Thu, 13 Sep 2018 15:04:51 +0800 Subject: [PATCH] Show warning if etcd count is invalid when editing cluster https://github.com/rancher/rancher/issues/15494 --- .../addon/components/cru-node-pools/component.js | 6 +++++- .../addon/components/cru-node-pools/template.hbs | 11 +++++------ translations/en-us.yaml | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/shared/addon/components/cru-node-pools/component.js b/lib/shared/addon/components/cru-node-pools/component.js index e84ccf7fa..ac18e7e6e 100644 --- a/lib/shared/addon/components/cru-node-pools/component.js +++ b/lib/shared/addon/components/cru-node-pools/component.js @@ -149,7 +149,7 @@ export default Component.extend({ const errors = []; - if ( !get(this, 'etcdOk') ) { + if ( get(this, 'mode') === 'new' && !get(this, 'etcdOk') ) { errors.push(intl.t('clusterNew.rke.errors.etcd')); } @@ -201,6 +201,10 @@ export default Component.extend({ return count === 1 || count === 3 || count === 5 }), + etcdCount: computed('nodePools.@each.{quantity,etcd}', function() { + return this._nodeCountFor('etcd'); + }), + controlPlaneOk: computed('nodePools.@each.{quantity,controlPlane}', function() { let count = this._nodeCountFor('controlPlane'); diff --git a/lib/shared/addon/components/cru-node-pools/template.hbs b/lib/shared/addon/components/cru-node-pools/template.hbs index a45963640..5d64b793c 100644 --- a/lib/shared/addon/components/cru-node-pools/template.hbs +++ b/lib/shared/addon/components/cru-node-pools/template.hbs @@ -97,12 +97,11 @@ {{#if showIamWarning}} - + {{banner-message icon='icon-alert' color='bg-warning mb-10' message=(t 'clusterNew.rke.warning.aws.iam')}} + {{/if}} + + {{#if (and (eq mode 'edit') (not etcdOk))}} + {{banner-message icon='icon-alert' color='bg-warning mb-10' message=(if (lt etcdCount 1) (t 'clusterNew.rke.warning.etcd.noEtcd') (t 'clusterNew.rke.warning.etcd.even' count=etcdCount))}} {{/if}} {{/accordion-list-item}} {{/accordion-list}} diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 9740d3279..9dea20356 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -2157,6 +2157,9 @@ clusterNew: domain: Cluster Domain dns: Cluster DNS Server warning: + etcd: + even: Setting {count} etcd nodes is a waste of hardware because it doesn't increase the quorum until you have an odd number. + noEtcd: The number of etcd nodes should not be less than 1. aws: iam: 'An IAM role name should be provided in node template when using the Cloud Provider Amazon' errors: