Skip to content

Commit ff0ea15

Browse files
authored
Merge pull request #585 from njhale/fix-mod-checksum
fix(annotations): merge CSV and pod template annotations when installing deployments
2 parents 3a2240f + 78e1788 commit ff0ea15

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

pkg/controller/install/deployment.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ func (i *StrategyDeploymentInstaller) installDeployments(deps []StrategyDeployme
6363
dep := &appsv1.Deployment{Spec: d.Spec}
6464
dep.SetName(d.Name)
6565
dep.SetNamespace(i.owner.GetNamespace())
66-
dep.Spec.Template.SetAnnotations(i.templateAnnotations)
66+
67+
// Merge annotations (to avoid losing info from pod template)
68+
annotations := map[string]string{}
69+
for k, v := range i.templateAnnotations {
70+
annotations[k] = v
71+
}
72+
for k, v := range dep.Spec.Template.GetAnnotations() {
73+
annotations[k] = v
74+
}
75+
dep.Spec.Template.SetAnnotations(annotations)
76+
6777
ownerutil.AddNonBlockingOwner(dep, i.owner)
6878
if dep.Labels == nil {
6979
dep.SetLabels(map[string]string{})

pkg/controller/install/deployment_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
171171
"olm.owner.namespace": mockOwner.GetNamespace(),
172172
},
173173
},
174+
Spec: appsv1.DeploymentSpec{
175+
Template: corev1.PodTemplateSpec{
176+
ObjectMeta: metav1.ObjectMeta{
177+
Annotations: map[string]string{},
178+
},
179+
},
180+
},
174181
},
175182
returnError: nil,
176183
},
@@ -185,6 +192,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
185192
"olm.owner.namespace": mockOwner.GetNamespace(),
186193
},
187194
},
195+
Spec: appsv1.DeploymentSpec{
196+
Template: corev1.PodTemplateSpec{
197+
ObjectMeta: metav1.ObjectMeta{
198+
Annotations: map[string]string{},
199+
},
200+
},
201+
},
188202
},
189203
returnError: nil,
190204
},
@@ -199,6 +213,13 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
199213
"olm.owner.namespace": mockOwner.GetNamespace(),
200214
},
201215
},
216+
Spec: appsv1.DeploymentSpec{
217+
Template: corev1.PodTemplateSpec{
218+
ObjectMeta: metav1.ObjectMeta{
219+
Annotations: map[string]string{},
220+
},
221+
},
222+
},
202223
},
203224
returnError: nil,
204225
},
@@ -215,7 +236,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
215236
fakeClient.CreateDeploymentReturns(nil, m.returnError)
216237
defer func(i int, expectedDeployment appsv1.Deployment) {
217238
dep := fakeClient.CreateOrUpdateDeploymentArgsForCall(i)
218-
require.Equal(t, expectedDeployment, *dep)
239+
assert.Equal(t, expectedDeployment, *dep)
219240
}(i, m.expectedDeployment)
220241
}
221242

scripts/run_e2e_local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ trap cleanupAndExit SIGINT SIGTERM EXIT
4242

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

0 commit comments

Comments
 (0)