Expose etcd snapshot params on rke clusters

rancher/rancher#16414
This commit is contained in:
Westly Wright 2018-11-02 14:41:35 -07:00
parent a5540a70e2
commit b4a7b95ef8
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
3 changed files with 98 additions and 2 deletions

View File

@ -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') ) {

View File

@ -280,8 +280,48 @@
</div>
</div>
<div class="row">
<div class="col span-4">
<label class="acc-label">{{t 'clusterNew.rke.etcd.snapshot.label'}}</label>
<div class="radio">
<label>
{{radio-button selection=cluster.rancherKubernetesEngineConfig.services.etcd.snapshot value=false}}
{{t 'generic.disabled'}}
</label>
</div>
<div class="radio">
<label>
{{radio-button selection=cluster.rancherKubernetesEngineConfig.services.etcd.snapshot value=true}}
{{t 'generic.enabled'}}
</label>
</div>
</div>
<div class="col span-2">
<label class="acc-label">{{t 'clusterNew.rke.etcd.creation.label'}}</label>
<div class="input-group">
{{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
}}
</div>
</div>
<div class="col span-2 offset-2">
<label class="acc-label">{{t 'clusterNew.rke.etcd.retention.label'}}</label>
<div class="input-group">
{{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
}}
</div>
</div>
</div>
{{/accordion-list-item}}
{{/advanced-section}}
{{/if}}
{{/accordion-list}}

View File

@ -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