diff --git a/controllers/kuadrant_status_updater.go b/controllers/kuadrant_status_updater.go index a9678e8d9..ad1906227 100644 --- a/controllers/kuadrant_status_updater.go +++ b/controllers/kuadrant_status_updater.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/go-logr/logr" + limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1" "github.com/kuadrant/policy-machinery/controller" "github.com/kuadrant/policy-machinery/machinery" corev1 "k8s.io/api/core/v1" @@ -18,6 +19,7 @@ import ( kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1" "github.com/kuadrant/kuadrant-operator/pkg/authorino" + "github.com/kuadrant/kuadrant-operator/pkg/kuadrant" ) const ( @@ -25,12 +27,14 @@ const ( ) type KuadrantStatusUpdater struct { - Client *dynamic.DynamicClient - HasGateway bool + Client *dynamic.DynamicClient + HasGateway bool + isLimitadorOperatorInstalled bool + isAuthorinoOperatorInstalled bool } -func NewKuadrantStatusUpdater(client *dynamic.DynamicClient, isIstioInstalled, isEnvoyGatewayInstalled bool) *KuadrantStatusUpdater { - return &KuadrantStatusUpdater{Client: client, HasGateway: isIstioInstalled || isEnvoyGatewayInstalled} +func NewKuadrantStatusUpdater(client *dynamic.DynamicClient, isIstioInstalled, isEnvoyGatewayInstalled, isLimitadorOperatorInstalled, isAuthorinoOperatorInstalled bool) *KuadrantStatusUpdater { + return &KuadrantStatusUpdater{Client: client, HasGateway: isIstioInstalled || isEnvoyGatewayInstalled, isLimitadorOperatorInstalled: isLimitadorOperatorInstalled, isAuthorinoOperatorInstalled: isAuthorinoOperatorInstalled} } func (r *KuadrantStatusUpdater) Subscription() *controller.Subscription { @@ -121,7 +125,14 @@ func (r *KuadrantStatusUpdater) readyCondition(topology *machinery.Topology, log if !r.HasGateway { cond.Status = metav1.ConditionFalse cond.Reason = "GatewayAPIProviderNotFound" - cond.Message = "GatewayAPI provider not found" + cond.Message = kuadrant.NewErrDependencyNotInstalled("GatewayAPI provider").Error() + return cond + } + + if !r.isLimitadorOperatorInstalled { + cond.Status = metav1.ConditionFalse + cond.Reason = "LimitadorAPIProviderNotFound" + cond.Message = kuadrant.NewErrDependencyNotInstalled("Limitador Operator").Error() return cond } @@ -167,7 +178,7 @@ func checkAuthorinoAvailable(topology *machinery.Topology, logger logr.Logger) * return ptr.To(err.Error()) } - readyCondition := authorino.FindAuthorinoStatusCondition(authorinoObj.Status.Conditions, "Ready") + readyCondition := authorino.FindAuthorinoStatusCondition(authorinoObj.Status.Conditions, limitadorv1alpha1.StatusConditionReady) if readyCondition == nil { return ptr.To("Ready condition not found") } diff --git a/controllers/state_of_the_world.go b/controllers/state_of_the_world.go index 3fd231e0a..9f793e8a1 100644 --- a/controllers/state_of_the_world.go +++ b/controllers/state_of_the_world.go @@ -396,12 +396,10 @@ func (b *BootOptionsBuilder) Reconciler() controller.ReconcileFunc { mainWorkflow := &controller.Workflow{ Precondition: initWorkflow(b.client).Run, Tasks: []controller.ReconcileFunc{ - NewAuthorinoReconciler(b.client).Subscription().Reconcile, - NewLimitadorReconciler(b.client).Subscription().Reconcile, NewDNSWorkflow(b.client, b.manager.GetScheme(), b.isDNSOperatorInstalled).Run, NewTLSWorkflow(b.client, b.manager.GetScheme(), b.isCertManagerInstalled).Run, NewDataPlanePoliciesWorkflow(b.client, b.isIstioInstalled, b.isEnvoyGatewayInstalled, b.isLimitadorOperatorInstalled, b.isAuthorinoOperatorInstalled).Run, - NewKuadrantStatusUpdater(b.client, b.isIstioInstalled, b.isEnvoyGatewayInstalled).Subscription().Reconcile, + NewKuadrantStatusUpdater(b.client, b.isIstioInstalled, b.isEnvoyGatewayInstalled, b.isLimitadorOperatorInstalled, b.isAuthorinoOperatorInstalled).Subscription().Reconcile, }, Postcondition: finalStepsWorkflow(b.client, b.isIstioInstalled, b.isGatewayAPIInstalled).Run, } @@ -412,6 +410,17 @@ func (b *BootOptionsBuilder) Reconciler() controller.ReconcileFunc { ) } + if b.isLimitadorOperatorInstalled { + mainWorkflow.Tasks = append(mainWorkflow.Tasks, + NewLimitadorReconciler(b.client).Subscription().Reconcile, + ) + } + + if b.isAuthorinoOperatorInstalled { + mainWorkflow.Tasks = append(mainWorkflow.Tasks, + NewAuthorinoReconciler(b.client).Subscription().Reconcile) + } + return mainWorkflow.Run } diff --git a/tests/gatewayapi/kuadrant_controller_test.go b/tests/gatewayapi/kuadrant_controller_test.go index fdf101b13..ec02ddf05 100644 --- a/tests/gatewayapi/kuadrant_controller_test.go +++ b/tests/gatewayapi/kuadrant_controller_test.go @@ -53,7 +53,7 @@ var _ = Describe("Kuadrant controller when gateway provider is missing", func() g.Expect(cond).ToNot(BeNil()) g.Expect(cond.Status).To(Equal(metav1.ConditionFalse)) g.Expect(cond.Reason).To(Equal("GatewayAPIProviderNotFound")) - g.Expect(cond.Message).To(Equal("GatewayAPI provider not found")) + g.Expect(cond.Message).To(Equal("GatewayAPI provider is not installed, please restart pod once dependency has been installed")) }, time.Minute, 15*time.Second).WithContext(ctx).Should(Succeed()) }) })