Skip to content

Commit

Permalink
Issue 657: Providing support to update controller service annotations (
Browse files Browse the repository at this point in the history
…#658)

* Issue 657: Providing support to update controller service annotations

Signed-off-by: anisha.kj <[email protected]>

* Addressing review comments

Signed-off-by: anisha.kj <[email protected]>

* Addressing review comments

Signed-off-by: anisha.kj <[email protected]>

---------

Signed-off-by: anisha.kj <[email protected]>
  • Loading branch information
anishakj authored Mar 7, 2023
1 parent 340107d commit a1dcfec
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions controllers/pravegacluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,26 @@ func (r *PravegaClusterReconciler) reconcileControllerService(p *pravegav1beta1.

service := MakeControllerService(p)
controllerutil.SetControllerReference(p, service, r.Scheme)
err = r.Client.Create(context.TODO(), service)
if err != nil && !errors.IsAlreadyExists(err) {
return err
currentService := &corev1.Service{}
err = r.Client.Get(context.TODO(), types.NamespacedName{Name: service.Name, Namespace: p.Namespace}, currentService)
if err != nil {
if errors.IsNotFound(err) {
err = r.Client.Create(context.TODO(), service)
if err != nil && !errors.IsAlreadyExists(err) {
return err
}
} else {
return err
}
} else {
currentService.ObjectMeta.Labels = service.ObjectMeta.Labels
currentService.ObjectMeta.Annotations = service.ObjectMeta.Annotations
currentService.Spec.Selector = service.Spec.Selector
err = r.Client.Update(context.TODO(), currentService)
if err != nil {
return fmt.Errorf("failed to update service (%s): %v", service.Name, err)
}
}

return nil
}

Expand Down

0 comments on commit a1dcfec

Please sign in to comment.