From ff81aa826860adfc1e97baca32adff2b23fd33ad Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 10:14:39 -0700 Subject: [PATCH 1/8] Remove tenant id from import, its on the cloud cc --- .../driver-import-aks/template.hbs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-import-aks/template.hbs b/lib/shared/addon/components/cluster-driver/driver-import-aks/template.hbs index c236dbb85..ec5f4be29 100644 --- a/lib/shared/addon/components/cluster-driver/driver-import-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-import-aks/template.hbs @@ -16,24 +16,6 @@ @showExpand={{false}} >
-
- - - - -
{{#if (eq step 1)}} {{else}}
From c5917281be1816db078a86b9dd7185568a0300b1 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 10:22:22 -0700 Subject: [PATCH 2/8] Validate DNS prefix on create only rancher/rancher#32999 --- .../addon/components/cluster-driver/driver-aks/component.js | 4 ++-- .../addon/components/cluster-driver/driver-aks/template.hbs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/component.js b/lib/shared/addon/components/cluster-driver/driver-aks/component.js index 7696184f3..b1cf1000f 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-aks/component.js @@ -582,11 +582,11 @@ export default Component.extend(ClusterDriver, { clusterErrors = clusterErrors.concat(this.validateVnetInputs()); } - if ( !get(this, 'config.resourceGroup') ) { + if ( this.isNew && !get(this, 'config.resourceGroup') ) { clusterErrors.push(intl.t('validation.required', { key: intl.t('clusterNew.azureaks.resourceGroup.label') })); } - if ( !get(this, 'config.dnsPrefix') ) { + if ( this.isNew && !get(this, 'config.dnsPrefix') ) { clusterErrors.push(intl.t('validation.required', { key: intl.t('clusterNew.azureaks.dns.label') })); } diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs index 3eff5b41c..5c908e648 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs @@ -377,7 +377,9 @@
Date: Fri, 4 Jun 2021 10:58:36 -0700 Subject: [PATCH 3/8] fix setTags logic for AKS v2 rancher/rancher#33017 --- .../components/cluster-driver/driver-aks/component.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/component.js b/lib/shared/addon/components/cluster-driver/driver-aks/component.js index b1cf1000f..370b71210 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-aks/component.js @@ -309,12 +309,7 @@ export default Component.extend(ClusterDriver, { }, setTags(section) { - const out = [] - - for (let key in section) { - out.pushObject(`${ key }=${ section[key] }`) - } - set(this, 'config.tags', out); + set(this, 'config.tags', section); }, }, From b12e9ac8f90c32e10092f8fe89a669d375732f12 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 11:13:27 -0700 Subject: [PATCH 4/8] az checkboxes should be disabled when location without is selected rancher/rancher#33019 --- .../addon/components/cluster-driver/driver-aks/template.hbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs index 5c908e648..62e789cef 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs @@ -111,7 +111,7 @@ {{/if}} {{t "clusterNew.azureaks.availabilityZones.zone" loc=1}} @@ -130,7 +130,7 @@ {{/if}} {{t "clusterNew.azureaks.availabilityZones.zone" loc=2}} @@ -149,7 +149,7 @@ {{/if}} {{t "clusterNew.azureaks.availabilityZones.zone" loc=3}} From e416275d3671b3b0ea8b6d50d13ded5bf13554e9 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 14:49:02 -0700 Subject: [PATCH 5/8] exclude nodeGroups & nodePools from json string check --- app/models/cluster.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/cluster.js b/app/models/cluster.js index a83e00940..fe25c5fba 100644 --- a/app/models/cluster.js +++ b/app/models/cluster.js @@ -1311,11 +1311,13 @@ export default Resource.extend(Grafana, ResourceUsage, { const lhsMatch = get(lhs, k); const rhsMatch = get(rhs, k); - try { - if (isEqual(JSON.stringify(lhsMatch), JSON.stringify(rhsMatch))) { - return; - } - } catch (e){} + if (k !== 'nodeGroups' && k !== 'nodePools') { + try { + if (isEqual(JSON.stringify(lhsMatch), JSON.stringify(rhsMatch))) { + return; + } + } catch (e){} + } if (k === 'nodeGroups' || k === 'nodePools' || k === 'tags' || k === 'labels') { // Node Groups and Node Pools do not require a sync, we can safely send the entire object From 3b0c1d3c71994c7eaa37cc302679f782df20a254 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 14:49:31 -0700 Subject: [PATCH 6/8] remove auto scaling defaults for aks nps --- app/models/cluster.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/cluster.js b/app/models/cluster.js index fe25c5fba..57e2cc14b 100644 --- a/app/models/cluster.js +++ b/app/models/cluster.js @@ -180,9 +180,7 @@ export const DEFAULT_AKS_NODE_POOL_CONFIG = { availabilityZones: ['1', '2', '3'], count: 1, enableAutoScaling: false, - maxCount: 3, maxPods: 110, - minCount: 1, mode: 'System', name: '', orchestratorVersion: '', From 3f29cb540ad0c295bf31c95255d76550eeebd317 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 4 Jun 2021 14:50:46 -0700 Subject: [PATCH 7/8] move node availablity zones to aks node pool row rancher/rancher#33021 --- .../components/aks-node-pool-row/component.js | 76 +++++++++++++++++++ .../components/aks-node-pool-row/template.hbs | 58 ++++++++++++-- .../cluster-driver/driver-aks/component.js | 63 ++------------- .../cluster-driver/driver-aks/template.hbs | 63 +-------------- 4 files changed, 135 insertions(+), 125 deletions(-) diff --git a/lib/shared/addon/components/aks-node-pool-row/component.js b/lib/shared/addon/components/aks-node-pool-row/component.js index 0f8f80092..38842305c 100644 --- a/lib/shared/addon/components/aks-node-pool-row/component.js +++ b/lib/shared/addon/components/aks-node-pool-row/component.js @@ -26,6 +26,7 @@ export default Component.extend({ diskTypes: OS_DISK_TYPES, upgradeVersion: false, showNodeUpgradePreventionReason: false, + disableAzs: false, isSystemType: equal('nodePool.mode', 'System'), @@ -39,6 +40,81 @@ export default Component.extend({ } })), + resetAvailablity: on('init', observer('isNewNodePool', 'disableAzs', function() { + const { + isNewNodePool, disableAzs, nodePool: { availabilityZones }, mode + } = this; + + if (mode !== 'edit' && !isNewNodePool || disableAzs) { + if (!isEmpty(availabilityZones)) { + set(this, 'nodePool.availabilityZones', []); + } + } + })), + + availablityZoneOne: computed('nodePool.availabilityZones.[]', { + get() { + return (this.nodePool?.availabilityZones ?? []).find((az) => az === '1') ? true : false; + }, + set(_key, value) { + let azs = (this.nodePool?.availabilityZones ?? []).slice(); + + if (value) { + if (!azs.find((az) => az === '1')) { + azs.push('1'); + } + } else { + azs = azs.without('1'); + } + + set(this, 'nodePool.availabilityZones', azs.sort()); + + return value; + } + }), + + availablityZoneThree: computed('nodePool.availabilityZones.[]', { + get() { + return (this.nodePool?.availabilityZones ?? []).find((az) => az === '2') ? true : false; + }, + set(_key, value) { + let azs = (this.nodePool?.availabilityZones ?? []).slice(); + + if (value) { + if (!azs.find((az) => az === '2')) { + azs.push('2'); + } + } else { + azs = azs.without('2'); + } + + set(this, 'nodePool.availabilityZones', azs.sort()); + + return value; + } + }), + + availablityZoneTwo: computed('nodePool.availabilityZones.[]', { + get() { + return (this.nodePool?.availabilityZones ?? []).find((az) => az === '3') ? true : false; + }, + set(_key, value) { + let azs = (this.nodePool?.availabilityZones ?? []).slice(); + + if (value) { + if (!azs.find((az) => az === '3')) { + azs.push('3'); + } + } else { + azs = azs.without('3'); + } + + set(this, 'nodePool.availabilityZones', azs.sort()); + + return value; + } + }), + originalClusterVersion: computed('cluster.aksConfig.kubernetesVersion', 'originalCluster.aksConfig.kubernetesVersion', 'originalCluster.aksConfig.upstreamSpec.kubernetesVersion', function() { if (!isEmpty(get(this, 'originalCluster.aksConfig.kubernetesVersion'))) { return get(this, 'originalCluster.aksConfig.kubernetesVersion'); diff --git a/lib/shared/addon/components/aks-node-pool-row/template.hbs b/lib/shared/addon/components/aks-node-pool-row/template.hbs index ef444dbde..06215487d 100644 --- a/lib/shared/addon/components/aks-node-pool-row/template.hbs +++ b/lib/shared/addon/components/aks-node-pool-row/template.hbs @@ -94,14 +94,58 @@
-
- {{#if nodePool.availabilityZones.length}} - {{displayZones}} - {{else}} - {{t "generic.na"}} - {{/if}} +
+ +
+
+ +
+
+
diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/component.js b/lib/shared/addon/components/cluster-driver/driver-aks/component.js index 370b71210..dc8aaf01c 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-aks/component.js @@ -64,9 +64,6 @@ export default Component.extend(ClusterDriver, { configField: 'aksConfig', - availablityZoneOne: true, - availablityZoneThree: true, - availablityZoneTwo: true, clusterAdvanced: false, clusterErrors: null, clusterLocationSaved: false, @@ -116,13 +113,6 @@ export default Component.extend(ClusterDriver, { if ( this.editing && this.importedClusterIsPending || (this.clusterIsPending && config?.privateCluster) ) { set(this, 'step', 4); } else { - // reset on edit so we can get real az's - setProperties(this, { - availablityZoneOne: false, - availablityZoneThree: false, - availablityZoneTwo: false, - }); - this.syncUpstreamConfig(); const tags = { ...( config.tags || {} ) }; @@ -132,32 +122,6 @@ export default Component.extend(ClusterDriver, { if (!isEmpty(config?.authorizedIpRanges)) { set(this, 'enabledAuthorizedIpRanges', true); } - - if (!isEmpty(config?.nodePools)) { - const azs = []; - - config.nodePools.forEach((np) => { - if (!isEmpty(np?.availabilityZones)) { - azs.pushObjects(np.availabilityZones); - } - }); - - azs.uniq().forEach((az) => { - switch (az) { - case '1': - set(this, 'availablityZoneOne', true); - break; - case '2': - set(this, 'availablityZoneTwo', true); - break; - case '3': - set(this, 'availablityZoneThree', true); - break; - default: - break; - } - }); - } } } }, @@ -339,12 +303,7 @@ export default Component.extend(ClusterDriver, { if (regionHasAz) { set(this, 'disableAzs', false); } else { - setProperties(this, { - disableAzs: true, - availablityZoneOne: false, - availablityZoneTwo: false, - availablityZoneThree: false, - }) + set(this, 'disableAzs', true); } }), @@ -367,22 +326,16 @@ export default Component.extend(ClusterDriver, { } }), - availablityZonesChanged: on('init', observer('availablityZoneOne', 'availablityZoneTwo', 'availablityZoneThree', 'config.nodePools.[]', function() { - const { - availablityZoneOne, availablityZoneTwo, availablityZoneThree - } = this; + availablityZonesChanged: on('init', observer('config.nodePools.[]', function() { const nodePools = get(this, 'config.nodePools') || []; - const azs = [availablityZoneOne, availablityZoneTwo, availablityZoneThree]; - const anySet = azs.any((az) => az); - const nodeAzs = []; + const azs = []; - azs.forEach((az, idx) => { - if (az) { - const azNo = idx + 1; - - nodeAzs.push(azNo); + nodePools.forEach((np) => { + if (np?.availabilityZones && np.availabilityZones.length > 0) { + azs.pushObjects(np.availabilityZones); } }); + const anySet = azs.uniq().any((az) => az); if (anySet) { setProperties(this, { @@ -392,8 +345,6 @@ export default Component.extend(ClusterDriver, { } else { set(this, 'loadBalancerImmutable', false); } - - nodePools.forEach((np) => set(np, 'availabilityZones', nodeAzs)); })), resetAdvancedOptions: on('init', observer('config.networkPlugin', function() { diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs index 62e789cef..c41ed03ba 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs @@ -101,68 +101,6 @@ />
-
- -
- -
-
- -
-
- -
-
{{#if (eq step 2)}} {{#each config.nodePools as |nodePool|}} Date: Fri, 4 Jun 2021 15:43:22 -0700 Subject: [PATCH 8/8] group regions by availablity for aks v2 display warning if selecting a region that is not ha --- .../cluster-driver/driver-aks/component.js | 18 ++++++++++++++++-- .../cluster-driver/driver-aks/template.hbs | 9 +++++++++ translations/en-us.yaml | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/component.js b/lib/shared/addon/components/cluster-driver/driver-aks/component.js index dc8aaf01c..5aaf0e7a2 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-aks/component.js @@ -175,7 +175,7 @@ export default Component.extend(ClusterDriver, { }, async loadRegions(cb) { const store = get(this, 'globalStore') - const { selectedCloudCredential } = this; + const { selectedCloudCredential, regionsWithAZs } = this; const data = { cloudCredentialId: get(selectedCloudCredential, 'id'), // tenantId: get(this, 'config.tenantId'), @@ -188,7 +188,21 @@ export default Component.extend(ClusterDriver, { method: 'GET', }); - set(this, 'regions', regions?.body ?? []); + const filteredRegions = (regions?.body ?? []).map((reg) => { + if (regionsWithAZs.includes(reg?.displayName || '')) { + return { + ...reg, + ...{ group: 'High Availablity' } + } + } else { + return { + ...reg, + ...{ group: 'Other' } + }; + } + }); + + set(this, 'regions', filteredRegions); cb(true); diff --git a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs index c41ed03ba..9c6a43c01 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs @@ -101,6 +101,15 @@ /> +
+ {{#if disableAzs}} + + {{/if}} +
{{#if (eq step 2)}}