diff --git a/lib/shared/addon/components/cluster-driver/driver-rke/component.js b/lib/shared/addon/components/cluster-driver/driver-rke/component.js index b113ccf23..36f4b2acd 100644 --- a/lib/shared/addon/components/cluster-driver/driver-rke/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-rke/component.js @@ -592,7 +592,8 @@ export default InputTextFile.extend(ClusterDriver, { validate() { this._super(...arguments); - const errors = get(this, 'errors') || []; + + let errors = get(this, 'errors') || []; if ( !get(this, 'isCustom') ) { errors.pushObjects(get(this, 'nodePoolErrors')); @@ -611,6 +612,8 @@ export default InputTextFile.extend(ClusterDriver, { } } + errors = this.validateEtcdService(errors); + const clusterOptErrors = get(this, 'clusterOptErrors') || []; set(this, 'errors', errors); @@ -618,6 +621,48 @@ export default InputTextFile.extend(ClusterDriver, { return errors.length === 0 && clusterOptErrors.length === 0; }, + validateEtcdService(errors) { + const baseUnits = ['s', 'm', 'h', 'd', 'w', 'm', 'y']; + const etcdService = get(this, 'cluster.rancherKubernetesEngineConfig.services.etcd') || {}; + const { creation, retention } = etcdService; + const that = this; + + if (creation) { + hasError(creation, 'Creation'); + } + + if (retention) { + hasError(retention, 'Retention'); + } + + function hasError(entry, type) { + let last = getLast(entry); + + if (typeof parseInt(entry) !== 'number' || typeof last !== 'string') { + errors.push(get(that, 'intl').t('clusterNew.rke.etcd.error', { + type, + entry + })); + } + + if (baseUnits.indexOf(last) === -1) { + errors.push(get(that, 'intl').t('clusterNew.rke.etcd.baseError', { + type, + entry: last + })); + } + } + + function getLast(val) { + let num = parseInt(val); + let numIdx = num.toString().split('').length;// count the "numbers" last index in the string + + return val.slice(numIdx); + } + + return errors; + }, + doneSaving() { if ( get(this, 'isCustom') ) { if ( get(this, 'isEdit') ) { diff --git a/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs b/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs index 09998cbb9..c3ef0b3f3 100644 --- a/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-rke/template.hbs @@ -280,8 +280,48 @@ +
+
+ +
+ +
+
+ +
+
+
+ +
+ {{input + type="text" + classNames="form-control" + disabled=(not cluster.rancherKubernetesEngineConfig.services.etcd.snapshot) + placeholder=(t 'clusterNew.rke.etcd.creation.placeholder') + value=cluster.rancherKubernetesEngineConfig.services.etcd.creation + }} +
+
+
+ +
+ {{input + type="text" + classNames="form-control" + disabled=(not cluster.rancherKubernetesEngineConfig.services.etcd.snapshot) + placeholder=(t 'clusterNew.rke.etcd.retention.placeholder') + value=cluster.rancherKubernetesEngineConfig.services.etcd.retention + }} +
+
+
{{/accordion-list-item}} - {{/advanced-section}} {{/if}} {{/accordion-list}} diff --git a/translations/en-us.yaml b/translations/en-us.yaml index bb91af285..767c8f426 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -50,6 +50,7 @@ generic: healthy: Healthy help: Help hostname: Hostname + hours: hours id: ID image: Image import: Import @@ -2079,6 +2080,16 @@ clusterNew: election: label: etcd Election Timeout placeholder: Time for an election to timeout + snapshot: + label: Recurring etcd Snapshots + retention: + label: Snapshot Retention Period + placeholder: "1d" + creation: + label: Snapshot Creation Period + placeholder: "3h" + error: "Snapshot {type} Period Error: You must designate a time value and SI time unit. You entered {entry}" + baseError: "Snapshot {type} Period Error: You must designate a valid SI time unit. You entered {entry}" nodeName: title: Node Name detail: Optionally configure the node name as identification instead of the actual hostname