Skip to content

Commit 7432afd

Browse files
authored
fix: [M3-9025] - Region validation when switching to LKE-E (#11471)
## Description 📝 Fix region validation when a user is switching from LKE to LKE-E tier in the Kubernetes create flow ## How to test 🧪 ### Prerequisites (How to setup test environment) - Ensure you have the customer tags for LKE-E (check project tracker) ### Reproduction steps (How to reproduce the issue, if applicable) - [ ] Go to another branch or dev environment and navigate to the Kubernetes create page - [ ] Enter a cluster label, select LKE as the tier, select a non LKE-E supported region (i.e. Atlanta, GA), select a HA control plane option, add a plan - [ ] Change the selected tier to LKE-E. Notice the region select is cleared but the Create Cluster button is enabled. Clicking Create Cluster shows an error text in the Region field ### Verification steps (How to verify changes) - [ ] Checkout this branch or PR preview link and navigate to the Kubernetes create page - [ ] Enter a cluster label, select LKE as the tier, select a non LKE-E supported region (i.e. Atlanta, GA), select a HA control plane option, add a plan - [ ] Change the selected tier to LKE-E. The region select should be cleared and the Create Cluster button is disabled
1 parent 3e74aca commit 7432afd

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

packages/manager/src/features/Kubernetes/CreateCluster/CreateCluster.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ import type {
6161
KubeNodePoolResponse,
6262
KubernetesTier,
6363
} from '@linode/api-v4/lib/kubernetes';
64+
import type { Region } from '@linode/api-v4/lib/regions';
6465
import type { APIError } from '@linode/api-v4/lib/types';
6566
import type { ExtendedIP } from 'src/utilities/ipUtils';
6667

6768
export const CreateCluster = () => {
6869
const { classes } = useStyles();
69-
const [selectedRegionId, setSelectedRegionId] = React.useState<
70-
string | undefined
70+
const [selectedRegion, setSelectedRegion] = React.useState<
71+
Region | undefined
7172
>();
7273
const [nodePools, setNodePools] = React.useState<KubeNodePoolResponse[]>([]);
7374
const [label, setLabel] = React.useState<string | undefined>();
@@ -110,6 +111,11 @@ export const CreateCluster = () => {
110111
// HA is enabled by default for enterprise clusters
111112
if (tier === 'enterprise') {
112113
setHighAvailability(true);
114+
115+
// When changing the tier to enterprise, we want to check if the pre-selected region has the capability
116+
if (!selectedRegion?.capabilities.includes('Kubernetes Enterprise')) {
117+
setSelectedRegion(undefined);
118+
}
113119
} else {
114120
setHighAvailability(undefined);
115121
}
@@ -214,7 +220,7 @@ export const CreateCluster = () => {
214220
k8s_version: version,
215221
label,
216222
node_pools,
217-
region: selectedRegionId,
223+
region: selectedRegion?.id,
218224
};
219225

220226
if (showAPL) {
@@ -271,7 +277,7 @@ export const CreateCluster = () => {
271277
};
272278

273279
const highAvailabilityPrice = getDCSpecificPriceByType({
274-
regionId: selectedRegionId,
280+
regionId: selectedRegion?.id,
275281
type: lkeHAType,
276282
});
277283

@@ -295,7 +301,7 @@ export const CreateCluster = () => {
295301
isSelectedRegionEligibleForPlan,
296302
} = plansNoticesUtils({
297303
regionsData,
298-
selectedRegionID: selectedRegionId,
304+
selectedRegionID: selectedRegion?.id,
299305
});
300306

301307
if (typesError || regionsError || versionsError) {
@@ -362,9 +368,9 @@ export const CreateCluster = () => {
362368
}
363369
disableClearable
364370
errorText={errorMap.region}
365-
onChange={(e, region) => setSelectedRegionId(region.id)}
371+
onChange={(e, region) => setSelectedRegion(region)}
366372
regions={regionsData}
367-
value={selectedRegionId}
373+
value={selectedRegion?.id}
368374
/>
369375
</Stack>
370376
<StyledDocsLinkContainer
@@ -414,7 +420,7 @@ export const CreateCluster = () => {
414420
isAPLEnabled={apl_enabled}
415421
isErrorKubernetesTypes={isErrorKubernetesTypes}
416422
isLoadingKubernetesTypes={isLoadingKubernetesTypes}
417-
selectedRegionId={selectedRegionId}
423+
selectedRegionId={selectedRegion?.id}
418424
setHighAvailability={setHighAvailability}
419425
/>
420426
</Box>
@@ -454,7 +460,7 @@ export const CreateCluster = () => {
454460
isPlanPanelDisabled={isPlanPanelDisabled}
455461
isSelectedRegionEligibleForPlan={isSelectedRegionEligibleForPlan}
456462
regionsData={regionsData}
457-
selectedRegionId={selectedRegionId}
463+
selectedRegionId={selectedRegion?.id}
458464
types={typesData || []}
459465
typesLoading={typesLoading}
460466
/>
@@ -473,7 +479,7 @@ export const CreateCluster = () => {
473479
updateFor={[
474480
hasAgreed,
475481
highAvailability,
476-
selectedRegionId,
482+
selectedRegion?.id,
477483
nodePools,
478484
submitting,
479485
typesData,
@@ -487,7 +493,7 @@ export const CreateCluster = () => {
487493
hasAgreed={hasAgreed}
488494
highAvailability={highAvailability}
489495
pools={nodePools}
490-
region={selectedRegionId}
496+
region={selectedRegion?.id}
491497
regionsData={regionsData}
492498
removePool={removePool}
493499
showHighAvailability={showHighAvailability}

0 commit comments

Comments
 (0)