Commit ccecc59f authored by Chao Xu's avatar Chao Xu

In kubelet's handler of pod update, prints out deletiontimestamp if it's not nil

parent 85b67f2f
...@@ -2638,7 +2638,7 @@ func (kl *Kubelet) syncLoopIteration(configCh <-chan kubetypes.PodUpdate, handle ...@@ -2638,7 +2638,7 @@ func (kl *Kubelet) syncLoopIteration(configCh <-chan kubetypes.PodUpdate, handle
// once we have checkpointing. // once we have checkpointing.
handler.HandlePodAdditions(u.Pods) handler.HandlePodAdditions(u.Pods)
case kubetypes.UPDATE: case kubetypes.UPDATE:
glog.V(2).Infof("SyncLoop (UPDATE, %q): %q", u.Source, format.Pods(u.Pods)) glog.V(2).Infof("SyncLoop (UPDATE, %q): %q", u.Source, format.PodsWithDeletiontimestamps(u.Pods))
handler.HandlePodUpdates(u.Pods) handler.HandlePodUpdates(u.Pods)
case kubetypes.REMOVE: case kubetypes.REMOVE:
glog.V(2).Infof("SyncLoop (REMOVE, %q): %q", u.Source, format.Pods(u.Pods)) glog.V(2).Infof("SyncLoop (REMOVE, %q): %q", u.Source, format.Pods(u.Pods))
......
...@@ -19,6 +19,7 @@ package format ...@@ -19,6 +19,7 @@ package format
import ( import (
"fmt" "fmt"
"strings" "strings"
"time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
) )
...@@ -33,12 +34,28 @@ func Pod(pod *api.Pod) string { ...@@ -33,12 +34,28 @@ func Pod(pod *api.Pod) string {
return fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.UID) return fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.UID)
} }
// PodWithDeletionTimestamp is the same as Pod. In addition, it prints the
// deletion timestamp of the pod if it's not nil.
func PodWithDeletionTimestamp(pod *api.Pod) string {
var deletionTimestamp string
if pod.DeletionTimestamp != nil {
deletionTimestamp = ":DeletionTimestamp=" + pod.DeletionTimestamp.UTC().Format(time.RFC3339)
}
return Pod(pod) + deletionTimestamp
}
// Pods returns a string representating a list of pods in a human // Pods returns a string representating a list of pods in a human
// readable format. // readable format.
func Pods(pods []*api.Pod) string { func Pods(pods []*api.Pod) string {
return aggregatePods(pods, Pod) return aggregatePods(pods, Pod)
} }
// PodsWithDeletiontimestamps is the same as Pods. In addition, it prints the
// deletion timestamps of the pods if they are not nil.
func PodsWithDeletiontimestamps(pods []*api.Pod) string {
return aggregatePods(pods, PodWithDeletionTimestamp)
}
func aggregatePods(pods []*api.Pod, handler podHandler) string { func aggregatePods(pods []*api.Pod, handler podHandler) string {
podStrings := make([]string, 0, len(pods)) podStrings := make([]string, 0, len(pods))
for _, pod := range pods { for _, pod := range pods {
......
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