Skip to content
Next Next commit
Update model_build_lattice_service_test for resolve issue
  • Loading branch information
u-kai committed Feb 8, 2025
commit eb0724e1d7c85585b03a7ebf9e921d2a2c78ab5d
30 changes: 22 additions & 8 deletions pkg/controllers/route_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"

"sigs.k8s.io/controller-runtime/pkg/controller"

"github.com/pkg/errors"
Expand Down Expand Up @@ -50,7 +51,6 @@ import (
"github.com/aws/aws-application-networking-k8s/pkg/k8s"
"github.com/aws/aws-application-networking-k8s/pkg/model/core"
lattice_runtime "github.com/aws/aws-application-networking-k8s/pkg/runtime"
"github.com/aws/aws-application-networking-k8s/pkg/utils"
k8sutils "github.com/aws/aws-application-networking-k8s/pkg/utils"
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"
)
Expand Down Expand Up @@ -85,16 +85,32 @@ func RegisterAllRouteControllers(
mgr ctrl.Manager,
) error {
mgrClient := mgr.GetClient()

gwEventHandler := eventhandlers.NewEnqueueRequestGatewayEvent(log, mgrClient)
svcEventHandler := eventhandlers.NewServiceEventHandler(log, mgrClient)

routeInfos := []struct {
routeType core.RouteType
gatewayApiType client.Object
}{
{core.HttpRouteType, &gwv1.HTTPRoute{}},
{core.GrpcRouteType, &gwv1.GRPCRoute{}},
{core.TlsRouteType, &gwv1alpha2.TLSRoute{}},
{core.HttpRouteType, &gwv1.HTTPRoute{
TypeMeta: metav1.TypeMeta{
APIVersion: gwv1.GroupVersion.String(),
Kind: "HTTPRoute",
},
}},
{core.GrpcRouteType, &gwv1.GRPCRoute{
TypeMeta: metav1.TypeMeta{
APIVersion: gwv1.GroupVersion.String(),
Kind: "GRPCRoute",
},
}},
{core.TlsRouteType, &gwv1alpha2.TLSRoute{
TypeMeta: metav1.TypeMeta{
APIVersion: gwv1.GroupVersion.String(),
Kind: "TLSRoute",
},
}},
}

for _, routeInfo := range routeInfos {
Expand Down Expand Up @@ -169,7 +185,6 @@ func (r *routeReconciler) reconcile(ctx context.Context, req ctrl.Request) error
if err != nil {
return client.IgnoreNotFound(err)
}

if err = r.client.Get(ctx, req.NamespacedName, route.K8sObject()); err != nil {
return client.IgnoreNotFound(err)
}
Expand Down Expand Up @@ -261,8 +276,7 @@ func (r *routeReconciler) isRouteRelevant(ctx context.Context, route core.Route)
// make sure gateway is an aws-vpc-lattice
gwClass := &gwv1.GatewayClass{}
gwClassName := types.NamespacedName{
Namespace: defaultNamespace,
Name: string(gw.Spec.GatewayClassName),
Name: string(gw.Spec.GatewayClassName),
}

if err := r.client.Get(ctx, gwClassName, gwClass); err != nil {
Expand Down Expand Up @@ -573,7 +587,7 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
}

// set of valid Kinds for Route Backend References
var validBackendKinds = utils.NewSet("Service", "ServiceImport")
var validBackendKinds = k8sutils.NewSet("Service", "ServiceImport")

// validate route's backed references, will return non-accepted
// condition if at least one backendRef not in a valid state
Expand Down
Loading