diff --git a/app/models/cluster.js b/app/models/cluster.js index a83e00940..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: '', @@ -1311,11 +1309,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 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 7696184f3..5aaf0e7a2 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; - } - }); - } } } }, @@ -211,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'), @@ -224,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); @@ -309,12 +287,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); }, }, @@ -344,12 +317,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); } }), @@ -372,22 +340,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, { @@ -397,8 +359,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() { @@ -582,11 +542,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..9c6a43c01 100644 --- a/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-aks/template.hbs @@ -102,66 +102,13 @@
- -
- -
-
- -
-
- -
+ {{#if disableAzs}} + + {{/if}}
{{#if (eq step 2)}} @@ -377,7 +324,9 @@
{{#each config.nodePools as |nodePool|}}
-
- - - - -
{{#if (eq step 1)}} {{else}}
diff --git a/translations/en-us.yaml b/translations/en-us.yaml index adc481bbf..bdfd9ac0e 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -3471,6 +3471,7 @@ clusterNew: title: Networking azureaks: + availabilityZoneWarning: No availablity zones are available for the selected region. For the most resiliency it is recommended to select a High Availablity region. access: cloudCred: Cloud Credential detail: Configure the Azure Active Directory (AD) Service Principal that will be used to talk to Azure