AlinsRan commented on code in PR #2846:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2846#discussion_r3780474285


##########
internal/controller/gateway_controller.go:
##########
@@ -259,6 +263,38 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, 
req ctrl.Request) (ct
        return ctrl.Result{}, nil
 }
 
+// resolveStatusAddresses returns the addresses to publish in
+// Gateway.status.addresses: the statically configured statusAddress if set,
+// otherwise the external addresses of the Service named by publishService.
+// This mirrors the Ingress status path, so the same GatewayProxy yields the
+// same addresses for both APIs.
+func (r *GatewayReconciler) resolveStatusAddresses(
+       ctx context.Context,
+       gatewayProxy *v1alpha1.GatewayProxy,
+) ([]string, error) {
+       if len(gatewayProxy.Spec.StatusAddress) > 0 {
+               return utils.Filter(gatewayProxy.Spec.StatusAddress, func(addr 
string) bool {
+                       return addr != ""
+               }), nil
+       }
+
+       if gatewayProxy.Spec.PublishService == "" {
+               return nil, nil
+       }
+
+       // a bare name is resolved against the GatewayProxy's namespace
+       svc, err := resolvePublishService(ctx, r.Client, 
gatewayProxy.Spec.PublishService, gatewayProxy.GetNamespace())

Review Comment:
   The doc comment above claims both APIs end up with the same addresses, but 
for a bare name (`publishService: apisix-gateway`, no namespace) they don't — 
the two paths default to a different namespace:
   
   - here: the GatewayProxy's namespace
   - Ingress path: `ingress.Namespace` (ingress_controller.go:716)
   
   Those agree only when the Ingress happens to sit in the GatewayProxy's 
namespace. With the GatewayProxy in `ingress-apisix` and the Ingress in `app`, 
the Ingress path looks up `app/apisix-gateway` and fails with NotFound, while 
this path looks up `ingress-apisix/apisix-gateway` and succeeds.
   
   The rule used here is the better one — suggest making the Ingress path use 
it too, and dropping the "same addresses for both APIs" claim from the comment.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to