2
0
Эх сурвалжийг харах

[POR-1980] rerun ci on predeploy failure (#3827)

ianedwards 2 жил өмнө
parent
commit
03b45fa340

+ 1 - 0
dashboard/src/lib/revisions/types.ts

@@ -10,6 +10,7 @@ export const appRevisionValidator = z.object({
     "BUILD_FAILED",
     "BUILD_CANCELED",
     "DEPLOY_FAILED",
+    "PREDEPLOY_FAILED"
   ]),
   b64_app_proto: z.string(),
   revision_number: z.number(),

+ 40 - 20
dashboard/src/main/home/app-dashboard/app-view/AppDataContainer.tsx

@@ -1,4 +1,10 @@
-import React, {useCallback, useContext, useEffect, useMemo, useState} from "react";
+import React, {
+  useCallback,
+  useContext,
+  useEffect,
+  useMemo,
+  useState,
+} from "react";
 import { FormProvider, useForm } from "react-hook-form";
 import {
   PorterAppFormData,
@@ -201,7 +207,9 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
       );
 
       const needsRebuild =
-        buildIsDirty || latestRevision.status === "BUILD_FAILED";
+        buildIsDirty ||
+        latestRevision.status === "BUILD_FAILED" ||
+        latestRevision.status === "PREDEPLOY_FAILED";
 
       if (needsRebuild && !data.redeployOnSave) {
         setConfirmDeployModalOpen(true);
@@ -297,16 +305,19 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
       // redirect to the default tab after save
       history.push(`/apps/${porterAppRecord.name}/${DEFAULT_TAB}`);
     } catch (err) {
-      let message = "App update failed: please try again or contact support@porter.run if the error persists.";
+      let message =
+        "App update failed: please try again or contact support@porter.run if the error persists.";
       let stack = "Unable to get error stack";
 
       if (axios.isAxiosError(err)) {
-        const parsed = z.object({error: z.string()}).safeParse(err.response?.data);
+        const parsed = z
+          .object({ error: z.string() })
+          .safeParse(err.response?.data);
         if (parsed.success) {
           message = `App update failed: ${parsed.data.error}`;
         }
         stack = err.stack ?? "(No error stack)";
-      } 
+      }
 
       updateAppStep({
         step: "porter-app-update-failure",
@@ -372,17 +383,23 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
     if (errorKeys.length > 0) {
       const stringifiedJson = JSON.stringify(errors);
 
-      let errorMessage = "App update failed. Please try again. If the error persists, please contact support@porter.run."
+      let errorMessage =
+        "App update failed. Please try again. If the error persists, please contact support@porter.run.";
       if (errorKeys.includes("app")) {
         const appErrors = Object.keys(errors.app ?? {});
         if (appErrors.includes("build")) {
-          errorMessage = "Build settings are not properly configured."
+          errorMessage = "Build settings are not properly configured.";
         }
 
         if (appErrors.includes("services")) {
           errorMessage = "Service settings are not properly configured";
-          if (errors.app?.services?.root?.message || errors.app?.services?.message) {
-            const serviceErrorMessage = errors.app?.services?.root?.message ?? errors.app?.services?.message;
+          if (
+            errors.app?.services?.root?.message ||
+            errors.app?.services?.message
+          ) {
+            const serviceErrorMessage =
+              errors.app?.services?.root?.message ??
+              errors.app?.services?.message;
             errorMessage = `${errorMessage} - ${serviceErrorMessage}`;
           }
           errorMessage = `${errorMessage}.`;
@@ -392,7 +409,7 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
         if (appErrors.includes("message")) {
           errorMessage = errors.app?.message ?? errorMessage;
         }
-      } 
+      }
 
       updateAppStep({
         step: "porter-app-update-failure",
@@ -435,11 +452,13 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
       });
     }
 
-    {(currentProject?.helm_values_enabled || user?.isPorterUser) &&
-      base.push({ label: "Helm Overrides", value: "helm-overrides" });
+    {
+      (currentProject?.helm_values_enabled || user?.isPorterUser) &&
+        base.push({ label: "Helm Overrides", value: "helm-overrides" });
     }
-    {user?.isPorterUser &&
-      base.push({ label: "Latest Helm Values", value: "helm-values" });
+    {
+      user?.isPorterUser &&
+        base.push({ label: "Latest Helm Values", value: "helm-values" });
     }
     base.push({ label: "Settings", value: "settings" });
     return base;
@@ -546,11 +565,7 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
         <Spacer y={1} />
         {match(currentTab)
           .with("activity", () => <Activity />)
-          .with("overview", () => (
-            <Overview
-              buttonStatus={buttonStatus}
-            />
-          ))
+          .with("overview", () => <Overview buttonStatus={buttonStatus} />)
           .with("build-settings", () => (
             <BuildSettingsTab buttonStatus={buttonStatus} />
           ))
@@ -568,7 +583,12 @@ const AppDataContainer: React.FC<AppDataContainerProps> = ({ tabParam }) => {
           .with("metrics", () => <MetricsTab />)
           .with("events", () => <EventFocusView />)
           .with("job-history", () => <JobsTab />)
-          .with("helm-overrides", () => <HelmEditorTab buttonStatus={buttonStatus} featureFlagEnabled={currentProject?.helm_values_enabled ?? false}/>)
+          .with("helm-overrides", () => (
+            <HelmEditorTab
+              buttonStatus={buttonStatus}
+              featureFlagEnabled={currentProject?.helm_values_enabled ?? false}
+            />
+          ))
           .with("helm-values", () => <HelmLatestValuesTab />)
           .otherwise(() => null)}
         <Spacer y={2} />

+ 3 - 0
dashboard/src/main/home/app-dashboard/app-view/ConfirmRedeployModal.tsx

@@ -30,6 +30,9 @@ const ConfirmRedeployModal: React.FC<Props> = ({
     if (latestRevision.status === "BUILD_FAILED") {
       return "Your application's build previously failed. Confirming this change will trigger a rerun of your application's CI pipeline.";
     }
+    if (latestRevision.status === "PREDEPLOY_FAILED") {
+      return "Your application's predeploy previously failed. Confirming this change will trigger a rerun of your application's CI pipeline.";
+    }
   }, [latestRevision, buildIsDirty]);
 
   return (

+ 5 - 4
dashboard/src/main/home/app-dashboard/validate-apply/revisions-list/RevisionTableContents.tsx

@@ -59,6 +59,7 @@ const RevisionTableContents: React.FC<RevisionTableContentsProps> = ({
       .with("BUILD_FAILED", () => "Build Failed")
       .with("DEPLOY_FAILED", () => "Deploy Failed")
       .with("DEPLOYED", () => "Deployed")
+      .with("PREDEPLOY_FAILED", () => "Pre-Deploy Failed")
       .exhaustive();
 
   const getDotColor = (status: AppRevision["status"]) =>
@@ -171,7 +172,7 @@ const RevisionTableContents: React.FC<RevisionTableContentsProps> = ({
                     selected={
                       previewRevision
                         ? revision.revision_number ===
-                        previewRevision.revision_number
+                          previewRevision.revision_number
                         : isLatestDeployedRevision
                     }
                     onClick={() => {
@@ -252,7 +253,7 @@ const RevisionHeader = styled.div`
     cursor: pointer;
     border-radius: 20px;
     transform: ${(props: { showRevisions: boolean; isCurrent: boolean }) =>
-    props.showRevisions ? "" : "rotate(-90deg)"};
+      props.showRevisions ? "" : "rotate(-90deg)"};
     transition: transform 0.1s ease;
   }
 `;
@@ -293,7 +294,7 @@ const Tr = styled.tr`
     props.selected ? "#ffffff11" : ""};
   :hover {
     background: ${(props: { disableHover?: boolean; selected?: boolean }) =>
-    props.disableHover ? "" : "#ffffff22"};
+      props.disableHover ? "" : "#ffffff22"};
   }
 `;
 
@@ -325,7 +326,7 @@ const RollbackButton = styled.div`
     props.disabled ? "#aaaabbee" : "#616FEEcc"};
   :hover {
     background: ${(props: { disabled: boolean }) =>
-    props.disabled ? "" : "#405eddbb"};
+      props.disabled ? "" : "#405eddbb"};
   }
 `;