Merge pull request #116482 from smarterclayton/no_mutate
kubelet: Do not mutate pods in the pod manager
This commit is contained in:
@@ -181,11 +181,14 @@ func (kl *Kubelet) GetPods() []*v1.Pod {
|
|||||||
pods := kl.podManager.GetPods()
|
pods := kl.podManager.GetPods()
|
||||||
// a kubelet running without apiserver requires an additional
|
// a kubelet running without apiserver requires an additional
|
||||||
// update of the static pod status. See #57106
|
// update of the static pod status. See #57106
|
||||||
for _, p := range pods {
|
for i, p := range pods {
|
||||||
if kubelettypes.IsStaticPod(p) {
|
if kubelettypes.IsStaticPod(p) {
|
||||||
if status, ok := kl.statusManager.GetPodStatus(p.UID); ok {
|
if status, ok := kl.statusManager.GetPodStatus(p.UID); ok {
|
||||||
klog.V(2).InfoS("Pod status updated", "pod", klog.KObj(p), "status", status.Phase)
|
klog.V(2).InfoS("Pod status updated", "pod", klog.KObj(p), "status", status.Phase)
|
||||||
|
// do not mutate the cache
|
||||||
|
p = p.DeepCopy()
|
||||||
p.Status = status
|
p.Status = status
|
||||||
|
pods[i] = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user