Sfoglia il codice sorgente

remove beta features enabled, add cluster vanity name, id, remove delete gpu (#4343)

Feroze Mohideen 2 anni fa
parent
commit
300e76e754

+ 0 - 48
api/server/handlers/project_integration/preflight_check.go

@@ -64,9 +64,6 @@ func (p *CreatePreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.R
 	ctx, span := telemetry.NewSpan(r.Context(), "preflight-checks")
 	defer span.End()
 	project, _ := ctx.Value(types.ProjectScope).(*models.Project)
-	betaFeaturesEnabled := project.GetFeatureFlag(models.BetaFeaturesEnabled, p.Config().LaunchDarklyClient)
-
-	telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "beta-features-enabled", Value: betaFeaturesEnabled})
 
 	cloudValues := &porterv1.PreflightCheckRequest{}
 	err := helpers.UnmarshalContractObjectFromReader(r.Body, cloudValues)
@@ -91,46 +88,6 @@ func (p *CreatePreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.R
 		}
 	}
 
-	if cloudValues.Contract != nil && cloudValues.Contract.Cluster != nil && cloudValues.Contract.Cluster.CloudProvider == porterv1.EnumCloudProvider_ENUM_CLOUD_PROVIDER_AZURE {
-		telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "new-endpoint", Value: true})
-		checkResp, err := p.Config().ClusterControlPlaneClient.CloudContractPreflightCheck(ctx,
-			connect.NewRequest(
-				&porterv1.CloudContractPreflightCheckRequest{
-					Contract: cloudValues.Contract,
-				},
-			),
-		)
-		if err != nil {
-			err = telemetry.Error(ctx, span, err, "error calling preflight checks")
-			p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
-			return
-		}
-
-		if checkResp.Msg == nil {
-			err = telemetry.Error(ctx, span, nil, "no message received from preflight checks")
-			p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
-			return
-		}
-
-		errors := []PreflightCheckError{}
-		for _, val := range checkResp.Msg.FailingPreflightChecks {
-			if val.Message == "" || !contains(recognizedPreflightCheckKeys, val.Type) {
-				continue
-			}
-
-			errors = append(errors, PreflightCheckError{
-				Name: val.Type,
-				Error: PorterError{
-					Message:  val.Message,
-					Metadata: val.Metadata,
-				},
-			})
-		}
-		resp.Errors = errors
-		p.WriteResult(w, r, resp)
-		return
-	}
-
 	checkResp, err := p.Config().ClusterControlPlaneClient.PreflightCheck(ctx, connect.NewRequest(&input))
 	if err != nil {
 		err = telemetry.Error(ctx, span, err, "error calling preflight checks")
@@ -144,11 +101,6 @@ func (p *CreatePreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.R
 		return
 	}
 
-	if !betaFeaturesEnabled {
-		p.WriteResult(w, r, checkResp)
-		return
-	}
-
 	errors := []PreflightCheckError{}
 	for key, val := range checkResp.Msg.PreflightChecks {
 		if val.Message == "" || !contains(recognizedPreflightCheckKeys, key) {

+ 1 - 2
dashboard/src/components/ClusterProvisioningPlaceholder.tsx

@@ -36,8 +36,7 @@ const ClusterProvisioningPlaceholder: React.FC<RouteComponentProps> = (
         onClick={() => {
           if (
             currentProject?.capi_provisioner_enabled &&
-            currentProject?.simplified_view_enabled &&
-            currentProject?.beta_features_enabled
+            currentProject?.simplified_view_enabled
           ) {
             pushFiltered(
               props,

+ 3 - 14
dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Resources.tsx

@@ -17,7 +17,6 @@ import { Context } from "shared/Context";
 
 import GPUResources from "./GPUResources";
 import IntelligentSlider from "./IntelligentSlider";
-import OldGPUResources from "./Old_GPUResources";
 
 type ResourcesProps = {
   index: number;
@@ -36,7 +35,6 @@ const Resources: React.FC<ResourcesProps> = ({
   maxRAM,
   maxGPU,
   service,
-  clusterContainsGPUNodes,
   isPredeploy = false,
   cluster,
 }) => {
@@ -148,18 +146,9 @@ const Resources: React.FC<ResourcesProps> = ({
         )}
       />
 
-      {currentProject?.gpu_enabled &&
-        (currentProject?.beta_features_enabled ? (
-          cluster && (
-            <GPUResources index={index} maxGPU={maxGPU} cluster={cluster} />
-          )
-        ) : (
-          <OldGPUResources
-            clusterContainsGPUNodes={clusterContainsGPUNodes}
-            maxGPU={maxGPU}
-            index={index}
-          />
-        ))}
+      {currentProject?.gpu_enabled && cluster && (
+        <GPUResources index={index} maxGPU={maxGPU} cluster={cluster} />
+      )}
       {match(service.config)
         .with({ type: "job" }, () => null)
         .with({ type: "predeploy" }, () => null)

+ 20 - 3
dashboard/src/main/home/infrastructure-dashboard/ClusterDashboard.tsx

@@ -1,4 +1,4 @@
-import React, { useMemo, useState } from "react";
+import React, { useContext, useMemo, useState } from "react";
 import _ from "lodash";
 import { Link } from "react-router-dom";
 import styled from "styled-components";
@@ -25,6 +25,7 @@ import {
 import { type ClientCluster } from "lib/clusters/types";
 import { useClusterList } from "lib/hooks/useCluster";
 
+import { Context } from "shared/Context";
 import { search } from "shared/search";
 import { readableDate } from "shared/string_utils";
 import infra from "assets/cluster.svg";
@@ -45,6 +46,7 @@ const ClusterDashboard: React.FC = () => {
   >("all");
 
   const { clusters, isLoading } = useClusterList();
+  const { user } = useContext(Context);
 
   const filteredClusters = useMemo(() => {
     const filteredBySearch = search(clusters, searchValue, {
@@ -161,7 +163,9 @@ const ClusterDashboard: React.FC = () => {
           {filteredClusters.map((cluster: ClientCluster, i: number) => {
             return (
               <Link to={`/infrastructure/${cluster.id}`} key={i}>
-                <Block>
+                <Block
+                  clusterId={user.isPorterUser ? cluster.id.toString() : ""}
+                >
                   <Container row>
                     <Icon src={cluster.cloud_provider.icon} height="18px" />
                     <Spacer inline width="11px" />
@@ -271,7 +275,7 @@ const List = styled.div`
   overflow: hidden;
 `;
 
-const Block = styled.div`
+const Block = styled.div<{ clusterId?: string }>`
   height: 150px;
   flex-direction: column;
   display: flex;
@@ -285,6 +289,19 @@ const Block = styled.div`
   border: 1px solid #494b4f;
   :hover {
     border: 1px solid #7a7b80;
+
+    ::after {
+      content: ${(props) =>
+        !props.clusterId ? "''" : `"ID: ${props.clusterId}"`};
+      position: absolute;
+      top: 2px;
+      right: 2px;
+      background: ${(props) => props.clusterId && `#ffffff44`};
+      opacity: 0.3;
+      padding: 5px;
+      border-radius: 4px;
+      font-size: 12px;
+    }
   }
 
   animation: fadeIn 0.3s 0s;

+ 23 - 23
dashboard/src/main/home/infrastructure-dashboard/shared/NodeGroups.tsx

@@ -29,7 +29,7 @@ const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
   const {
     fields: nodeGroups,
     append,
-    remove,
+    // remove,
   } = useFieldArray({
     control,
     name: "cluster.config.nodeGroups",
@@ -138,7 +138,7 @@ const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
                   <Spacer inline x={1} />
                   GPU node group
                 </Container>
-                <Container row>
+                {/* <Container row>
                   <ActionButton
                     onClick={(e) => {
                       e.stopPropagation();
@@ -147,7 +147,7 @@ const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
                   >
                     <span className="material-icons">delete</span>
                   </ActionButton>
-                </Container>
+                </Container> */}
               </Container>
             }
           >
@@ -255,24 +255,24 @@ const I = styled.i`
   }
 `;
 
-const ActionButton = styled.button`
-  position: relative;
-  border: none;
-  background: none;
-  color: white;
-  padding: 5px;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  border-radius: 50%;
-  cursor: pointer;
-  color: #aaaabb;
-  :hover {
-    color: white;
-  }
+// const ActionButton = styled.button`
+//   position: relative;
+//   border: none;
+//   background: none;
+//   color: white;
+//   padding: 5px;
+//   display: flex;
+//   justify-content: center;
+//   align-items: center;
+//   border-radius: 50%;
+//   cursor: pointer;
+//   color: #aaaabb;
+//   :hover {
+//     color: white;
+//   }
 
-  > span {
-    font-size: 20px;
-  }
-  margin-right: 5px;
-`;
+//   > span {
+//     font-size: 20px;
+//   }
+//   margin-right: 5px;
+// `;

+ 1 - 2
dashboard/src/main/home/onboarding/Onboarding.tsx

@@ -163,8 +163,7 @@ const Onboarding = () => {
   const renderOnboarding = () => {
     if (
       context?.currentProject?.simplified_view_enabled &&
-      context?.currentProject?.capi_provisioner_enabled &&
-      context?.currentProject?.beta_features_enabled
+      context?.currentProject?.capi_provisioner_enabled
     ) {
       return <CreateClusterForm />;
     } else if (context?.currentProject?.capi_provisioner_enabled) {

+ 1 - 1
dashboard/src/main/home/project-settings/Metadata.tsx

@@ -86,7 +86,7 @@ const Metadata: React.FC<Props> = ({
                 {clusters?.length > 0 &&
                     clusters.map((cluster, index) =>
                         <>
-                            <IdTextWithCopy key={index} id={cluster.id} name={cluster.name} icon={infra} />
+                            <IdTextWithCopy key={index} id={cluster.id} name={cluster.vanity_name ?? cluster.name} icon={infra} />
                         </>
                     )
                 }

+ 3 - 6
dashboard/src/main/home/sidebar/ClusterList.tsx

@@ -87,8 +87,7 @@ const ClusterList: React.FC = (props) => {
   const renderOptionList = (): JSX.Element[] => {
     if (
       currentProject?.simplified_view_enabled &&
-      currentProject?.capi_provisioner_enabled &&
-      currentProject?.beta_features_enabled
+      currentProject?.capi_provisioner_enabled
     ) {
       return clusterList.map((c) => (
         <OptionDiv
@@ -153,8 +152,7 @@ const ClusterList: React.FC = (props) => {
               setExpanded(false);
               if (
                 currentProject?.simplified_view_enabled &&
-                currentProject?.capi_provisioner_enabled &&
-                currentProject?.beta_features_enabled
+                currentProject?.capi_provisioner_enabled
               ) {
                 pushFiltered(props, "/infrastructure/new", []);
               } else {
@@ -207,8 +205,7 @@ const ClusterList: React.FC = (props) => {
       onClick={() => {
         if (
           currentProject?.simplified_view_enabled &&
-          currentProject?.capi_provisioner_enabled &&
-          currentProject?.beta_features_enabled
+          currentProject?.capi_provisioner_enabled
         ) {
           pushFiltered(props, "/infrastructure/new", []);
         } else {

+ 4 - 8
dashboard/src/main/home/sidebar/Sidebar.tsx

@@ -213,8 +213,7 @@ class Sidebar extends Component<PropsType, StateType> {
               "delete",
             ]) &&
               currentProject?.simplified_view_enabled &&
-              currentProject?.capi_provisioner_enabled &&
-              currentProject?.beta_features_enabled && (
+              currentProject?.capi_provisioner_enabled && (
                 <NavButton
                   path={"/infrastructure"}
                   active={window.location.pathname.startsWith(
@@ -261,8 +260,7 @@ class Sidebar extends Component<PropsType, StateType> {
             ]) &&
               !(
                 currentProject?.simplified_view_enabled &&
-                currentProject?.capi_provisioner_enabled &&
-                currentProject?.beta_features_enabled
+                currentProject?.capi_provisioner_enabled
               ) && (
                 <NavButton
                   path={"/cluster-dashboard"}
@@ -354,15 +352,13 @@ class Sidebar extends Component<PropsType, StateType> {
             <NavButton
               path={
                 currentProject?.simplified_view_enabled &&
-                currentProject?.capi_provisioner_enabled &&
-                currentProject?.beta_features_enabled
+                currentProject?.capi_provisioner_enabled
                   ? "/infrastructure"
                   : "/cluster-dashboard"
               }
               active={window.location.pathname.startsWith(
                 currentProject?.simplified_view_enabled &&
-                  currentProject?.capi_provisioner_enabled &&
-                  currentProject?.beta_features_enabled
+                  currentProject?.capi_provisioner_enabled
                   ? "/infrastructure"
                   : "/cluster-dashboard"
               )}