mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix memoryUsage display for Nodes
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f12851ff3b
commit
b1416f5f79
@ -21,7 +21,6 @@ import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
|||||||
import { Badge } from "../badge/badge";
|
import { Badge } from "../badge/badge";
|
||||||
import { eventStore } from "../+events/legacy-store";
|
import { eventStore } from "../+events/legacy-store";
|
||||||
import { makeObservable, observable } from "mobx";
|
import { makeObservable, observable } from "mobx";
|
||||||
import isEmpty from "lodash/isEmpty";
|
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
@ -48,7 +47,7 @@ interface UsageArgs {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class NodesRoute extends React.Component {
|
export class NodesRoute extends React.Component {
|
||||||
@observable.ref metrics: Partial<NodeMetricData> = {};
|
@observable.ref metrics?: NodeMetricData;
|
||||||
private metricsWatcher = interval(30, async () => this.metrics = await getMetricsForAllNodes());
|
private metricsWatcher = interval(30, async () => this.metrics = await getMetricsForAllNodes());
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
@ -65,7 +64,9 @@ export class NodesRoute extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getLastMetricValues(node: Node, metricNames: string[]): number[] {
|
getLastMetricValues(node: Node, metricNames: string[]): number[] {
|
||||||
if (isEmpty(this.metrics)) {
|
const { metrics } = this;
|
||||||
|
|
||||||
|
if (!metrics) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ export class NodesRoute extends React.Component {
|
|||||||
|
|
||||||
return metricNames.map(metricName => {
|
return metricNames.map(metricName => {
|
||||||
try {
|
try {
|
||||||
const metric = this.metrics[metricName];
|
const metric = metrics[metricName];
|
||||||
const result = metric?.data.result.find(({ metric: { node, instance, kubernetes_node }}) => (
|
const result = metric?.data.result.find(({ metric: { node, instance, kubernetes_node }}) => (
|
||||||
nodeName === node
|
nodeName === node
|
||||||
|| nodeName === instance
|
|| nodeName === instance
|
||||||
@ -124,7 +125,7 @@ export class NodesRoute extends React.Component {
|
|||||||
return this.renderUsage({
|
return this.renderUsage({
|
||||||
node,
|
node,
|
||||||
title: "Memory",
|
title: "Memory",
|
||||||
metricNames: ["workloadMemoryUsage", "memoryAllocatableCapacity"],
|
metricNames: ["memoryUsage", "memoryAllocatableCapacity"],
|
||||||
formatters: [
|
formatters: [
|
||||||
([usage, capacity]) => `${(usage * 100 / capacity).toFixed(2)}%`,
|
([usage, capacity]) => `${(usage * 100 / capacity).toFixed(2)}%`,
|
||||||
([usage]) => bytesToUnits(usage, { precision: 3 }),
|
([usage]) => bytesToUnits(usage, { precision: 3 }),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user