Merge pull request #36399 from mwielgus/fedrc1

Automatic merge from submit-queue

Make desired objects in fed controller reconcilation function fully writable

When creating desired objects for sub-cluster in reconciliate functions we don't make full copies. This may result in unexpected race condition in the future when someone actually adds some object modifications (not needed in most cases but anyway - the cost of extra copy will be relatively small comparing to inter-cluster traffic). In case of ReplicaSet and Deployment the spec copy was a shallow one - ok for setting just replicas but also error-prone in the future.

cc: @quinton-hoole @nikhiljindal @madhusudancs
This commit is contained in:
Kubernetes Submit Queue
2016-11-21 00:00:26 -08:00
committed by GitHub
10 changed files with 31 additions and 15 deletions

View File

@@ -391,9 +391,10 @@ func (nc *NamespaceController) reconcileNamespace(namespace string) {
nc.deliverNamespace(namespace, 0, true)
return
}
// The object should not be modified.
desiredNamespace := &api_v1.Namespace{
ObjectMeta: util.CopyObjectMeta(baseNamespace.ObjectMeta),
Spec: baseNamespace.Spec,
ObjectMeta: util.DeepCopyRelevantObjectMeta(baseNamespace.ObjectMeta),
Spec: util.DeepCopyApiTypeOrPanic(baseNamespace.Spec).(api_v1.NamespaceSpec),
}
glog.V(5).Infof("Desired namespace in underlying clusters: %+v", desiredNamespace)