Copy deployment's annotations to its RC
This commit is contained in:
@@ -34,7 +34,6 @@ import (
|
||||
unversioned_legacy "k8s.io/kubernetes/pkg/client/typed/generated/legacy/unversioned"
|
||||
"k8s.io/kubernetes/pkg/controller"
|
||||
"k8s.io/kubernetes/pkg/controller/framework"
|
||||
"k8s.io/kubernetes/pkg/kubectl"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
deploymentutil "k8s.io/kubernetes/pkg/util/deployment"
|
||||
@@ -679,9 +678,21 @@ func (dc *DeploymentController) getNewRC(deployment extensions.Deployment, maxOl
|
||||
if existingNewRC.Annotations == nil {
|
||||
existingNewRC.Annotations = make(map[string]string)
|
||||
}
|
||||
// Copy deployment's annotations to existing new RC
|
||||
annotationChanged := false
|
||||
for k, v := range deployment.Annotations {
|
||||
if existingNewRC.Annotations[k] != v {
|
||||
annotationChanged = true
|
||||
existingNewRC.Annotations[k] = v
|
||||
}
|
||||
}
|
||||
// Update existing new RC's revision annotation
|
||||
if existingNewRC.Annotations[deploymentutil.RevisionAnnotation] != newRevision {
|
||||
existingNewRC.Annotations[deploymentutil.RevisionAnnotation] = newRevision
|
||||
annotationChanged = true
|
||||
glog.V(4).Infof("update existingNewRC %s revision to %s - %+v\n", existingNewRC.Name, newRevision)
|
||||
}
|
||||
if annotationChanged {
|
||||
return dc.client.Legacy().ReplicationControllers(deployment.ObjectMeta.Namespace).Update(existingNewRC)
|
||||
}
|
||||
return existingNewRC, nil
|
||||
@@ -708,13 +719,20 @@ func (dc *DeploymentController) getNewRC(deployment extensions.Deployment, maxOl
|
||||
return nil, fmt.Errorf("couldn't get key for deployment controller %#v: %v", deployment, err)
|
||||
}
|
||||
dc.rcExpectations.ExpectCreations(dKey, 1)
|
||||
// Copy deployment's annotations to new RC
|
||||
annotations := deployment.Annotations
|
||||
if annotations == nil {
|
||||
annotations = make(map[string]string)
|
||||
}
|
||||
// Set new RC's revision annotation
|
||||
annotations[deploymentutil.RevisionAnnotation] = newRevision
|
||||
|
||||
// Create new RC
|
||||
newRC := api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
GenerateName: deployment.Name + "-",
|
||||
Namespace: namespace,
|
||||
Annotations: map[string]string{deploymentutil.RevisionAnnotation: newRevision},
|
||||
Annotations: annotations,
|
||||
},
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: 0,
|
||||
@@ -722,12 +740,6 @@ func (dc *DeploymentController) getNewRC(deployment extensions.Deployment, maxOl
|
||||
Template: &newRCTemplate,
|
||||
},
|
||||
}
|
||||
if _, ok := deployment.Annotations[kubectl.ChangeCauseAnnotation]; ok {
|
||||
if newRC.Annotations == nil {
|
||||
newRC.Annotations = make(map[string]string)
|
||||
}
|
||||
newRC.Annotations[kubectl.ChangeCauseAnnotation] = deployment.Annotations[kubectl.ChangeCauseAnnotation]
|
||||
}
|
||||
createdRC, err := dc.client.Legacy().ReplicationControllers(namespace).Create(&newRC)
|
||||
if err != nil {
|
||||
dc.rcExpectations.DeleteExpectations(dKey)
|
||||
|
Reference in New Issue
Block a user