aws / aws-application-networking-k8s

A Kubernetes controller for Amazon VPC Lattice

Home Page:https://www.gateway-api-controller.eks.aws.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Http/GRPCRoute's backendref port didn't take effect when updating HttpRoute/GRPCRoute/k8Service

zijun726911 opened this issue · comments

For following scenarios, Http/GRPCRoute's backendref ports didn't take effect and the controller will create lattice targets with unexpected ports:

Root cause:
In this PR #351, we only assign &latticeTargetsModelBuildTask{ backendRefPort: port} in (t *latticeServiceModelBuildTask) buildTargets(), but miss to do that in (b *LatticeTargetsModelBuilder) Build().

Adding backendRefPort: port logic in the (b *LatticeTargetsModelBuilder) Build()` is quite likely could fix it.

Furthermore, build targets logic could diverge triggering from k8sService/Route/ServiceExport, should we consider to refactor and combine them?

For ServiceExport, instead of using backendRef ports we are relying on annotations for determining ports - because at the moment of creating TGs we may not have HTTPRoute in the same cluster. Please try setting up "multicluster.x-k8s.io/port" annotation on ServiceExport.

Ok, I think only happen for updating HttpRoute/GRPCRoute/Service scenarios, no ServiceExport

So your explanation is:

  • k8s Service change does trigger all these - ServiceReconciler, HTTPRouteReconciler, and ServiceExportReconciler.
  • ServiceReconciler is not aware of port information so tries to register all endpoints instead of watching backendRef.

I think it makes sense. Actually I don't get why ServiceReconciler even exists, the other two reconcilers are able to handle that anyways.

Perhaps a better path forward is to remove ServiceReconciler and letting the other two reconcilers watch endpoint events instead.