mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use .status.phase instead of computing it for Pod.getStatusMessage
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a399b8ee20
commit
ca8000544d
@ -165,40 +165,40 @@ interface IContainerProbe {
|
|||||||
failureThreshold?: number;
|
failureThreshold?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ContainerStateRunning {
|
||||||
|
startedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContainerStateWaiting {
|
||||||
|
reason: string;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContainerStateTerminated {
|
||||||
|
startedAt: string;
|
||||||
|
finishedAt: string;
|
||||||
|
exitCode: number;
|
||||||
|
reason: string;
|
||||||
|
containerID?: string;
|
||||||
|
message?: string;
|
||||||
|
signal?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContainerState holds a possible state of container. Only one of its members
|
||||||
|
* may be specified. If none of them is specified, the default one is
|
||||||
|
* `ContainerStateWaiting`.
|
||||||
|
*/
|
||||||
|
export interface ContainerState {
|
||||||
|
running?: ContainerStateRunning;
|
||||||
|
waiting?: ContainerStateWaiting;
|
||||||
|
terminated?: ContainerStateTerminated;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IPodContainerStatus {
|
export interface IPodContainerStatus {
|
||||||
name: string;
|
name: string;
|
||||||
state?: {
|
state?: ContainerState;
|
||||||
[index: string]: object;
|
lastState?: ContainerState;
|
||||||
running?: {
|
|
||||||
startedAt: string;
|
|
||||||
};
|
|
||||||
waiting?: {
|
|
||||||
reason: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
terminated?: {
|
|
||||||
startedAt: string;
|
|
||||||
finishedAt: string;
|
|
||||||
exitCode: number;
|
|
||||||
reason: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
lastState?: {
|
|
||||||
[index: string]: object;
|
|
||||||
running?: {
|
|
||||||
startedAt: string;
|
|
||||||
};
|
|
||||||
waiting?: {
|
|
||||||
reason: string;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
terminated?: {
|
|
||||||
startedAt: string;
|
|
||||||
finishedAt: string;
|
|
||||||
exitCode: number;
|
|
||||||
reason: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
ready: boolean;
|
ready: boolean;
|
||||||
restartCount: number;
|
restartCount: number;
|
||||||
image: string;
|
image: string;
|
||||||
@ -373,23 +373,16 @@ export class Pod extends WorkloadKubeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns pod phase or container error if occurred
|
// Returns pod phase or container error if occurred
|
||||||
getStatusMessage() {
|
getStatusMessage(): string {
|
||||||
if (this.getReason() === PodStatus.EVICTED) return "Evicted";
|
if (this.getReason() === PodStatus.EVICTED) {
|
||||||
if (this.metadata.deletionTimestamp) return "Terminating";
|
return "Evicted";
|
||||||
|
|
||||||
const statuses = this.getContainerStatuses(false); // not including initContainers
|
|
||||||
|
|
||||||
for (const { state } of statuses.reverse()) {
|
|
||||||
if (state.waiting) {
|
|
||||||
return state.waiting.reason || "Waiting";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.terminated) {
|
|
||||||
return state.terminated.reason || "Terminated";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getStatusPhase();
|
if (this.metadata.deletionTimestamp) {
|
||||||
|
return "Terminating";
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getStatusPhase() || "Waiting";
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusPhase() {
|
getStatusPhase() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user