You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/11/15 06:39:41 UTC

[GitHub] [apisix-ingress-controller] tao12345666333 commented on a change in pull request #740: feat: Fix lb ingress status

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



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

Review comment:
       I think that directly specifying the IP will be more direct and will have a higher priority. I will modify the description in the configuration.




-- 
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-unsubscribe@apisix.apache.org

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