From 4f08c0b69626f322645655cad6e4f3333982fb81 Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Fri, 5 Apr 2024 14:28:18 -0400 Subject: [PATCH] show placeholder for no job metrics (#4504) --- .../app-view/tabs/MetricsTab.tsx | 4 +-- .../validate-apply/metrics/MetricsSection.tsx | 28 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dashboard/src/main/home/app-dashboard/app-view/tabs/MetricsTab.tsx b/dashboard/src/main/home/app-dashboard/app-view/tabs/MetricsTab.tsx index 6106f87787..e9d74e8fa3 100644 --- a/dashboard/src/main/home/app-dashboard/app-view/tabs/MetricsTab.tsx +++ b/dashboard/src/main/home/app-dashboard/app-view/tabs/MetricsTab.tsx @@ -17,9 +17,9 @@ const MetricsTab: React.FC = () => { projectId={projectId} clusterId={clusterId} appName={appName} - // we do not yet support metrics for jobs services={latestClientServices.filter( - (svc) => svc.config.type !== "predeploy" && svc.config.type !== "job" + (svc) => + svc.config.type !== "predeploy" && svc.config.type !== "initdeploy" )} deploymentTargetId={deploymentTarget.id} /> diff --git a/dashboard/src/main/home/app-dashboard/validate-apply/metrics/MetricsSection.tsx b/dashboard/src/main/home/app-dashboard/validate-apply/metrics/MetricsSection.tsx index 7ff9ce3b29..6000edb0e2 100644 --- a/dashboard/src/main/home/app-dashboard/validate-apply/metrics/MetricsSection.tsx +++ b/dashboard/src/main/home/app-dashboard/validate-apply/metrics/MetricsSection.tsx @@ -6,7 +6,10 @@ import { match } from "ts-pattern"; import CheckboxRow from "components/CheckboxRow"; import Loading from "components/Loading"; +import Container from "components/porter/Container"; +import Fieldset from "components/porter/Fieldset"; import Filter from "components/porter/Filter"; +import Text from "components/porter/Text"; import TabSelector from "components/TabSelector"; import { type AvailableMetrics, @@ -109,12 +112,10 @@ const MetricsSection: React.FunctionComponent = ({ const serviceName = `${appName}-${service.name.value}`; - let serviceKind = ""; const metricTypes: MetricType[] = ["cpu", "memory"]; let isHpaEnabled = false; if (service.config.type === "web" || service.config.type === "worker") { - serviceKind = service.config.type === "web" ? "web" : "worker"; if (service.config.autoscaling?.enabled.value) { isHpaEnabled = true; } @@ -128,7 +129,7 @@ const MetricsSection: React.FunctionComponent = ({ metricTypes.push("replicas"); - return [serviceName, serviceKind, metricTypes, isHpaEnabled]; + return [serviceName, service.config.type, metricTypes, isHpaEnabled]; }, [selectedFilterValues.service_name]); const { @@ -148,6 +149,7 @@ const MetricsSection: React.FunctionComponent = ({ if ( serviceName === "" || serviceKind === "" || + serviceKind === "job" || metricTypes.length === 0 ) { return; @@ -245,7 +247,7 @@ const MetricsSection: React.FunctionComponent = ({ hpaData.push(...autoscalingMetrics.getParsedData()); } - const metric: Metric = match(metricType) + const metric: Metric | undefined = match(metricType) .with("cpu", () => ({ type: metricType, label: "CPU Utilization (vCPUs)", @@ -281,8 +283,10 @@ const MetricsSection: React.FunctionComponent = ({ aggregatedData: allPodsAggregatedData, hpaData, })) - .exhaustive(); - metrics.push(metric); + .otherwise(() => undefined); + if (metric) { + metrics.push(metric); + } } } return metrics; @@ -363,7 +367,17 @@ const MetricsSection: React.FunctionComponent = ({ /> - {renderMetrics()} + {serviceKind === "job" ? ( +
+ + + Metrics are not currently supported for jobs. + + +
+ ) : ( + renderMetrics() + )} ); };