Quellcode durchsuchen

Case on run time in case job runned for less than 5 minutes

jnfrati vor 4 Jahren
Ursprung
Commit
27d868667f

+ 0 - 2
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -967,8 +967,6 @@ class ExpandedJobChart extends Component<PropsType, StateType> {
     let { currentChart } = this.state;
     let chart = currentChart;
     let run = this.state.expandedJobRun;
-    const runName = run?.metadata?.name;
-
     return (
       <StyledExpandedChart>
         <HeaderWrapper>

+ 30 - 8
dashboard/src/main/home/cluster-dashboard/expanded-chart/metrics/JobMetricsSection.tsx

@@ -197,7 +197,8 @@ const JobMetricsSection: React.FunctionComponent<PropsType> = ({
       let end = Math.round(
         new Date(jobRun?.status?.completionTime).getTime() / 1000
       );
-      if (jobRun?.status?.completionTime) {
+
+      if (!jobRun?.status?.completionTime) {
         end = Math.round(new Date().getTime() / 1000);
       }
 
@@ -333,6 +334,15 @@ const JobMetricsSection: React.FunctionComponent<PropsType> = ({
     );
   };
 
+  const hasJobRunnedForMoreThan5m = () => {
+    const firstDate = new Date(jobRun.status.startTime);
+    const secondDate = jobRun?.status?.completionTime
+      ? new Date(jobRun?.status?.completionTime)
+      : new Date();
+    const _5M_IN_MILISECONDS = 60000;
+    return secondDate.getTime() - firstDate.getTime() > _5M_IN_MILISECONDS;
+  };
+
   return (
     <StyledMetricsSection>
       <MetricsHeader>
@@ -371,13 +381,25 @@ const JobMetricsSection: React.FunctionComponent<PropsType> = ({
       </MetricsHeader>
       {isLoading > 0 && <Loading />}
       {data.length === 0 && isLoading === 0 && (
-        <Message>
-          No data available yet.
-          <Highlight color={"#8590ff"} onClick={getMetrics}>
-            <i className="material-icons">autorenew</i>
-            Refresh
-          </Highlight>
-        </Message>
+        <>
+          {selectedMetric === "cpu" && hasJobRunnedForMoreThan5m() ? (
+            <Message>
+              No data available yet.
+              <Highlight color={"#8590ff"} onClick={getMetrics}>
+                <i className="material-icons">autorenew</i>
+                Refresh
+              </Highlight>
+            </Message>
+          ) : (
+            <Message>
+              No data for this job run.
+              <Highlight color={"#8590ff"}>
+                This run went for less than 5 minutes, so we couldn't retrieve
+                any metrics.
+              </Highlight>
+            </Message>
+          )}
+        </>
       )}
       {data.length > 0 && isLoading === 0 && (
         <>