Skip to content

Commit

Permalink
handle unknown preflight checks on frontend (#4362)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Mar 4, 2024
1 parent 31cdd09 commit 7f2e57a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dashboard/src/lib/clusters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export const clusterContractValidator = z.object({
export type ClientClusterContract = z.infer<typeof clusterContractValidator>;

const preflightCheckKeyValidator = z.enum([
"UNKNOWN",
"eip",
"vcpu",
"vpc",
Expand All @@ -522,7 +523,7 @@ type PreflightCheckKey = z.infer<typeof preflightCheckKeyValidator>;
export const preflightCheckValidator = z.object({
errors: z
.object({
name: preflightCheckKeyValidator,
name: z.string().pipe(preflightCheckKeyValidator.catch("UNKNOWN")),
error: z.object({
message: z.string(),
metadata: z.record(z.string()).optional(),
Expand Down
12 changes: 11 additions & 1 deletion dashboard/src/lib/hooks/useCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export const useUpdateCluster = ({
}
);
}

const parsed = await preflightCheckValidator.parseAsync(
preflightCheckResp.data
);
Expand All @@ -406,7 +407,15 @@ export const useUpdateCluster = ({
(cloudProviderCheck) => e.name === cloudProviderCheck.name
);
if (!preflightCheckMatch) {
return undefined;
return {
title: "Unknown preflight check",
status: "failure" as const,
error: {
detail:
"Your cloud provider returned an unknown error. Please reach out to Porter support.",
metadata: {},
},
};
}
return {
title: preflightCheckMatch.displayName,
Expand All @@ -419,6 +428,7 @@ export const useUpdateCluster = ({
};
})
.filter(valueExists);

return {
preflightChecks: clientPreflightChecks,
};
Expand Down

0 comments on commit 7f2e57a

Please sign in to comment.