mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #21661 from AdoHe/describe_container_status_optional
make show status in describe.DescribeContainers optional
This commit is contained in:
commit
97bae1099b
@ -731,13 +731,16 @@ func DescribeContainers(containers []api.Container, containerStatuses []api.Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
status := statuses[container.Name]
|
status, ok := statuses[container.Name]
|
||||||
state := status.State
|
|
||||||
|
|
||||||
fmt.Fprintf(out, " %v:\n", container.Name)
|
fmt.Fprintf(out, " %v:\n", container.Name)
|
||||||
fmt.Fprintf(out, " Container ID:\t%s\n", status.ContainerID)
|
if ok {
|
||||||
|
fmt.Fprintf(out, " Container ID:\t%s\n", status.ContainerID)
|
||||||
|
}
|
||||||
fmt.Fprintf(out, " Image:\t%s\n", container.Image)
|
fmt.Fprintf(out, " Image:\t%s\n", container.Image)
|
||||||
fmt.Fprintf(out, " Image ID:\t%s\n", status.ImageID)
|
if ok {
|
||||||
|
fmt.Fprintf(out, " Image ID:\t%s\n", status.ImageID)
|
||||||
|
}
|
||||||
|
|
||||||
if len(container.Command) > 0 {
|
if len(container.Command) > 0 {
|
||||||
fmt.Fprintf(out, " Command:\n")
|
fmt.Fprintf(out, " Command:\n")
|
||||||
@ -774,12 +777,14 @@ func DescribeContainers(containers []api.Container, containerStatuses []api.Cont
|
|||||||
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
|
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
describeStatus("State", state, out)
|
if ok {
|
||||||
if status.LastTerminationState.Terminated != nil {
|
describeStatus("State", status.State, out)
|
||||||
describeStatus("Last State", status.LastTerminationState, out)
|
if status.LastTerminationState.Terminated != nil {
|
||||||
|
describeStatus("Last State", status.LastTerminationState, out)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(out, " Ready:\t%v\n", printBool(status.Ready))
|
||||||
|
fmt.Fprintf(out, " Restart Count:\t%d\n", status.RestartCount)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, " Ready:\t%v\n", printBool(status.Ready))
|
|
||||||
fmt.Fprintf(out, " Restart Count:\t%d\n", status.RestartCount)
|
|
||||||
|
|
||||||
if container.LivenessProbe != nil {
|
if container.LivenessProbe != nil {
|
||||||
probe := DescribeProbe(container.LivenessProbe)
|
probe := DescribeProbe(container.LivenessProbe)
|
||||||
|
Loading…
Reference in New Issue
Block a user