From f5cec5cb13d3c987688f591771d8b5177d483401 Mon Sep 17 00:00:00 2001 From: neogopher Date: Fri, 31 Jan 2025 13:08:39 +0530 Subject: [PATCH] Remove the ServiceBlockDeletion Annotation once the virtual service exists (cherry picked from commit eb6204a803e9ca3113310163a95c6b9215e84710) --- pkg/controllers/resources/services/syncer.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/controllers/resources/services/syncer.go b/pkg/controllers/resources/services/syncer.go index 340f9de038..2c595634e2 100644 --- a/pkg/controllers/resources/services/syncer.go +++ b/pkg/controllers/resources/services/syncer.go @@ -198,9 +198,7 @@ func (s *serviceSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.Sy event.Virtual.Labels, event.Host.Labels = translate.LabelsBidirectionalUpdate(event) // remove the ServiceBlockDeletion annotation if it's not needed - if event.Virtual.Spec.ClusterIP == event.Host.Spec.ClusterIP { - delete(event.Host.Annotations, ServiceBlockDeletion) - } + delete(event.Host.Annotations, ServiceBlockDeletion) // translate selector // TODO: ryan - convert to bidirectional @@ -221,8 +219,8 @@ func (s *serviceSyncer) SyncToVirtual(ctx *synccontext.SyncContext, event *syncc // we have to delay deletion here if a vObj does not (yet) exist for a service that was just // created, because vcluster intercepts those calls and first creates a service inside the host // cluster and then inside the virtual cluster. - if event.Host.Annotations != nil && event.Host.Annotations[ServiceBlockDeletion] == "true" { - return ctrl.Result{Requeue: true}, nil + if event.Host.Annotations != nil && event.Host.Annotations[ServiceBlockDeletion] == "true" && time.Since(event.Host.CreationTimestamp.Time) < 2*time.Minute { + return ctrl.Result{RequeueAfter: 10 * time.Second}, nil } if event.VirtualOld != nil || event.Host.DeletionTimestamp != nil {