Skip to content

Commit

Permalink
Merge pull request operator-framework#585 from njhale/fix-mod-checksum
Browse files Browse the repository at this point in the history
fix(annotations): merge CSV and pod template annotations when installing deployments
  • Loading branch information
njhale authored Dec 3, 2018
2 parents 79d44e0 + c1c9327 commit 2b9b5a9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
12 changes: 11 additions & 1 deletion pkg/controller/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ func (i *StrategyDeploymentInstaller) installDeployments(deps []StrategyDeployme
dep := &appsv1.Deployment{Spec: d.Spec}
dep.SetName(d.Name)
dep.SetNamespace(i.owner.GetNamespace())
dep.Spec.Template.SetAnnotations(i.templateAnnotations)

// Merge annotations (to avoid losing info from pod template)
annotations := map[string]string{}
for k, v := range i.templateAnnotations {
annotations[k] = v
}
for k, v := range dep.Spec.Template.GetAnnotations() {
annotations[k] = v
}
dep.Spec.Template.SetAnnotations(annotations)

ownerutil.AddNonBlockingOwner(dep, i.owner)
if dep.Labels == nil {
dep.SetLabels(map[string]string{})
Expand Down
23 changes: 22 additions & 1 deletion pkg/controller/install/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
"olm.owner.namespace": mockOwner.GetNamespace(),
},
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
},
},
},
returnError: nil,
},
Expand All @@ -185,6 +192,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
"olm.owner.namespace": mockOwner.GetNamespace(),
},
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
},
},
},
returnError: nil,
},
Expand All @@ -199,6 +213,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
"olm.owner.namespace": mockOwner.GetNamespace(),
},
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
},
},
},
returnError: nil,
},
Expand All @@ -215,7 +236,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
fakeClient.CreateDeploymentReturns(nil, m.returnError)
defer func(i int, expectedDeployment appsv1.Deployment) {
dep := fakeClient.CreateOrUpdateDeploymentArgsForCall(i)
require.Equal(t, expectedDeployment, *dep)
assert.Equal(t, expectedDeployment, *dep)
}(i, m.expectedDeployment)
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_e2e_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ trap cleanupAndExit SIGINT SIGTERM EXIT

# run tests
e2e_kubeconfig=${KUBECONFIG:-~/.kube/config}
KUBECONFIG=${e2e_kubeconfig} NAMESPACE=${namespace} go test -v -timeout 20m ./test/e2e/... ${1/[[:alnum:]-]*/-run ${1}}
KUBECONFIG=${e2e_kubeconfig} NAMESPACE=${namespace} go test -v -mod=vendor -timeout 20m ./test/e2e/... ${1/[[:alnum:]-]*/-run ${1}}

0 comments on commit 2b9b5a9

Please sign in to comment.