Просмотр исходного кода

replace provisioner status for testing

Alexander Belanger 4 лет назад
Родитель
Сommit
74fced17f3

+ 9 - 25
dashboard/src/components/ProvisionerStatus.tsx

@@ -15,10 +15,15 @@ export interface TFModule {
   resources: TFResource[]
 }
 
+export interface TFResourceError {
+  errored_out: boolean
+  error_context?: string
+}
+
 export interface TFResource {
   addr: string,
   provisioned: boolean,
-  error: string,
+  errored: TFResourceError,
 }
 
 const nameMap : { [key: string]: string } = {
@@ -63,11 +68,11 @@ const ProvisionerStatus: React.FC<Props> = (props) => {
       var errors : string[] = []
 
       const hasError = val.resources?.filter((resource) => {
-        if (resource.error !== "") {
-          errors.push(resource.error)
+        if (resource.errored?.errored_out) {
+          errors.push(resource.errored?.error_context)
         }
 
-        return resource.error !== ""
+        return resource.errored?.errored_out
       }).length > 0
 
       const width = 100 * (provisionedResources / (totalResources * 1.0))
@@ -110,27 +115,6 @@ const ProvisionerStatus: React.FC<Props> = (props) => {
   return (
     <StyledProvisionerStatus>
         {renderModules()}
-        {/* <InfraObject>
-          <InfraHeader>
-            {renderStatus("loading")}
-            Elastic Kubernetes Service (EKS)
-          </InfraHeader>
-          <LoadingBar>
-            <LoadingFill status="loading" width="90%" />
-          </LoadingBar>
-        </InfraObject>
-        <InfraObject>
-          <InfraHeader>
-            {renderStatus("error")}
-            Elastic Container Registry (ECR)
-          </InfraHeader>
-          <LoadingBar>
-            <LoadingFill status="error" width="10%" />
-          </LoadingBar>
-          <ExpandedError>
-            422 validation error: autoscaling failed because sometimes infrastructure is a bit mysterious and hard to predict.
-          </ExpandedError>
-        </InfraObject> */}
     </StyledProvisionerStatus>
   );
 };

+ 6 - 1
dashboard/src/main/home/dashboard/Dashboard.tsx

@@ -16,6 +16,7 @@ import TitleSection from "components/TitleSection";
 
 import { pushFiltered, pushQueryParams } from "shared/routing";
 import { withAuth, WithAuthProps } from "shared/auth/AuthorizationHoc";
+import { SharedStatus } from "../onboarding/steps/ProvisionResources/forms/SharedStatus";
 
 type PropsType = RouteComponentProps &
   WithAuthProps & {
@@ -105,7 +106,11 @@ class Dashboard extends Component<PropsType, StateType> {
 
   renderTabContents = () => {
     if (this.currentTab() === "provisioner") {
-      return <Provisioner setRefreshClusters={this.props.setRefreshClusters} />;
+      return <SharedStatus 
+        filter={["doks", "docr", "eks", "ecr", "gke", "gcr"]} 
+        project_id={this.props.projectId} 
+        nextFormStep={() => null} 
+      />
     } else if (this.currentTab() === "create-cluster") {
       let helperText = "Create a cluster to link to this project";
       let helperIcon = "info";

+ 10 - 8
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/Status.tsx → dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/SharedStatus.tsx

@@ -5,9 +5,9 @@ import { useWebsockets } from "shared/hooks/useWebsockets";
 
 export const SharedStatus: React.FC<{
     nextFormStep: () => void;
-    project: any;
+    project_id: number;
     filter: string[];
-  }> = ({ nextFormStep, project, filter }) => {
+  }> = ({ nextFormStep, project_id, filter }) => {
     const {
       newWebsocket,
       openWebsocket,
@@ -21,7 +21,7 @@ export const SharedStatus: React.FC<{
       websocketID: string,
       module: TFModule
     ) => {
-      let apiPath = `/api/projects/${project?.id}/infras/${module.id}/logs`;
+      let apiPath = `/api/projects/${project_id}/infras/${module.id}/logs`;
   
       const wsConfig = {
         onopen: () => {
@@ -46,7 +46,7 @@ export const SharedStatus: React.FC<{
     };
   
     useEffect(() => {  
-      api.getInfra("<token>", {}, { project_id: project?.id }).then((res) => {
+      api.getInfra("<token>", {}, { project_id: project_id }).then((res) => {
         var matchedInfras : Map<string, any> = new Map()
   
         res.data.forEach((infra : any) => {
@@ -59,8 +59,8 @@ export const SharedStatus: React.FC<{
   
         // query for desired and current state, and convert to tf module
         matchedInfras.forEach((infra : any) => {
-          api.getInfraDesired("<token>", {}, { project_id: project?.id, infra_id: infra?.id }).then((resDesired) => {
-            api.getInfraCurrent("<token>", {}, { project_id: project?.id, infra_id: infra?.id }).then((resCurrent) => {
+          api.getInfraDesired("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resDesired) => {
+            api.getInfraCurrent("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resCurrent) => {
               var desired = resDesired.data
               var current = resCurrent.data
   
@@ -76,8 +76,10 @@ export const SharedStatus: React.FC<{
                 return {
                   addr: val?.addr,
                   provisioned: currentMap.has(val?.addr),
-                  // TODO: add error types
-                  error: "",
+                  errored: {
+                    errored_out: val?.errored?.errored_out,
+                    error_context: val?.errored?.error_context,
+                  },
                 }
               })
   

+ 1 - 1
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/_AWSProvisionerForm.tsx

@@ -10,7 +10,7 @@ import {
 import React, { useState } from "react";
 import api from "shared/api";
 import { useSnapshot } from "valtio";
-import { SharedStatus } from "./Status";
+import { SharedStatus } from "./SharedStatus";
 
 const regionOptions = [
   { value: "us-east-1", label: "US East (N. Virginia) us-east-1" },

+ 1 - 1
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/_DOProvisionerForm.tsx

@@ -13,7 +13,7 @@ import api from "shared/api";
 import styled from "styled-components";
 import { useSnapshot } from "valtio";
 import { useWebsockets } from "shared/hooks/useWebsockets";
-import { SharedStatus } from "./Status";
+import { SharedStatus } from "./SharedStatus";
 
 const tierOptions = [
   { value: "basic", label: "Basic" },

+ 1 - 1
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/_GCPProvisionerForm.tsx

@@ -12,7 +12,7 @@ import React, { useState } from "react";
 import api from "shared/api";
 import styled from "styled-components";
 import { useSnapshot } from "valtio";
-import { SharedStatus } from "./Status";
+import { SharedStatus } from "./SharedStatus";
 
 const regionOptions = [
   { value: "asia-east1", label: "asia-east1" },