From e7c8d8f9007d4347724e068ae88ef6ef981e8250 Mon Sep 17 00:00:00 2001 From: loganhz Date: Fri, 30 Aug 2019 17:35:41 +0800 Subject: [PATCH 1/5] Hide k8s role taints --- lib/shared/addon/mixins/cattle-transitioning-resource.js | 8 +++++--- lib/shared/addon/utils/constants.js | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/shared/addon/mixins/cattle-transitioning-resource.js b/lib/shared/addon/mixins/cattle-transitioning-resource.js index 37e92e3b3..faeb131b9 100644 --- a/lib/shared/addon/mixins/cattle-transitioning-resource.js +++ b/lib/shared/addon/mixins/cattle-transitioning-resource.js @@ -719,9 +719,11 @@ export default Mixin.create({ const out = []; const taints = get(this, 'nodeTaints') || get(this, 'taints') || []; - taints.forEach((taint) => { - out.push(`${ get(taint, 'key') }${ get(taint, 'value') ? `=${ get(taint, 'value') }` : '' }:${ get(taint, 'effect') }`); - }); + taints + .filter((taint) => !C.TAINT_PREFIX_TO_IGNORE.find((L) => taint.key.startsWith(L))) + .forEach((taint) => { + out.push(`${ get(taint, 'key') }${ get(taint, 'value') ? `=${ get(taint, 'value') }` : '' }:${ get(taint, 'effect') }`); + }); return out; }), diff --git a/lib/shared/addon/utils/constants.js b/lib/shared/addon/utils/constants.js index c3451f9d6..8ab4699d0 100644 --- a/lib/shared/addon/utils/constants.js +++ b/lib/shared/addon/utils/constants.js @@ -560,6 +560,10 @@ C.LABELS_TO_IGNORE = [ C.LABEL_ISTIO_RULE = 'io.rancher.istio'; +C.TAINT_PREFIX_TO_IGNORE = [ + 'node-role.kubernetes.io/', +]; + C.LABEL_PREFIX_TO_IGNORE = [ 'io.cattle.lifecycle.', 'beta.kubernetes.io/', From bae8f1cca8b2a01bcd2faea7f07ac1660cf0428d Mon Sep 17 00:00:00 2001 From: loganhz Date: Fri, 30 Aug 2019 17:45:57 +0800 Subject: [PATCH 2/5] Make k8s taints readonly --- lib/shared/addon/components/node-taints/component.js | 8 +++++--- lib/shared/addon/components/node-taints/template.hbs | 4 ++++ lib/shared/addon/utils/constants.js | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/shared/addon/components/node-taints/component.js b/lib/shared/addon/components/node-taints/component.js index 4657820dd..cf0ce7a39 100644 --- a/lib/shared/addon/components/node-taints/component.js +++ b/lib/shared/addon/components/node-taints/component.js @@ -2,6 +2,7 @@ import { get, set, observer } from '@ember/object'; import Component from '@ember/component'; import layout from './template'; import EmberObject from '@ember/object'; +import C from 'ui/utils/constants'; const NO_SCHEDULE = 'NoSchedule'; const NO_EXECUTE = 'NoExecute'; @@ -82,9 +83,10 @@ export default Component.extend({ initTaints() { set(this, 'taints', (get(this, 'model.nodeTaints') || get(this, 'model.taints') || []).map((taint) => { return { - key: get(taint, 'key'), - value: get(taint, 'value'), - effect: get(taint, 'effect'), + key: get(taint, 'key'), + value: get(taint, 'value'), + effect: get(taint, 'effect'), + readonly: C.LABEL_PREFIX_TO_IGNORE.find((L) => get(taint, 'key').startsWith(L)) } })); }, diff --git a/lib/shared/addon/components/node-taints/template.hbs b/lib/shared/addon/components/node-taints/template.hbs index 1b637ae14..3075fc173 100644 --- a/lib/shared/addon/components/node-taints/template.hbs +++ b/lib/shared/addon/components/node-taints/template.hbs @@ -39,6 +39,7 @@ class="form-control input-sm" type="text" value=taint.key + disabled=taint.readonly placeholder=(t "formNodeTaints.key.placeholder") }} @@ -50,6 +51,7 @@ class="form-control input-sm" type="text" value=taint.value + disabled=taint.readonly placeholder=(t "formNodeTaints.value.placeholder") }} @@ -61,12 +63,14 @@ classNames="form-control input-sm" content=effects value=taint.effect + disabled=taint.readonly }}