From 871424368f52ac624489f5be99a70fa6e218d1f8 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Fri, 11 Oct 2019 15:45:33 -0700 Subject: [PATCH] Fix pod status updates for when pod is updated outside of VK Pods can be updated outside of VK. Right now, if this happens, pod status updates are dropped because the resourceversion from the provider will mismatch with what's on the server, breaking pod status updates. Since we're the only ones writing to the pod status, we can do a blind overwrite. --- node/pod.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/pod.go b/node/pod.go index bd2a901e9..0f20f6075 100644 --- a/node/pod.go +++ b/node/pod.go @@ -213,8 +213,12 @@ func (pc *PodController) updatePodStatus(ctx context.Context, podFromKubernetes } kPod := obj.(*knownPod) kPod.Lock() - podFromProvider := kPod.lastPodStatusReceivedFromProvider + podFromProvider := kPod.lastPodStatusReceivedFromProvider.DeepCopy() kPod.Unlock() + // We need to do this because the other parts of the pod can be updated elsewhere. Since we're only updating + // the pod status, and we should be the sole writers of the pod status, we can blind overwrite it. Therefore + // we need to copy the pod and set ResourceVersion to 0. + podFromProvider.ResourceVersion = "0" if _, err := pc.client.Pods(podFromKubernetes.Namespace).UpdateStatus(podFromProvider); err != nil { span.SetStatus(err)