mirror of https://github.com/rancher/dashboard.git
AKS: fix node labels and errors when saving the cluster fails immediately (#11278)
* fix aks nodepool nodelabel * remove cleanPoolsForSave before save hook * remove unused beforeSaveHook
This commit is contained in:
parent
4168a2b1a5
commit
cc25f8523e
|
|
@ -447,11 +447,12 @@ export default defineComponent({
|
|||
/>
|
||||
</div>
|
||||
<KeyValue
|
||||
v-model="pool.labels"
|
||||
v-model="pool.nodeLabels"
|
||||
:mode="mode"
|
||||
:value-can-be-empty="true"
|
||||
add-label-key="Add Label"
|
||||
:add-label="t('aks.nodePools.labels.add')"
|
||||
:read-allowed="false"
|
||||
data-testid="aks-node-labels-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -301,7 +301,6 @@ export default defineComponent({
|
|||
const registerBeforeHook = this.registerBeforeHook as Function;
|
||||
const registerAfterHook = this.registerAfterHook as Function;
|
||||
|
||||
registerBeforeHook(this.cleanPoolsForSave);
|
||||
registerBeforeHook(this.removeUnchangedConfigFields);
|
||||
registerAfterHook(this.saveRoleBindings, 'save-role-bindings');
|
||||
},
|
||||
|
|
@ -985,17 +984,6 @@ export default defineComponent({
|
|||
}
|
||||
},
|
||||
|
||||
// these fields are used purely in UI, to track individual nodepool components
|
||||
cleanPoolsForSave(): void {
|
||||
this.nodePools.forEach((pool: AKSNodePool) => {
|
||||
Object.keys(pool).forEach((key: string) => {
|
||||
if (key.startsWith('_')) {
|
||||
delete pool[key as keyof AKSNodePool];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// only save values that differ from upstream aks spec - see diffUpstreamSpec comments for details
|
||||
removeUnchangedConfigFields(): void {
|
||||
const upstreamConfig = this.normanCluster?.status?.aksStatus?.upstreamSpec;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ const mockedValidationMixin = {
|
|||
const mockedStore = () => {
|
||||
return {
|
||||
getters: {
|
||||
'i18n/t': (text: string, v = {}) => {
|
||||
return `${ text }${ Object.values(v) }`;
|
||||
'i18n/t': (text: string, v: {[key:string]: string}) => {
|
||||
return `${ text }${ Object.values(v || {}) }`;
|
||||
},
|
||||
t: (text: string) => text,
|
||||
currentStore: () => 'current_store',
|
||||
|
|
@ -204,4 +204,26 @@ describe('aks node pool component', () => {
|
|||
// above verifies that the form is showing the right thing: also verify that the node pool spec has been updated to remove the taint
|
||||
expect(wrapper.props().pool.nodeTaints).toStrictEqual([initialTaints[1]]);
|
||||
});
|
||||
|
||||
it('should add nodeLabels to the pool spec when the labels keyvalue is edited', async() => {
|
||||
const labels = { abc: 'def', efg: 'hij' };
|
||||
const newLabels = { abc: 'def' };
|
||||
const wrapper = mount(AksNodePool, {
|
||||
propsData: {
|
||||
pool: { ...defaultPool, nodeLabels: { ...labels } },
|
||||
|
||||
mode: _EDIT
|
||||
},
|
||||
...requiredSetup()
|
||||
|
||||
});
|
||||
const labelInput = wrapper.find('[data-testid="aks-node-labels-input"]');
|
||||
|
||||
expect(labelInput.props().value).toStrictEqual(labels);
|
||||
|
||||
labelInput.vm.$emit('input', newLabels);
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
expect(wrapper.props().pool.nodeLabels).toStrictEqual(newLabels);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ aks:
|
|||
label: Mode
|
||||
labels:
|
||||
tooltip: Configure labels for all nodes in this Node Pool.
|
||||
add: Add Label
|
||||
orchestratorVersion:
|
||||
label: Node Pool Kubernetes Version
|
||||
upgrade: Upgrade node pool Kubernetes version from {from} to {to}
|
||||
|
|
|
|||
Loading…
Reference in New Issue