From da6871ad97cfdb36fb340d0a61e48f8c90f2f55e Mon Sep 17 00:00:00 2001 From: Pavan <25031267+Pavan-SAP@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:08:07 +0100 Subject: [PATCH] [Fix] Domains: Error handling amended Error scenarios were not getting correctly rate limited as the operator incorrectly reset the state to Processing on every other reconcile! This is now fixed by not requeuing the resource, other than when status is unset. --- internal/controller/reconcile-domain.go | 7 +++++-- internal/controller/reconcile-domain_test.go | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/controller/reconcile-domain.go b/internal/controller/reconcile-domain.go index cd80f45f..f37c3a0a 100644 --- a/internal/controller/reconcile-domain.go +++ b/internal/controller/reconcile-domain.go @@ -134,10 +134,13 @@ func reconcileDomainEntity[T v1alpha1.DomainEntity](ctx context.Context, c *Cont return handleDomainResourceDeletion(ctx, c, dom) } - if dom.GetStatus().State != v1alpha1.DomainStateProcessing { - // set processing status + if dom.GetStatus().State == "" { + // When no status state is set, we set it to processing state first and requeue for processing. dom.SetStatusWithReadyCondition(v1alpha1.DomainStateProcessing, metav1.ConditionFalse, "Processing", "Processing domain resources") return NewReconcileResultWithResource(getResourceKeyFromKind(dom), dom.GetName(), dom.GetNamespace(), 0), nil + } else if dom.GetStatus().State != v1alpha1.DomainStateProcessing { + // If not in processing state, we set it to processing state first and continue without requeuing. This ensures Error scenarios (if any) stay rate limited. + dom.SetStatusWithReadyCondition(v1alpha1.DomainStateProcessing, metav1.ConditionFalse, "Processing", "Processing domain resources") } defer func() { diff --git a/internal/controller/reconcile-domain_test.go b/internal/controller/reconcile-domain_test.go index aa40bbdb..65cdf33c 100644 --- a/internal/controller/reconcile-domain_test.go +++ b/internal/controller/reconcile-domain_test.go @@ -41,6 +41,25 @@ func TestDomain_InitialState(t *testing.T) { ) } +func TestDomain_ProcessingWithError(t *testing.T) { + err := reconcileTestItem( + context.TODO(), t, + QueueItem{Key: ResourceDomain, ResourceKey: NamespacedResourceKey{Namespace: "default", Name: "test-cap-01-primary"}}, + TestData{ + description: "Processing with ingress error", + initialResources: []string{ + "testdata/domain/domain-no-ingress-error.yaml", + }, + expectedResources: "testdata/domain/domain-no-ingress-error.yaml", + expectError: true, + }, + ) + + if err.Error() != "failed to get ingress information for Domain.default.test-cap-01-primary: no matching ingress gateway pods found matching selector from Domain.default.test-cap-01-primary" { + t.Error("Wrong error message") + } +} + func TestDomain_ProcessingWithoutIngress(t *testing.T) { err := reconcileTestItem( context.TODO(), t,