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 (#4286)
This commit is contained in:
parent
b52bd29784
commit
200061d386
@ -165,40 +165,40 @@ interface IContainerProbe {
|
||||
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 {
|
||||
name: string;
|
||||
state?: {
|
||||
[index: string]: object;
|
||||
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;
|
||||
};
|
||||
};
|
||||
state?: ContainerState;
|
||||
lastState?: ContainerState;
|
||||
ready: boolean;
|
||||
restartCount: number;
|
||||
image: string;
|
||||
@ -373,23 +373,16 @@ export class Pod extends WorkloadKubeObject {
|
||||
}
|
||||
|
||||
// Returns pod phase or container error if occurred
|
||||
getStatusMessage() {
|
||||
if (this.getReason() === PodStatus.EVICTED) return "Evicted";
|
||||
if (this.metadata.deletionTimestamp) return "Terminating";
|
||||
|
||||
const statuses = this.getContainerStatuses(false); // not including initContainers
|
||||
|
||||
for (const { state } of statuses.reverse()) {
|
||||
if (state.waiting) {
|
||||
return state.waiting.reason || "Waiting";
|
||||
getStatusMessage(): string {
|
||||
if (this.getReason() === PodStatus.EVICTED) {
|
||||
return "Evicted";
|
||||
}
|
||||
|
||||
if (state.terminated) {
|
||||
return state.terminated.reason || "Terminated";
|
||||
}
|
||||
if (this.metadata.deletionTimestamp) {
|
||||
return "Terminating";
|
||||
}
|
||||
|
||||
return this.getStatusPhase();
|
||||
return this.getStatusPhase() || "Waiting";
|
||||
}
|
||||
|
||||
getStatusPhase() {
|
||||
|
||||
@ -69,7 +69,7 @@ export class Pods extends React.Component<Props> {
|
||||
formatters: {
|
||||
tableView: true,
|
||||
},
|
||||
children: Object.keys(state).map(status => (
|
||||
children: Object.keys(state).map((status: keyof typeof state) => (
|
||||
<Fragment key={status}>
|
||||
<div className="title">
|
||||
{name} <span className="text-secondary">({status}{ready ? ", ready" : ""})</span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user