Skip to content

Commit

Permalink
Merge pull request #11452 from mantis-toboggan-md/aks-fix-nodepool-na…
Browse files Browse the repository at this point in the history
…ming

AKS - fix tab component behavior when there are duplicate node pool names
  • Loading branch information
richard-cox authored Jul 17, 2024
2 parents dfd537c + b135177 commit 3da1205
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pkg/aks/components/CruAks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ import {
ipv4WithCidr,
outboundTypeUserDefined,
privateDnsZone,
nodePoolNames
nodePoolNames,
nodePoolNamesUnique
} from '../util/validators';
export const defaultNodePool = {
Expand Down Expand Up @@ -242,6 +243,10 @@ export default defineComponent({
path: 'poolName',
rules: ['poolNames']
},
{
path: 'poolNamesUnique',
rules: ['poolNamesUnique']
},
{
path: 'poolAZ',
rules: ['availabilityZoneSupport']
Expand Down Expand Up @@ -336,6 +341,7 @@ export default defineComponent({
outboundType: outboundTypeUserDefined(this, 'aks.outboundType.label', 'aksConfig.outboundType'),
privateDnsZone: privateDnsZone(this, 'aks.privateDnsZone.label', 'aksConfig.privateDnsZone'),
poolNames: nodePoolNames(this),
poolNamesUnique: nodePoolNamesUnique(this),
vmSizeAvailable: () => {
if (this.touchedVmSize) {
Expand Down Expand Up @@ -1093,7 +1099,7 @@ export default defineComponent({
<Tab
v-for="(pool, i) in nodePools"
:key="pool._id"
:name="pool.name"
:name="pool._id || pool.name"
:label="pool.name || t('aks.nodePools.notNamed')"
:error="!poolIsValid(pool)"
>
Expand Down
3 changes: 2 additions & 1 deletion pkg/aks/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ aks:
poolMinMax: The minimum number of nodes must be less than or equal to the maximum number of nodes, and the node count must be between or equal to the minimum and maximum.
poolMin: The minimum number of nodes must be greater than 0 and at most 100.
poolMax: The maximum number of nodes must be greater than 0 and at most 100.
poolTaints: Taints must have both a key and value defined.
poolTaints: Taints must have both a key and value defined.
poolNamesUnique: Node pool names must be unique.
12 changes: 12 additions & 0 deletions pkg/aks/util/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,15 @@ export const nodePoolNames = (ctx: any) => {
}
};
};

export const nodePoolNamesUnique = (ctx: any) => {
return () :string | undefined => {
const poolNames = (ctx.nodePools || []).map((pool: AKSNodePool) => pool.name);

const hasDuplicates = poolNames.some((name: string, idx: number) => poolNames.indexOf(name) !== idx);

if (hasDuplicates) {
return ctx.t('aks.errors.poolNamesUnique');
}
};
};

0 comments on commit 3da1205

Please sign in to comment.