diff --git a/lib/monitoring/addon/components/enable-monitoring/component.js b/lib/monitoring/addon/components/enable-monitoring/component.js index 55c87cefa..8e1a3d3d6 100644 --- a/lib/monitoring/addon/components/enable-monitoring/component.js +++ b/lib/monitoring/addon/components/enable-monitoring/component.js @@ -31,6 +31,8 @@ const CLUSTER_HIDDEN_KEYS = { 'operator-init.enabled': 'true', } const PROMETHEUS_TOLERATION = 'prometheus.tolerations' +const SCHEDULABLE_COMPONENTS = ['prometheus', 'grafana', 'operator', 'exporter-kube-state'] + export default Component.extend(ReservationCheck, CatalogUpgrade, { scope: service(), settings: service(), @@ -111,7 +113,7 @@ export default Component.extend(ReservationCheck, CatalogUpgrade, { answers['prometheus.persistent.useReleaseName'] = 'true'; } - Object.keys(answers).filter((key) => key.startsWith('prometheus.nodeSelectors[') ).forEach((key) => { + Object.keys(answers).filter((key) => SCHEDULABLE_COMPONENTS.find((c) => key.startsWith(`${ c }.nodeSelectors[`))).forEach((key) => { delete answers[key] }); @@ -124,15 +126,17 @@ export default Component.extend(ReservationCheck, CatalogUpgrade, { } else if (v) { s += `="${ get(selector, 'value') }"`; } - answers[`prometheus.nodeSelectors[${ index }]`] = s; + SCHEDULABLE_COMPONENTS.forEach((c) => { + answers[`${ c }.nodeSelectors[${ index }]`] = s; + }); }); - Object.keys(answers).filter((key) => key.startsWith(`${ PROMETHEUS_TOLERATION }[`) ).forEach((key) => { + Object.keys(answers).filter((key) => SCHEDULABLE_COMPONENTS.find((c) => key.startsWith(`${ c }.tolerations[`))).forEach((key) => { delete answers[key] }); - ['prometheus'].map((component) => { - (get(this, `${ component }Tolerations`) || []).map((t, index) => { + SCHEDULABLE_COMPONENTS.map((component) => { + (get(this, `prometheusTolerations`) || []).map((t, index) => { Object.keys(t).map((key) => { if (t[key]) { answers[`${ component }.tolerations[${ index }].${ key }`] = t[key].toString() @@ -308,8 +312,8 @@ export default Component.extend(ReservationCheck, CatalogUpgrade, { Object.keys(body || {}).forEach((key) => { if ( EXPOSED_OPTIONS.indexOf(key) > -1 || - key.startsWith('prometheus.nodeSelectors[') || - key.startsWith(PROMETHEUS_TOLERATION) + SCHEDULABLE_COMPONENTS.find((c) => key.startsWith(`${ c }.nodeSelectors[`)) || + SCHEDULABLE_COMPONENTS.find((c) => key.startsWith(`${ c }.tolerations[`)) ) { answers[key] = body[key]; } else if (!Object.keys(CLUSTER_HIDDEN_KEYS).includes(key)) {