Просмотр исходного кода

Fixed non existing autoscaling config

jnfrati 4 лет назад
Родитель
Сommit
a20d894a5e

+ 5 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/metrics/MetricsSection.tsx

@@ -83,7 +83,9 @@ const MetricsSection: React.FunctionComponent<PropsType> = ({
           (option) => option.value === "hpa_replicas"
         );
         const options = [...prev];
-        options.splice(hpaReplicasOptionIndex, 1);
+        if (hpaReplicasOptionIndex > -1) {
+          options.splice(hpaReplicasOptionIndex, 1);
+        }
         return [...options];
       });
     }
@@ -124,7 +126,6 @@ const MetricsSection: React.FunctionComponent<PropsType> = ({
         })
         .catch((err) => {
           setCurrentError(JSON.stringify(err));
-          setControllerOptions([]);
         })
         .finally(() => {
           setIsLoading((prev) => prev - 1);
@@ -309,7 +310,7 @@ const MetricsSection: React.FunctionComponent<PropsType> = ({
       );
 
       setHpaData([]);
-      const isHpaEnabled = currentChart.config.autoscaling.enabled;
+      const isHpaEnabled = currentChart?.config?.autoscaling?.enabled;
       if (shouldsum && isHpaEnabled) {
         if (selectedMetric === "cpu") {
           await getAutoscalingThreshold(
@@ -489,7 +490,7 @@ const MetricsSection: React.FunctionComponent<PropsType> = ({
           {currentChart?.config?.autoscaling?.enabled &&
             ["cpu", "memory"].includes(selectedMetric) && (
               <CheckboxRow
-                toggle={() => setHpaEnabled((prev) => !prev)}
+                toggle={() => setHpaEnabled((prev: any) => !prev)}
                 checked={hpaEnabled}
                 label="Show Autoscaling Threshold"
               />