Feroze Mohideen пре 2 година
родитељ
комит
7828e0d5ff

+ 6 - 6
dashboard/src/lib/clusters/constants.ts

@@ -14,8 +14,8 @@ import gcp from "assets/gcp.png";
 
 import {
   type ClientCloudProvider,
+  type ClientMachineType,
   type ClientRegion,
-  type MachineType,
   type PreflightCheck,
   type PreflightCheckResolution,
 } from "./types";
@@ -94,7 +94,7 @@ const SUPPORTED_AZURE_REGIONS: ClientRegion[] = [
   { name: "westus3", displayName: "West US 3" },
 ];
 
-const SUPPORTED_AWS_MACHINE_TYPES: MachineType[] = [
+const SUPPORTED_AWS_MACHINE_TYPES: ClientMachineType[] = [
   {
     name: "t3.medium",
     displayName: "t3.medium",
@@ -426,13 +426,13 @@ const SUPPORTED_AWS_MACHINE_TYPES: MachineType[] = [
     supportedRegions: SUPPORTED_AWS_REGIONS.map((r) => r.name),
   },
   {
-    name: "g4dn.24xlarge",
-    displayName: "g4dn.24xlarge",
+    name: "p4d.24xlarge",
+    displayName: "p4d.24xlarge",
     supportedRegions: SUPPORTED_AWS_REGIONS.map((r) => r.name),
   },
 ];
 
-const SUPPORTED_GCP_MACHINE_TYPES: MachineType[] = [
+const SUPPORTED_GCP_MACHINE_TYPES: ClientMachineType[] = [
   {
     name: "e2-standard-2",
     displayName: "e2-standard-2",
@@ -590,7 +590,7 @@ const SUPPORTED_GCP_MACHINE_TYPES: MachineType[] = [
   },
 ];
 
-const SUPPORTED_AZURE_MACHINE_TYPES: MachineType[] = [
+const SUPPORTED_AZURE_MACHINE_TYPES: ClientMachineType[] = [
   {
     name: "Standard_B2als_v2",
     displayName: "Standard_B2als_v2",

+ 3 - 3
dashboard/src/lib/clusters/types.ts

@@ -13,7 +13,7 @@ export type ClientCloudProvider = {
   displayName: string;
   icon: string;
   regions: ClientRegion[];
-  machineTypes: MachineType[];
+  machineTypes: ClientMachineType[];
   baseCost: number;
   newClusterDefaultContract: Contract; // this is where we include sensible defaults for new clusters
   preflightChecks: PreflightCheck[];
@@ -167,7 +167,7 @@ const awsMachineTypeValidator = z.enum([
   "g4dn.xlarge",
   "g4dn.2xlarge",
   "g4dn.4xlarge",
-  "g4dn.24xlarge",
+  "p4d.24xlarge",
 ]);
 type AWSMachineType = z.infer<typeof awsMachineTypeValidator>;
 const gcpMachineTypeValidator = z.enum([
@@ -224,7 +224,7 @@ type AzureSKUTier = {
   name: string;
   displayName: string;
 };
-export type MachineType = {
+export type ClientMachineType = {
   name: AWSMachineType | GCPMachineType | AzureMachineType;
   displayName: string;
   supportedRegions: Array<AWSRegion | GCPRegion | AzureRegion>;

+ 4 - 6
dashboard/src/main/home/app-dashboard/create-app/CreateApp.tsx

@@ -23,6 +23,7 @@ import VerticalSteps from "components/porter/VerticalSteps";
 import DashboardHeader from "main/home/cluster-dashboard/DashboardHeader";
 import { useAppAnalytics } from "lib/hooks/useAppAnalytics";
 import { useAppValidation } from "lib/hooks/useAppValidation";
+import { useCluster } from "lib/hooks/useCluster";
 import {
   useDefaultDeploymentTarget,
   useDeploymentTargetList,
@@ -216,6 +217,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
     creating: true,
   });
   const { currentClusterResources } = useClusterResources();
+  const { cluster } = useCluster({ clusterId: currentCluster?.id });
 
   // set the deployment target id to the default if no deployment target has been selected yet
   useEffect(() => {
@@ -361,12 +363,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
         setIsDeploying(false);
       }
     },
-    [
-      currentProject?.id,
-      currentCluster?.id,
-      deploymentTargetID,
-      name.value,
-    ]
+    [currentProject?.id, currentCluster?.id, deploymentTargetID, name.value]
   );
 
   useEffect(() => {
@@ -725,6 +722,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
                     <ServiceList
                       addNewText={"Add a new service"}
                       fieldArrayName={"app.services"}
+                      cluster={cluster}
                     />
                   </>,
                   <>

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

@@ -29,8 +29,10 @@ const GPUResources: React.FC<Props> = ({ index, cluster }) => {
   const { control } = useFormContext<PorterAppFormData>();
 
   const canEnableGPU = useMemo(() => {
-    return cluster?.contract.config.cluster.config.nodeGroups.some(
-      (ng) => ng.nodeGroupType === "CUSTOM"
+    return (
+      cluster.contract.config.cluster.config.nodeGroups.some(
+        (ng) => ng.nodeGroupType === "CUSTOM"
+      ) && cluster.contract.condition === "SUCCESS"
     );
   }, [cluster]);
 
@@ -53,7 +55,7 @@ const GPUResources: React.FC<Props> = ({ index, cluster }) => {
                 checked={value.enabled.value}
                 disabled={clusterIsUpdating}
                 onChange={() => {
-                  if (!canEnableGPU) {
+                  if (!value.enabled.value && !canEnableGPU) {
                     setClusterModalVisible(true);
                     return;
                   }

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

@@ -10,13 +10,13 @@ import Spacer from "components/porter/Spacer";
 import Text from "components/porter/Text";
 import {
   type ClientClusterContract,
-  type MachineType,
+  type ClientMachineType,
 } from "lib/clusters/types";
 
 import world from "assets/world.svg";
 
 type Props = {
-  availableMachineTypes: MachineType[];
+  availableMachineTypes: ClientMachineType[];
 };
 const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
   const { control } = useFormContext<ClientClusterContract>();