File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import (
4545 "github.com/apache/apisix-ingress-controller/internal/provider"
4646 "github.com/apache/apisix-ingress-controller/internal/types"
4747 "github.com/apache/apisix-ingress-controller/internal/utils"
48+ pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
4849)
4950
5051// TCPRouteReconciler reconciles a TCPRoute object.
@@ -93,10 +94,15 @@ func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error {
9394 ).
9495 Watches (& v1alpha1.GatewayProxy {},
9596 handler .EnqueueRequestsFromMapFunc (r .listTCPRoutesForGatewayProxy ),
96- ).
97- Watches (& v1alpha1.L4RoutePolicy {},
97+ )
98+
99+ // L4RoutePolicy is an optional CRD. Only watch it when installed so the
100+ // controller still starts if the CRD has not been applied yet (e.g. upgrades).
101+ if pkgutils .HasAPIResource (mgr , & v1alpha1.L4RoutePolicy {}) {
102+ bdr .Watches (& v1alpha1.L4RoutePolicy {},
98103 handler .EnqueueRequestsFromMapFunc (r .listTCPRoutesForL4RoutePolicy ),
99104 )
105+ }
100106
101107 if GetEnableReferenceGrant () {
102108 bdr .Watches (& v1beta1.ReferenceGrant {},
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import (
4545 "github.com/apache/apisix-ingress-controller/internal/provider"
4646 "github.com/apache/apisix-ingress-controller/internal/types"
4747 "github.com/apache/apisix-ingress-controller/internal/utils"
48+ pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
4849)
4950
5051// TLSRouteReconciler reconciles a TLSRoute object.
@@ -93,10 +94,15 @@ func (r *TLSRouteReconciler) SetupWithManager(mgr ctrl.Manager) error {
9394 ).
9495 Watches (& v1alpha1.GatewayProxy {},
9596 handler .EnqueueRequestsFromMapFunc (r .listTLSRoutesForGatewayProxy ),
96- ).
97- Watches (& v1alpha1.L4RoutePolicy {},
97+ )
98+
99+ // L4RoutePolicy is an optional CRD. Only watch it when installed so the
100+ // controller still starts if the CRD has not been applied yet (e.g. upgrades).
101+ if pkgutils .HasAPIResource (mgr , & v1alpha1.L4RoutePolicy {}) {
102+ bdr .Watches (& v1alpha1.L4RoutePolicy {},
98103 handler .EnqueueRequestsFromMapFunc (r .listTLSRoutesForL4RoutePolicy ),
99104 )
105+ }
100106
101107 if GetEnableReferenceGrant () {
102108 bdr .Watches (& v1beta1.ReferenceGrant {},
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import (
4545 "github.com/apache/apisix-ingress-controller/internal/provider"
4646 "github.com/apache/apisix-ingress-controller/internal/types"
4747 "github.com/apache/apisix-ingress-controller/internal/utils"
48+ pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
4849)
4950
5051// UDPRouteReconciler reconciles a UDPRoute object.
@@ -93,10 +94,15 @@ func (r *UDPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error {
9394 ).
9495 Watches (& v1alpha1.GatewayProxy {},
9596 handler .EnqueueRequestsFromMapFunc (r .listUDPRoutesForGatewayProxy ),
96- ).
97- Watches (& v1alpha1.L4RoutePolicy {},
97+ )
98+
99+ // L4RoutePolicy is an optional CRD. Only watch it when installed so the
100+ // controller still starts if the CRD has not been applied yet (e.g. upgrades).
101+ if pkgutils .HasAPIResource (mgr , & v1alpha1.L4RoutePolicy {}) {
102+ bdr .Watches (& v1alpha1.L4RoutePolicy {},
98103 handler .EnqueueRequestsFromMapFunc (r .listUDPRoutesForL4RoutePolicy ),
99104 )
105+ }
100106
101107 if GetEnableReferenceGrant () {
102108 bdr .Watches (& v1beta1.ReferenceGrant {},
You can’t perform that action at this time.
0 commit comments