mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix getNodeWarningConditions (#2644)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
0a604201d4
commit
f61f768fc7
@ -1,5 +1,5 @@
|
||||
import { KubeConfig } from "@kubernetes/client-node";
|
||||
import { validateKubeConfig, loadConfig } from "../kube-helpers";
|
||||
import { validateKubeConfig, loadConfig, getNodeWarningConditions } from "../kube-helpers";
|
||||
|
||||
const kubeconfig = `
|
||||
apiVersion: v1
|
||||
@ -251,4 +251,43 @@ describe("kube helpers", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getNodeWarningConditions", () => {
|
||||
it("should return an empty array if no status or no conditions", () => {
|
||||
expect(getNodeWarningConditions({}).length).toBe(0);
|
||||
});
|
||||
|
||||
it("should return an empty array if all conditions are good", () => {
|
||||
expect(getNodeWarningConditions({
|
||||
status: {
|
||||
conditions: [
|
||||
{
|
||||
type: "Ready",
|
||||
status: "foobar"
|
||||
}
|
||||
]
|
||||
}
|
||||
}).length).toBe(0);
|
||||
});
|
||||
|
||||
it("should all not ready conditions", () => {
|
||||
const conds = getNodeWarningConditions({
|
||||
status: {
|
||||
conditions: [
|
||||
{
|
||||
type: "Ready",
|
||||
status: "foobar"
|
||||
},
|
||||
{
|
||||
type: "NotReady",
|
||||
status: "true"
|
||||
},
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
expect(conds.length).toBe(1);
|
||||
expect(conds[0].type).toBe("NotReady");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -174,9 +174,9 @@ export function podHasIssues(pod: V1Pod) {
|
||||
}
|
||||
|
||||
export function getNodeWarningConditions(node: V1Node) {
|
||||
return node.status.conditions.filter(c =>
|
||||
return node.status?.conditions?.filter(c =>
|
||||
c.status.toLowerCase() === "true" && c.type !== "Ready" && c.type !== "HostUpgrades"
|
||||
);
|
||||
) ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user