1
0
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:
Sebastian Malton 2021-04-29 05:25:44 -04:00 committed by GitHub
parent 0a604201d4
commit f61f768fc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 3 deletions

View File

@ -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");
});
});
});

View File

@ -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"
);
) ?? [];
}
/**