tao12345666333 commented on a change in pull request #740:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/740#discussion_r749045213



##########
File path: pkg/ingress/status.go
##########
@@ -163,8 +173,142 @@ func (c *Controller) recordStatus(at interface{}, reason 
string, err error, stat
                                )
                        }
                }
+       case *networkingv1.Ingress:
+               // set to status
+               lbips, err := c.ingressLBStatusIPs()
+               if err != nil {
+                       log.Errorw("failed to get APISIX gateway external IPs",
+                               zap.Error(err),
+                       )
+
+               }
+
+               v.Status.LoadBalancer.Ingress = lbips
+               if _, errRecord := 
kubeClient.NetworkingV1().Ingresses(v.Namespace).UpdateStatus(context.TODO(), 
v, metav1.UpdateOptions{}); errRecord != nil {
+                       log.Errorw("failed to record status change for 
IngressV1",
+                               zap.Error(errRecord),
+                               zap.String("name", v.Name),
+                               zap.String("namespace", v.Namespace),
+                       )
+               }
+
+       case *networkingv1beta1.Ingress:
+               // set to status
+               lbips, err := c.ingressLBStatusIPs()
+               if err != nil {
+                       log.Errorw("failed to get APISIX gateway external IPs",
+                               zap.Error(err),
+                       )
+
+               }
+
+               v.Status.LoadBalancer.Ingress = lbips
+               if _, errRecord := 
kubeClient.NetworkingV1beta1().Ingresses(v.Namespace).UpdateStatus(context.TODO(),
 v, metav1.UpdateOptions{}); errRecord != nil {
+                       log.Errorw("failed to record status change for 
IngressV1",
+                               zap.Error(errRecord),
+                               zap.String("name", v.Name),
+                               zap.String("namespace", v.Namespace),
+                       )
+               }
+       case *extensionsv1beta1.Ingress:
+               // set to status
+               lbips, err := c.ingressLBStatusIPs()
+               if err != nil {
+                       log.Errorw("failed to get APISIX gateway external IPs",
+                               zap.Error(err),
+                       )
+
+               }
+
+               v.Status.LoadBalancer.Ingress = lbips
+               if _, errRecord := 
kubeClient.ExtensionsV1beta1().Ingresses(v.Namespace).UpdateStatus(context.TODO(),
 v, metav1.UpdateOptions{}); errRecord != nil {
+                       log.Errorw("failed to record status change for 
IngressV1",
+                               zap.Error(errRecord),
+                               zap.String("name", v.Name),
+                               zap.String("namespace", v.Namespace),
+                       )
+               }
        default:
                // This should not be executed
                log.Errorf("unsupported resource record: %s", v)
        }
 }
+
+// ingressPublishAddresses get addressed used to expose Ingress
+func (c *Controller) ingressPublishAddresses() ([]string, error) {
+       ingressPublishService := c.cfg.IngressPublishService
+       ingressStatusAddress := c.cfg.IngressStatusAddress
+       addrs := []string{}
+
+       // if ingressStatusAddress is specified, it will be used first
+       if len(ingressStatusAddress) > 0 {
+               addrs = append(addrs, ingressStatusAddress...)
+               return addrs, nil
+       }
+
+       namespace, name, err := 
cache.SplitMetaNamespaceKey(ingressPublishService)

Review comment:
       I didn't understand what you mean.




-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to