mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Updating PodDetailsContainerMetrics to support fetching metrics for Pods that have multiple containers
Signed-off-by: John Daly <john.daly2@gmail.com>
This commit is contained in:
1 parent
4ab97d2372
commit
6e8e58eaf9
3 files changed
+15
-8
No files matched your search
+10
-3
@@ -5,9 +5,14 @@
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { asyncComputed } from "@ogre-tools/injectable-react";
|
||||
import { now } from "mobx-utils";
|
||||
import type { Pod } from "@k8slens/kube-object";
|
||||
import type { Pod, Container } from "@k8slens/kube-object";
|
||||
import requestPodMetricsInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-pod-metrics.injectable";
|
||||
|
||||
interface PodContainerParams {
|
||||
pod: Pod;
|
||||
container: Container;
|
||||
}
|
||||
|
||||
const podContainerMetricsInjectable = getInjectable({
|
||||
id: "pod-container-metrics",
|
||||
instantiate: (di, pod) => {
|
||||
@@ -17,12 +22,14 @@ const podContainerMetricsInjectable = getInjectable({
|
||||
getValueFromObservedPromise: () => {
|
||||
now(60 * 1000);
|
||||
|
||||
return requestPodMetrics([pod], pod.getNs(), "container, namespace");
|
||||
return requestPodMetrics([pod], pod.getNs(), container, "pod, container, namespace");
|
||||
},
|
||||
});
|
||||
},
|
||||
lifecycle: lifecycleEnum.keyedSingleton({
|
||||
getInstanceKey: (di, pod: Pod) => pod.getId(),
|
||||
getInstanceKey: (di, { pod, container }: PodContainerParams) => {
|
||||
return `${pod.getId()}-${container.name}`;
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -48,6 +48,6 @@ const NonInjectedPodDetailsContainerMetrics = observer(({ pod, container, podCon
|
||||
export const PodDetailsContainerMetrics = withInjectables<Dependencies, ContainerMetricsProps>(NonInjectedPodDetailsContainerMetrics, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
podContainerMetrics: di.inject(podContainerMetricsInjectable, props.pod),
|
||||
podContainerMetrics: di.inject(podContainerMetricsInjectable, { pod: props.pod, container: props.container }),
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user