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


##########
internal/controller/gateway_controller.go:
##########
@@ -194,10 +194,14 @@ func (r *GatewayReconciler) Reconcile(ctx 
context.Context, req ctrl.Request) (ct
                        msg:    "gateway proxy not found",
                }
        } else {
-               for _, addr := range gatewayProxy.Spec.StatusAddress {
-                       if addr == "" {
-                               continue
-                       }
+               statusAddresses, err := r.resolveStatusAddresses(ctx, 
&gatewayProxy)
+               if err != nil {
+                       // fail the reconcile so a missing or invalid publish 
Service retries
+                       // with backoff, mirroring the Ingress status path
+                       r.Log.Error(err, "failed to resolve gateway status 
addresses", "gateway", req.NamespacedName)
+                       return ctrl.Result{}, err

Review Comment:
   fixed



##########
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:
   fixed



-- 
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