Skip to content

Commit

Permalink
Add update condition
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelMue committed Dec 14, 2020
1 parent 44abb80 commit c8a4e19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions pkg/reconciler/v1alpha1/eventlistener/eventlistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ func (r *Reconciler) reconcileDeployment(ctx context.Context, logger *zap.Sugare
existingDeployment.Spec.Template.Spec.Volumes = deployment.Spec.Template.Spec.Volumes
updated = true
}
if !reflect.DeepEqual(existingDeployment.Spec.Template.Spec.SecurityContext, deployment.Spec.Template.Spec.SecurityContext) {
existingDeployment.Spec.Template.Spec.SecurityContext = deployment.Spec.Template.Spec.SecurityContext
updated = true
}
}
if updated {
if _, err := r.KubeClientSet.AppsV1().Deployments(el.Namespace).Update(ctx, existingDeployment, metav1.UpdateOptions{}); err != nil {
Expand Down
8 changes: 2 additions & 6 deletions pkg/reconciler/v1alpha1/eventlistener/eventlistener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ var withTLSConfig = func(d *appsv1.Deployment) {
},
},
}},
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
RunAsUser: ptr.Int64(65532),
},
}}
d.Spec.Template.Spec.Volumes = []corev1.Volume{{
Name: "config-logging",
Expand Down Expand Up @@ -988,13 +984,13 @@ func TestReconcile(t *testing.T) {
key: reconcileKey,
startResources: test.Resources{
Namespaces: []*corev1.Namespace{namespaceResource},
EventListeners: []*v1alpha1.EventListener{elWithTLSConnection},
EventListeners: []*v1alpha1.EventListener{elWithStatus},
Deployments: []*appsv1.Deployment{deploymentMissingSecurityContext},
ConfigMaps: []*corev1.ConfigMap{loggingConfigMap},
},
endResources: test.Resources{
Namespaces: []*corev1.Namespace{namespaceResource},
EventListeners: []*v1alpha1.EventListener{makeEL(withStatus)},
EventListeners: []*v1alpha1.EventListener{elWithStatus},
Deployments: []*appsv1.Deployment{elDeployment},
Services: []*corev1.Service{elService},
ConfigMaps: []*corev1.ConfigMap{loggingConfigMap},
Expand Down

0 comments on commit c8a4e19

Please sign in to comment.