Skip to content

Commit

Permalink
fix aks region being overwritten when editing unprovisioned aks clust…
Browse files Browse the repository at this point in the history
…ers (#13037)

* fix aks region being overwritten when editing unprovisioned aks clusters

* update aks unit tests
  • Loading branch information
mantis-toboggan-md authored Jan 10, 2025
1 parent 9c6ff41 commit 938b866
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 6 additions & 3 deletions pkg/aks/components/CruAks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ export default defineComponent({
virtualNetwork: {
get() {
return this.virtualNetworkOptions.find((opt) => opt.value === this.config.subnet) || this.t('generic.none');
return this.virtualNetworkOptions.find((opt) => opt.value === this.config.subnet) || { label: this.t('generic.none') };
},
set(neu: {label: string, kind?: string, disabled?: boolean, value?: string, virtualNetwork?: any}) {
if (neu.label === this.t('generic.none')) {
Expand Down Expand Up @@ -804,8 +804,6 @@ export default defineComponent({
return;
}
this.loadingLocations = true;
// this will force the resourceLocation watcher to re-run every time new locations are fetched even if the default one selected hasn't changed
this.config['resourceLocation'] = '';
const { azureCredentialSecret } = this.config;
Expand Down Expand Up @@ -839,6 +837,11 @@ export default defineComponent({
errors.push(this.t('aks.errors.regions', { e: parsedError || err }));
}
// once regions are loaded and a default selected, fetch resources that are region-scoped
this.getAksVersions();
this.getVmSizes();
this.getVirtualNetworks();
},
async getAksVersions(): Promise<void> {
Expand Down
15 changes: 7 additions & 8 deletions pkg/aks/components/__tests__/CruAks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('aks provisioning form', () => {
it('should display subnets grouped by network in the virtual network dropdown', async() => {
const noneOption = { label: 'generic.none' };
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand All @@ -254,7 +254,6 @@ describe('aks provisioning form', () => {
const networkOpts = virtualNetworkSelect.props().options;

expect(virtualNetworkSelect.props().value).toStrictEqual(noneOption);

expect(networkOpts).toStrictEqual([{ label: 'generic.none' }, {
disabled: true, kind: 'group', label: 'network2'
}, {
Expand Down Expand Up @@ -299,7 +298,7 @@ describe('aks provisioning form', () => {

it('should prevent saving if a node pool has taints missing keys or values', async() => {
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand Down Expand Up @@ -343,7 +342,7 @@ describe('aks provisioning form', () => {
}],
])('should set virtualNetwork, virtualNetworkResourceGroup, and subnet when a virtual network is selected', async(optionIndex, { virtualNetwork, virtualNetworkResourceGroup, subnet }) => {
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand All @@ -366,7 +365,7 @@ describe('aks provisioning form', () => {

it('should set config.monitoring to \'true\' and show log anaytics workspace name and log analytics workspace group inputs when the monitoring checkbox is checked', async() => {
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand Down Expand Up @@ -397,7 +396,7 @@ describe('aks provisioning form', () => {

it('should clear virtualNetwork, virtualNetworkResourceGroup, and subnet when the \'none\' virtual network option is selected', async() => {
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand Down Expand Up @@ -430,7 +429,7 @@ describe('aks provisioning form', () => {
name: 'abc', _validation: {}, _isNewOrUnprovisioned: false, orchestratorVersion: originalVersion
}];
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', kubernetesVersion: originalVersion, nodePools
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', kubernetesVersion: originalVersion, nodePools, resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand All @@ -451,7 +450,7 @@ describe('aks provisioning form', () => {

it('should clear config.logAnalyticsWorkspaceName and config.logAnalyticsWorkspaceGroup when the monitoring checkbox is unchecked', async() => {
const config = {
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', monitoring: true, logAnalyticsWorkspaceGroup: 'abc', logAnalyticsWorkspaceName: 'def'
dnsPrefix: 'abc-123', resourceGroup: 'abc', clusterName: 'abc', monitoring: true, logAnalyticsWorkspaceGroup: 'abc', logAnalyticsWorkspaceName: 'def', resourceLocation: 'eastus'
};
const wrapper = shallowMount(CruAks, {
propsData: {
Expand Down

0 comments on commit 938b866

Please sign in to comment.