Commit 1e48f5b4 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #45788 from zhangxiaoyu-zidif/describe-pod-node-nil

Automatic merge from submit-queue (batch tested with PRs 45171, 43947, 45788, 45822, 45808) Display <none> for kubectl describe pod when node is empty. **What this PR does / why we need it**: Display <none> for kubectl describe pod when node is empty. **Special notes for your reviewer**: refer to #45572 **Release note**: ```release-note NONE ```
parents 5b417e44 de64f526
...@@ -604,7 +604,11 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) { ...@@ -604,7 +604,11 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
w := NewPrefixWriter(out) w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%s\n", pod.Name) w.Write(LEVEL_0, "Name:\t%s\n", pod.Name)
w.Write(LEVEL_0, "Namespace:\t%s\n", pod.Namespace) w.Write(LEVEL_0, "Namespace:\t%s\n", pod.Namespace)
w.Write(LEVEL_0, "Node:\t%s\n", pod.Spec.NodeName+"/"+pod.Status.HostIP) if pod.Spec.NodeName == "" {
w.Write(LEVEL_0, "Node:\t<none>\n")
} else {
w.Write(LEVEL_0, "Node:\t%s\n", pod.Spec.NodeName+"/"+pod.Status.HostIP)
}
if pod.Status.StartTime != nil { if pod.Status.StartTime != nil {
w.Write(LEVEL_0, "Start Time:\t%s\n", pod.Status.StartTime.Time.Format(time.RFC1123Z)) w.Write(LEVEL_0, "Start Time:\t%s\n", pod.Status.StartTime.Time.Format(time.RFC1123Z))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment