Ver código fonte

handle unknown preflight checks on frontend (#4362)

Feroze Mohideen 2 anos atrás
pai
commit
7f2e57a4b3

+ 2 - 1
dashboard/src/lib/clusters/types.ts

@@ -508,6 +508,7 @@ export const clusterContractValidator = z.object({
 export type ClientClusterContract = z.infer<typeof clusterContractValidator>;
 
 const preflightCheckKeyValidator = z.enum([
+  "UNKNOWN",
   "eip",
   "vcpu",
   "vpc",
@@ -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(),

+ 11 - 1
dashboard/src/lib/hooks/useCluster.ts

@@ -387,6 +387,7 @@ export const useUpdateCluster = ({
           }
         );
       }
+
       const parsed = await preflightCheckValidator.parseAsync(
         preflightCheckResp.data
       );
@@ -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,
@@ -419,6 +428,7 @@ export const useUpdateCluster = ({
             };
           })
           .filter(valueExists);
+
         return {
           preflightChecks: clientPreflightChecks,
         };