From 1ffc82dfe652c1420f2c503de20d354bcffa6ccf Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Thu, 23 Oct 2014 16:55:12 -0400 Subject: [PATCH] createPod should copy the labels, not edit them in place --- pkg/controller/replication_controller.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/controller/replication_controller.go b/pkg/controller/replication_controller.go index afae3ef9d6..1e67a8d640 100644 --- a/pkg/controller/replication_controller.go +++ b/pkg/controller/replication_controller.go @@ -53,18 +53,20 @@ type RealPodControl struct { } func (r RealPodControl) createReplica(ctx api.Context, controllerSpec api.ReplicationController) { - labels := controllerSpec.DesiredState.PodTemplate.Labels - // TODO: don't fail to set this label just because the map isn't created. - if labels != nil { - labels["replicationController"] = controllerSpec.Name + desiredLabels := make(labels.Set) + for k, v := range controllerSpec.DesiredState.PodTemplate.Labels { + desiredLabels[k] = v } + desiredLabels["replicationController"] = controllerSpec.Name + pod := &api.Pod{ + ObjectMeta: api.ObjectMeta{ + Labels: desiredLabels, + }, DesiredState: controllerSpec.DesiredState.PodTemplate.DesiredState, - Labels: controllerSpec.DesiredState.PodTemplate.Labels, } - _, err := r.kubeClient.CreatePod(ctx, pod) - if err != nil { - glog.Errorf("%#v\n", err) + if _, err := r.kubeClient.CreatePod(ctx, pod); err != nil { + glog.Errorf("Unable to create pod replica: %v", err) } }