Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [M3-9025] - Region validation when switching to LKE-E #11471

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ import type {
KubeNodePoolResponse,
KubernetesTier,
} from '@linode/api-v4/lib/kubernetes';
import type { Region } from '@linode/api-v4/lib/regions';
import type { APIError } from '@linode/api-v4/lib/types';
import type { ExtendedIP } from 'src/utilities/ipUtils';

export const CreateCluster = () => {
const { classes } = useStyles();
const [selectedRegionId, setSelectedRegionId] = React.useState<
string | undefined
const [selectedRegion, setSelectedRegion] = React.useState<
Region | undefined
>();
const [nodePools, setNodePools] = React.useState<KubeNodePoolResponse[]>([]);
const [label, setLabel] = React.useState<string | undefined>();
Expand Down Expand Up @@ -110,6 +111,11 @@ export const CreateCluster = () => {
// HA is enabled by default for enterprise clusters
if (tier === 'enterprise') {
setHighAvailability(true);

// When changing the tier to enterprise, we want to check if the pre-selected region has the capability
if (!selectedRegion?.capabilities.includes('Kubernetes Enterprise')) {
setSelectedRegion(undefined);
}
} else {
setHighAvailability(undefined);
}
Expand Down Expand Up @@ -214,7 +220,7 @@ export const CreateCluster = () => {
k8s_version: version,
label,
node_pools,
region: selectedRegionId,
region: selectedRegion?.id,
};

if (showAPL) {
Expand Down Expand Up @@ -271,7 +277,7 @@ export const CreateCluster = () => {
};

const highAvailabilityPrice = getDCSpecificPriceByType({
regionId: selectedRegionId,
regionId: selectedRegion?.id,
type: lkeHAType,
});

Expand All @@ -295,7 +301,7 @@ export const CreateCluster = () => {
isSelectedRegionEligibleForPlan,
} = plansNoticesUtils({
regionsData,
selectedRegionID: selectedRegionId,
selectedRegionID: selectedRegion?.id,
});

if (typesError || regionsError || versionsError) {
Expand Down Expand Up @@ -362,9 +368,9 @@ export const CreateCluster = () => {
}
disableClearable
errorText={errorMap.region}
onChange={(e, region) => setSelectedRegionId(region.id)}
onChange={(e, region) => setSelectedRegion(region)}
regions={regionsData}
value={selectedRegionId}
value={selectedRegion?.id}
/>
</Stack>
<StyledDocsLinkContainer
Expand Down Expand Up @@ -414,7 +420,7 @@ export const CreateCluster = () => {
isAPLEnabled={apl_enabled}
isErrorKubernetesTypes={isErrorKubernetesTypes}
isLoadingKubernetesTypes={isLoadingKubernetesTypes}
selectedRegionId={selectedRegionId}
selectedRegionId={selectedRegion?.id}
setHighAvailability={setHighAvailability}
/>
</Box>
Expand Down Expand Up @@ -454,7 +460,7 @@ export const CreateCluster = () => {
isPlanPanelDisabled={isPlanPanelDisabled}
isSelectedRegionEligibleForPlan={isSelectedRegionEligibleForPlan}
regionsData={regionsData}
selectedRegionId={selectedRegionId}
selectedRegionId={selectedRegion?.id}
types={typesData || []}
typesLoading={typesLoading}
/>
Expand All @@ -473,7 +479,7 @@ export const CreateCluster = () => {
updateFor={[
hasAgreed,
highAvailability,
selectedRegionId,
selectedRegion?.id,
nodePools,
submitting,
typesData,
Expand All @@ -487,7 +493,7 @@ export const CreateCluster = () => {
hasAgreed={hasAgreed}
highAvailability={highAvailability}
pools={nodePools}
region={selectedRegionId}
region={selectedRegion?.id}
regionsData={regionsData}
removePool={removePool}
showHighAvailability={showHighAvailability}
Expand Down
Loading