From ad752110b2c7f7b2a2fa9954069ae774cfe103f0 Mon Sep 17 00:00:00 2001 From: Nancy <42977925+mantis-toboggan-md@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:33:54 -0800 Subject: [PATCH] Ensure Azure RKE2 default region is available with selected cloud credential (#10471) * Fix(aks) Ensure AKS RKE2 default loaded region aligns with Credentials * fix azure machine pool default on edit * remove always-disabled azure environment input * force re-run ci --------- Co-authored-by: Siye Wang --- shell/assets/translations/en-us.yaml | 1 + shell/machine-config/azure.vue | 58 ++++++++++++++++++---------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/shell/assets/translations/en-us.yaml b/shell/assets/translations/en-us.yaml index f2e16e6a2a0..23bae1d138a 100644 --- a/shell/assets/translations/en-us.yaml +++ b/shell/assets/translations/en-us.yaml @@ -1393,6 +1393,7 @@ cluster: label: DNS Label environment: label: Environment + tooltip: The environment is configured when cloud credentials are created. faultDomainCount: help: If the availability set has already been created, the fault domain count will be ignored. label: Fault Domain Count diff --git a/shell/machine-config/azure.vue b/shell/machine-config/azure.vue index 866454716a2..d7925c64c77 100644 --- a/shell/machine-config/azure.vue +++ b/shell/machine-config/azure.vue @@ -12,6 +12,8 @@ import { Checkbox } from '@components/Form/Checkbox'; import ArrayList from '@shell/components/form/ArrayList'; import { randomStr } from '@shell/utils/string'; import { addParam, addParams } from '@shell/utils/url'; +import { NORMAN } from '@shell/config/types'; +import { findBy } from '@shell/utils/array'; import KeyValue from '@shell/components/form/KeyValue'; import { RadioGroup } from '@components/Form/Radio'; import { _CREATE, _EDIT } from '@shell/config/query-params'; @@ -92,7 +94,6 @@ const storageTypes = [ value: 'StandardSSD_LRS' } ]; -const DEFAULT_REGION = 'westus'; export default { components: { @@ -148,6 +149,12 @@ export default { } if (!isEmpty(environment)) { this.value.environment = environment; + } else if (this.loadedCredentialIdFor !== this.credentialId) { + this.allCredentials = await this.$store.dispatch('rancher/findAll', { type: NORMAN.CLOUD_CREDENTIAL }); + + const currentCredential = this.allCredentials.find((obj) => obj.id === this.credentialId); + + this.value.environment = currentCredential.azurecredentialConfig.environment; } if (!isEmpty(subscriptionId)) { this.value.subscriptionId = subscriptionId; @@ -156,19 +163,20 @@ export default { this.value.tenantId = tenantId; } - this.locationOptions = await this.$store.dispatch('management/request', { - url: addParam('/meta/aksLocations', 'cloudCredentialId', this.credentialId), - method: 'GET', - }); + if (this.loadedCredentialIdFor !== this.credentialId) { + this.locationOptions = await this.$store.dispatch('management/request', { + url: addParam('/meta/aksLocations', 'cloudCredentialId', this.credentialId), + method: 'GET', + }); - if (this.mode === _CREATE) { - this.value.location = DEFAULT_REGION; + this.loadedCredentialIdFor = this.credentialId; + } // when you edit an Azure cluster and add a new machine pool (edit) // the location field doesn't come populated which causes the vmSizes request // to return 200 but with a null response (also a bunch of other fields are undefined...) // so let's prefill them with the defaults - } else if (this.mode === _EDIT && !this.value?.location) { + if (this.mode === _EDIT && !this.value?.location) { for (const key in this.defaultConfig) { if (this.value[key] === undefined) { this.$set(this.value, key, this.defaultConfig[key]); @@ -176,6 +184,10 @@ export default { } } + if (!this.value.location || !findBy(this.locationOptions, 'name', this.value.location)) { + this.locationOptions?.length && this.setLocation(this.locationOptions[this.locationOptions.length - 1]); + } + this.vmSizes = await this.$store.dispatch('management/request', { url: addParams('/meta/aksVMSizesV2', { cloudCredentialId: this.credentialId, @@ -206,6 +218,8 @@ export default { useAvailabilitySet: false, vmSizes: [], valueCopy: this.value, + + loadedCredentialIdFor: null }; }, @@ -214,6 +228,10 @@ export default { this.$fetch(); }, + 'value.location'() { + this.$fetch(); + }, + 'value.availabilityZone'(neu) { if (neu && (!this.value.managedDisks || !this.value.enablePublicIpStandardSku || !this.value.staticPublicIp)) { this.$emit('expandAdvanced'); @@ -499,19 +517,6 @@ export default {
-
- -
+
+ + {{ value.environment }} +