Hemanth1205 commented on code in PR #2732:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2732#discussion_r2945705428


##########
internal/controller/ingress_controller.go:
##########
@@ -731,6 +737,33 @@ func (r *IngressReconciler) updateStatus(ctx 
context.Context, tctx *provider.Tra
                                                })
                                        }
                                }
+                       case corev1.ServiceTypeClusterIP:
+                               // for ClusterIP services, find Ingresses that 
reference this service
+                               // and collect hostnames from their load 
balancer status
+                               // this is when we run the apisix in ClusterIP 
mode and enable Ingress
+                               // when deploying in Cloud environments.
+                               ingressList := &networkingv1.IngressList{}
+                               if err := r.List(ctx, ingressList, 
client.MatchingFields{
+                                       indexer.ServiceIndexRef: 
indexer.GenIndexKey(namespace, name),
+                               }); err != nil {
+                                       return fmt.Errorf("failed to list 
ingresses for ClusterIP service %s/%s: %w", namespace, name, err)
+                               }
+                               for _, ing := range ingressList.Items {
+                                       // Skip the current Ingress being 
reconciled to avoid a
+                                       // self-referential loop: updating its 
own status would trigger
+                                       // a new reconcile, which would collect 
its own (just-written)
+                                       // hostname again and potentially 
repeat indefinitely.
+                                       if ing.Namespace == ingress.Namespace 
&& ing.Name == ingress.Name {
+                                               continue
+                                       }
+                                       for _, lb := range 
ing.Status.LoadBalancer.Ingress {
+                                               if lb.Hostname != "" {
+                                                       
loadBalancerStatus.Ingress = append(loadBalancerStatus.Ingress, 
networkingv1.IngressLoadBalancerIngress{
+                                                               Hostname: 
lb.Hostname,
+                                                       })
+                                               }
+                                       }

Review Comment:
   updated code



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