mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cherry Pick bug fixes from v5.5.0-beta.2 (#5429)
This commit is contained in:
1 parent
a61a455fad
commit
d09816aacf
5 files changed
+86
-13
No files matched your search
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { cpuUnitsToNumber, unitsToBytes } from "../../../renderer/utils";
|
||||
import { cpuUnitsToNumber, unitsToBytes, isObject } from "../../../renderer/utils";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
@@ -69,6 +69,17 @@ export interface NodeCondition extends BaseKubeObjectCondition {
|
||||
lastHeartbeatTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* These role label prefixs are the ones that are for master nodes
|
||||
*
|
||||
* The `master` label has been deprecated in Kubernetes 1.20, and will be removed in 1.25 so we
|
||||
* have to also use the newer `control-plane` label
|
||||
*/
|
||||
const masterNodeLabels = [
|
||||
"master",
|
||||
"control-plane",
|
||||
];
|
||||
|
||||
/**
|
||||
* This regex is used in the `getRoleLabels()` method bellow, but placed here
|
||||
* as factoring out regexes is best practice.
|
||||
@@ -189,15 +200,19 @@ export class Node extends KubeObject<NodeStatus, NodeSpec, KubeObjectScope.Clust
|
||||
return this.spec.taints || [];
|
||||
}
|
||||
|
||||
getRoleLabels(): string {
|
||||
isMasterNode(): boolean {
|
||||
return this.getRoleLabelItems()
|
||||
.some(roleLabel => masterNodeLabels.includes(roleLabel));
|
||||
}
|
||||
|
||||
getRoleLabelItems(): string[] {
|
||||
const { labels } = this.metadata;
|
||||
|
||||
if (!labels || typeof labels !== "object") {
|
||||
return "";
|
||||
}
|
||||
|
||||
const roleLabels: string[] = [];
|
||||
|
||||
if (!isObject(labels)) {
|
||||
return roleLabels;
|
||||
}
|
||||
|
||||
for (const labelKey of Object.keys(labels)) {
|
||||
const match = nodeRoleLabelKeyMatcher.match(labelKey);
|
||||
|
||||
@@ -214,7 +229,11 @@ export class Node extends KubeObject<NodeStatus, NodeSpec, KubeObjectScope.Clust
|
||||
roleLabels.push(labels["node.kubernetes.io/role"]);
|
||||
}
|
||||
|
||||
return roleLabels.join(", ");
|
||||
return roleLabels;
|
||||
}
|
||||
|
||||
getRoleLabels(): string {
|
||||
return this.getRoleLabelItems().join(", ");
|
||||
}
|
||||
|
||||
getCpuCapacity() {
|
||||
|
||||
Reference in new issue
Block a user