mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
kubelet: clear current pod records before relist
This commit is contained in:
parent
388689238b
commit
96eeb812ff
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user