Display <none> for kubectl describe pod when node is empty.

This commit is contained in:
zhangxiaoyu-zidif 2017-05-14 22:15:23 +08:00
parent 4807e6cadf
commit de64f52634

View File

@ -604,7 +604,11 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%s\n", pod.Name)
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 {
w.Write(LEVEL_0, "Start Time:\t%s\n", pod.Status.StartTime.Time.Format(time.RFC1123Z))
}