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,