mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Handle invalid metric response properly (#464)
* catch undefined and return default empty in normalizeMetrics * fix crash on drilldown Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
b9ddb503ee
commit
1752b8d3d9
5 files changed
+35
-18
No files matched your search
@@ -82,15 +82,15 @@ export class ClusterStore extends KubeObjectStore<Cluster> {
|
||||
this.liveMetrics = await this.loadMetrics({ start, end, step, range });
|
||||
}
|
||||
|
||||
getMetricsValues(source: Partial<IClusterMetrics>) {
|
||||
const metrics =
|
||||
this.metricType === MetricType.CPU ? source.cpuUsage :
|
||||
this.metricType === MetricType.MEMORY ? source.memoryUsage
|
||||
: null;
|
||||
if (!metrics) {
|
||||
getMetricsValues(source: Partial<IClusterMetrics>): [number, string][] {
|
||||
switch (this.metricType) {
|
||||
case MetricType.CPU:
|
||||
return normalizeMetrics(source.cpuUsage).data.result[0].values
|
||||
case MetricType.MEMORY:
|
||||
return normalizeMetrics(source.memoryUsage).data.result[0].values
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
return normalizeMetrics(metrics).data.result[0].values;
|
||||
}
|
||||
|
||||
resetMetrics() {
|
||||
|
||||
@@ -18,9 +18,9 @@ export const IngressCharts = observer(() => {
|
||||
if (!metrics) return null;
|
||||
if (isMetricsEmpty(metrics)) return <NoMetrics/>;
|
||||
|
||||
const values = Object.values(metrics).map(metric =>
|
||||
normalizeMetrics(metric).data.result[0].values
|
||||
);
|
||||
const values = Object.values(metrics)
|
||||
.map(normalizeMetrics)
|
||||
.map(({ data }) => data.result[0].values);
|
||||
const [
|
||||
bytesSentSuccess,
|
||||
bytesSentFailure,
|
||||
|
||||
@@ -17,9 +17,9 @@ export const ContainerCharts = () => {
|
||||
if (!metrics) return null;
|
||||
if (isMetricsEmpty(metrics)) return <NoMetrics/>;
|
||||
|
||||
const values = Object.values(metrics).map(metric =>
|
||||
normalizeMetrics(metric).data.result[0].values
|
||||
);
|
||||
const values = Object.values(metrics)
|
||||
.map(normalizeMetrics)
|
||||
.map(({ data }) => data.result[0].values);
|
||||
const [
|
||||
cpuUsage,
|
||||
cpuRequests,
|
||||
|
||||
@@ -28,9 +28,9 @@ export const PodCharts = observer(() => {
|
||||
if (isMetricsEmpty(metrics)) return <NoMetrics/>;
|
||||
|
||||
const options = tabId == 0 ? cpuOptions : memoryOptions;
|
||||
const values = Object.values(metrics).map(metric =>
|
||||
normalizeMetrics(metric).data.result[0].values
|
||||
);
|
||||
const values = Object.values(metrics)
|
||||
.map(normalizeMetrics)
|
||||
.map(({ data }) => data.result[0].values);
|
||||
const [
|
||||
cpuUsage,
|
||||
cpuRequests,
|
||||
|
||||
Reference in new issue
Block a user