From b48b8f36b31abca23dd11fe5c066286ab62b9251 Mon Sep 17 00:00:00 2001 From: nmirasch Date: Wed, 25 Sep 2024 13:41:28 +0200 Subject: [PATCH] Add changes to existing service and update Signed-off-by: nmirasch --- controllers/argocd/service.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/controllers/argocd/service.go b/controllers/argocd/service.go index 9894523d0..23dd3180e 100644 --- a/controllers/argocd/service.go +++ b/controllers/argocd/service.go @@ -451,24 +451,26 @@ func (r *ReconcileArgoCD) reconcileServerService(cr *argoproj.ArgoCD) error { existingSVC := &corev1.Service{} if argoutil.IsObjectFound(r.Client, cr.Namespace, svc.Name, existingSVC) { + changed := false if !cr.Spec.Server.IsEnabled() { return r.Client.Delete(context.TODO(), svc) } - if ensureAutoTLSAnnotation(r.Client, svc, common.ArgoCDServerTLSSecretName, cr.Spec.Server.WantsAutoTLS()) { - return r.Client.Update(context.TODO(), svc) - } - if !cr.Spec.Repo.IsEnabled() { - return nil + if ensureAutoTLSAnnotation(r.Client, existingSVC, common.ArgoCDServerTLSSecretName, cr.Spec.Server.WantsAutoTLS()) { + changed = true } - changed := false if !reflect.DeepEqual(svc.Spec.Type, existingSVC.Spec.Type) { + existingSVC.Spec.Type = svc.Spec.Type changed = true } if changed { - return r.Client.Update(context.TODO(), svc) + return r.Client.Update(context.TODO(), existingSVC) } return nil } + + if !cr.Spec.Server.IsEnabled() { + return nil + } return r.Client.Create(context.TODO(), svc) }