From 53e65b0826b3f4a4455c3e4fd420471cb25ee5a3 Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Tue, 6 Oct 2015 14:43:23 -0700 Subject: [PATCH] kubelet: fix mirror pod creation/deletion When annotating the mirror pod, make a new copy of the annotations map from the static pod, so that the change wouldn't be in the static pod. --- pkg/kubelet/mirror_client.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/mirror_client.go b/pkg/kubelet/mirror_client.go index e53cf51f63e..f692e69edb3 100644 --- a/pkg/kubelet/mirror_client.go +++ b/pkg/kubelet/mirror_client.go @@ -47,9 +47,16 @@ func (mc *basicMirrorClient) CreateMirrorPod(pod *api.Pod) error { if mc.apiserverClient == nil { return nil } - pod.Annotations[ConfigMirrorAnnotationKey] = MirrorType + // Make a copy of the pod. + copyPod := *pod + copyPod.Annotations = make(map[string]string) - _, err := mc.apiserverClient.Pods(pod.Namespace).Create(pod) + for k, v := range pod.Annotations { + copyPod.Annotations[k] = v + } + copyPod.Annotations[ConfigMirrorAnnotationKey] = MirrorType + + _, err := mc.apiserverClient.Pods(copyPod.Namespace).Create(©Pod) return err }