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;
|
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) {
|
if (this.metadata.deletionTimestamp) {
|
||||||
return state.terminated.reason || "Terminated";
|
return "Terminating";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getStatusPhase();
|
return this.getStatusPhase() || "Waiting";
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusPhase() {
|
getStatusPhase() {
|
||||||
|
|||||||
@ -69,7 +69,7 @@ export class Pods extends React.Component<Props> {
|
|||||||
formatters: {
|
formatters: {
|
||||||
tableView: true,
|
tableView: true,
|
||||||
},
|
},
|
||||||
children: Object.keys(state).map(status => (
|
children: Object.keys(state).map((status: keyof typeof state) => (
|
||||||
<Fragment key={status}>
|
<Fragment key={status}>
|
||||||
<div className="title">
|
<div className="title">
|
||||||
{name} <span className="text-secondary">({status}{ready ? ", ready" : ""})</span>
|
{name} <span className="text-secondary">({status}{ready ? ", ready" : ""})</span>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user