aws / aws-application-networking-k8s

A Kubernetes controller for Amazon VPC Lattice
https://www.gateway-api-controller.eks.aws.dev/
Apache License 2.0
162 stars 47 forks source link

HTTPRoute with multiple parentrefs not creating listener #661

Open michal-sa opened 4 weeks ago

michal-sa commented 4 weeks ago

While trying to create a HTTPRoute containing two parentRefs where one is a gatewayClassName: amazon-vpc-lattice Gateway resource and the other a gateway with another class it doesn't seem like the listeners are created correctly for the lattice service.

Not working manifest:

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: test-service
  namespace: my-namespace
spec:
  parentRefs:
     - name: lattice-gateway
       namespace: gateway-controller
       sectionName: https
     - name: gateway
       namespace: another-namespace
  rules:
      - backendRefs:
        - name: test-service
          kind: Service
          namespace: my-namespace
          port: 8080

Debug controller logs:


{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_listener.go:91","msg":"Ignore parentref of different gateway gateway-%!s(*v1.Namespace=0xc0013ad310)"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_lattice_service.go:84","msg":"Building rules for 1 listeners"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_rule.go:35","msg":"Processing 1 rules"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_rule.go:47","msg":"Processing rule match"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_rule.go:109","msg":"Examining pathmatch type PathPrefix value / for for httproute test-service-my-namespace "}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_rule.go:119","msg":"Using PathMatchPathPrefix for httproute test-service-my-namespace "}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_rule.go:226","msg":"Processing Service backendRef test-my-namespace"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_targetgroup.go:298","msg":"buildTargetGroupSpec, kind Service"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_targetgroup.go:264","msg":"Added target group for backendRef test to the stack id-a7af5abbe84d4edbcadf435b726e63cb5c6917cb7bf5d9da9298ac03d9a7b701"}
{"level":"debug","ts":"2024-08-14T12:19:54.264Z","logger":"controller.route","caller":"gateway/model_build_targets.go:89","msg":"Processing targets for service test-my-namespace"}
...
...
{"level":"debug","ts":"2024-08-14T12:19:54.355Z","logger":"controller.route","caller":"lattice/target_group_manager.go:121","msg":"HealthCheck is empty. Resetting to default settings"}
{"level":"debug","ts":"2024-08-14T12:19:54.355Z","logger":"controller.route","caller":"lattice/targets_manager.go:62","msg":"Creating targets for target group tg-02bfdf3549201a724"}
...
{"level":"debug","ts":"2024-08-14T12:19:54.759Z","logger":"controller.route","caller":"lattice/targets_manager.go:128","msg":"Successfully registered 2 targets from VPC Lattice Target Group tg-02bfdf3549201a724 for chunk 1/1"}
{"level":"debug","ts":"2024-08-14T12:19:54.759Z","logger":"controller.route","caller":"lattice/service_synthesizer.go:44","msg":"Synthesizing service: test-service-my-namespace"}
{"level":"debug","ts":"2024-08-14T12:19:54.806Z","logger":"cloud","caller":"aws/cloud.go:68","msg":"response","serviceName":"VPC Lattice","operation":"ListServices","params":"{\n\n}"}
...
{"level":"debug","ts":"2024-08-14T12:19:54.905Z","logger":"cloud","caller":"aws/cloud.go:68","msg":"response","serviceName":"VPC Lattice","operation":"ListServiceNetworks","params":"{\n\n}"}
{"level":"info","ts":"2024-08-14T12:19:54.905Z","logger":"controller.route","caller":"controllers/route_controller.go:156","msg":"reconcile error","name":"test-service","message":"error during service synthesis failed ServiceManager.Upsert test-service-my-namespace due to not found, Service network gateway"}

After removing the gateway parentRef the listerners are created successfully.

A workaround is to have two HTTPRoutes for the different gateways, but that's not optimal.

zijun726911 commented 4 weeks ago

While trying to create a HTTPRoute containing two parentRefs where one is a gatewayClassName: amazon-vpc-lattice Gateway resource and the other a gateway with another class it doesn't seem like the listeners are created correctly for the lattice service.

From my first glance, it's a controller bug, we will take a deeper look and fix it.