Przeglądaj źródła

disable preflight check if cluster exists (#2914)

Feroze Mohideen 3 lat temu
rodzic
commit
de2e345fe8

+ 37 - 34
dashboard/src/components/ProvisionerSettings.tsx

@@ -177,46 +177,49 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
     try {
       setIsReadOnly(true);
       setErrorMessage(undefined);
-      markStepStarted("pre-provisioning-check-started");
 
-      await api.preflightCheckAWSUsage(
-        "<token>",
-        {
-          target_arn: props.credentialId,
-          region: awsRegion,
-        },
-        {
-          id: currentProject.id,
-        }
-      );
+      if (!props.clusterId) {
+        markStepStarted("pre-provisioning-check-started");
+
+        await api.preflightCheckAWSUsage(
+          "<token>",
+          {
+            target_arn: props.credentialId,
+            region: awsRegion,
+          },
+          {
+            id: currentProject.id,
+          }
+        );
 
-      markStepStarted("provisioning-started");
+        markStepStarted("provisioning-started");
+      }
 
       const res = await api.createContract("<token>", data, {
         project_id: currentProject.id,
       });
 
       // Only refresh and set clusters on initial create
-      if (!props.clusterId) {
-        setShouldRefreshClusters(true);
-        api
-          .getClusters("<token>", {}, { id: currentProject.id })
-          .then(({ data }) => {
-            data.forEach((cluster: ClusterType) => {
-              if (cluster.id === res.data.contract_revision?.cluster_id) {
-                // setHasFinishedOnboarding(true);
-                setCurrentCluster(cluster);
-                OFState.actions.goTo("clean_up");
-                pushFiltered(props, "/cluster-dashboard", ["project_id"], {
-                  cluster: cluster.name,
-                });
-              }
-            });
-          })
-          .catch((err) => {
-            console.error(err);
+      // if (!props.clusterId) {
+      setShouldRefreshClusters(true);
+      api
+        .getClusters("<token>", {}, { id: currentProject.id })
+        .then(({ data }) => {
+          data.forEach((cluster: ClusterType) => {
+            if (cluster.id === res.data.contract_revision?.cluster_id) {
+              // setHasFinishedOnboarding(true);
+              setCurrentCluster(cluster);
+              OFState.actions.goTo("clean_up");
+              pushFiltered(props, "/cluster-dashboard", ["project_id"], {
+                cluster: cluster.name,
+              });
+            }
           });
-      }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+      // }
       setErrorMessage(undefined);
     } catch (err) {
       const errMessage = err.response.data.error.replace("unknown: ", "");
@@ -244,8 +247,8 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
   useEffect(() => {
     setIsReadOnly(
       props.clusterId &&
-        (currentCluster.status === "UPDATING" ||
-          currentCluster.status === "UPDATING_UNAVAILABLE")
+      (currentCluster.status === "UPDATING" ||
+        currentCluster.status === "UPDATING_UNAVAILABLE")
     );
     setClusterName(
       `${currentProject.name}-cluster-${Math.random()
@@ -393,7 +396,7 @@ const ExpandHeader = styled.div<{ isExpanded: boolean }>`
     margin-right: 7px;
     margin-left: -7px;
     transform: ${(props) =>
-      props.isExpanded ? "rotate(0deg)" : "rotate(-90deg)"};
+    props.isExpanded ? "rotate(0deg)" : "rotate(-90deg)"};
   }
 `;
 

+ 13 - 10
dashboard/src/main/home/onboarding/state/index.ts

@@ -35,16 +35,19 @@ export const OFState = proxy({
     saveState: () => {
       const state = compressState(OFState);
 
-      api
-        .saveOnboardingState(
-          "<token>",
-          {
-            ...state,
-          },
-          { project_id: OFState.StateHandler?.project?.id }
-        )
-        .then((res) => console.log(res))
-        .catch((err) => console.log(err));
+      if (OFState.StateHandler?.project?.id) {
+        api
+          .saveOnboardingState(
+            "<token>",
+            {
+              ...state,
+            },
+            { project_id: OFState.StateHandler?.project?.id }
+          )
+          .then((res) => console.log(res))
+          .catch((err) => console.log(err));
+      }
+
     },
     restoreState: (state: any) => {
       const prevState = decompressState(state);