Skip to content

Commit

Permalink
remove beta features enabled, add cluster vanity name, id, remove del…
Browse files Browse the repository at this point in the history
…ete gpu (#4343)
  • Loading branch information
Feroze Mohideen authored Feb 28, 2024
1 parent 63cbe42 commit 300e76e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 107 deletions.
48 changes: 0 additions & 48 deletions api/server/handlers/project_integration/preflight_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions dashboard/src/components/ClusterProvisioningPlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +35,6 @@ const Resources: React.FC<ResourcesProps> = ({
maxRAM,
maxGPU,
service,
clusterContainsGPUNodes,
isPredeploy = false,
cluster,
}) => {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand All @@ -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, {
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
const {
fields: nodeGroups,
append,
remove,
// remove,
} = useFieldArray({
control,
name: "cluster.config.nodeGroups",
Expand Down Expand Up @@ -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();
Expand All @@ -147,7 +147,7 @@ const NodeGroups: React.FC<Props> = ({ availableMachineTypes }) => {
>
<span className="material-icons">delete</span>
</ActionButton>
</Container>
</Container> */}
</Container>
}
>
Expand Down Expand Up @@ -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;
// `;
3 changes: 1 addition & 2 deletions dashboard/src/main/home/onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/main/home/project-settings/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
</>
)
}
Expand Down
9 changes: 3 additions & 6 deletions dashboard/src/main/home/sidebar/ClusterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions dashboard/src/main/home/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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"
)}
Expand Down

0 comments on commit 300e76e

Please sign in to comment.