kubelet: clear current pod records before relist

This commit is contained in:
Random-Liu 2016-02-28 13:00:29 -08:00
parent 388689238b
commit 96eeb812ff

View File

@ -165,9 +165,7 @@ func (g *GenericPLEG) relist() {
return return
} }
pods := kubecontainer.Pods(podList) pods := kubecontainer.Pods(podList)
for _, pod := range pods { g.podRecords.setCurrent(pods)
g.podRecords.setCurrent(pod)
}
// Compare the old and the current pods, and generate events. // Compare the old and the current pods, and generate events.
eventsByPodID := map[types.UID][]*PodLifecycleEvent{} eventsByPodID := map[types.UID][]*PodLifecycleEvent{}
@ -308,12 +306,17 @@ func (pr podRecords) getCurrent(id types.UID) *kubecontainer.Pod {
return r.current return r.current
} }
func (pr podRecords) setCurrent(pod *kubecontainer.Pod) { func (pr podRecords) setCurrent(pods []*kubecontainer.Pod) {
if r, ok := pr[pod.ID]; ok { for i := range pr {
r.current = pod pr[i].current = nil
return }
for _, pod := range pods {
if r, ok := pr[pod.ID]; ok {
r.current = pod
} else {
pr[pod.ID] = &podRecord{current: pod}
}
} }
pr[pod.ID] = &podRecord{current: pod}
} }
func (pr podRecords) update(id types.UID) { func (pr podRecords) update(id types.UID) {