You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2022/03/07 15:48:36 UTC

[apisix-ingress-controller] branch master updated: fix: fix ep resourceVersion comparison and clean up (#901)

This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ddbfa6  fix: fix ep resourceVersion comparison and clean up (#901)
1ddbfa6 is described below

commit 1ddbfa68bb05becda7eb301f3ce6740c02b4d0a1
Author: cmssczy <ca...@cmss.chinamobile.com>
AuthorDate: Mon Mar 7 23:48:30 2022 +0800

    fix: fix ep resourceVersion comparison and clean up (#901)
---
 pkg/ingress/apisix_tls.go    | 2 +-
 pkg/ingress/endpoint.go      | 2 +-
 pkg/ingress/endpointslice.go | 2 +-
 pkg/ingress/secret.go        | 2 +-
 pkg/ingress/status.go        | 5 ++---
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/pkg/ingress/apisix_tls.go b/pkg/ingress/apisix_tls.go
index c2865f8..266ee94 100644
--- a/pkg/ingress/apisix_tls.go
+++ b/pkg/ingress/apisix_tls.go
@@ -206,7 +206,7 @@ func (c *apisixTlsController) onAdd(obj interface{}) {
 func (c *apisixTlsController) onUpdate(prev, curr interface{}) {
 	oldTls := prev.(*configv2beta3.ApisixTls)
 	newTls := curr.(*configv2beta3.ApisixTls)
-	if oldTls.GetResourceVersion() == newTls.GetResourceVersion() {
+	if oldTls.GetResourceVersion() >= newTls.GetResourceVersion() {
 		return
 	}
 	key, err := cache.MetaNamespaceKeyFunc(curr)
diff --git a/pkg/ingress/endpoint.go b/pkg/ingress/endpoint.go
index 912958c..de5c540 100644
--- a/pkg/ingress/endpoint.go
+++ b/pkg/ingress/endpoint.go
@@ -133,7 +133,7 @@ func (c *endpointsController) onUpdate(prev, curr interface{}) {
 	prevEp := prev.(*corev1.Endpoints)
 	currEp := curr.(*corev1.Endpoints)
 
-	if prevEp.GetResourceVersion() == currEp.GetResourceVersion() {
+	if prevEp.GetResourceVersion() >= currEp.GetResourceVersion() {
 		return
 	}
 	key, err := cache.MetaNamespaceKeyFunc(currEp)
diff --git a/pkg/ingress/endpointslice.go b/pkg/ingress/endpointslice.go
index 5c09998..5c4d3b4 100644
--- a/pkg/ingress/endpointslice.go
+++ b/pkg/ingress/endpointslice.go
@@ -157,7 +157,7 @@ func (c *endpointSliceController) onUpdate(prev, curr interface{}) {
 	prevEp := prev.(*discoveryv1.EndpointSlice)
 	currEp := curr.(*discoveryv1.EndpointSlice)
 
-	if prevEp.GetResourceVersion() == currEp.GetResourceVersion() {
+	if prevEp.GetResourceVersion() >= currEp.GetResourceVersion() {
 		return
 	}
 	key, err := cache.MetaNamespaceKeyFunc(currEp)
diff --git a/pkg/ingress/secret.go b/pkg/ingress/secret.go
index d8e9b23..9eb32c3 100644
--- a/pkg/ingress/secret.go
+++ b/pkg/ingress/secret.go
@@ -254,7 +254,7 @@ func (c *secretController) onUpdate(prev, curr interface{}) {
 	prevSec := prev.(*corev1.Secret)
 	currSec := curr.(*corev1.Secret)
 
-	if prevSec.GetResourceVersion() == currSec.GetResourceVersion() {
+	if prevSec.GetResourceVersion() >= currSec.GetResourceVersion() {
 		return
 	}
 	key, err := cache.MetaNamespaceKeyFunc(currSec)
diff --git a/pkg/ingress/status.go b/pkg/ingress/status.go
index acd7bbc..2bbac5b 100644
--- a/pkg/ingress/status.go
+++ b/pkg/ingress/status.go
@@ -28,7 +28,6 @@ import (
 	networkingv1beta1 "k8s.io/api/networking/v1beta1"
 	"k8s.io/apimachinery/pkg/api/meta"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/client-go/tools/cache"
 	gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
@@ -55,7 +54,7 @@ func (c *Controller) verifyGeneration(conditions *[]metav1.Condition, newConditi
 }
 
 // recordStatus record resources status
-func (c *Controller) recordStatus(at interface{}, reason string, err error, status v1.ConditionStatus, generation int64) {
+func (c *Controller) recordStatus(at interface{}, reason string, err error, status metav1.ConditionStatus, generation int64) {
 	// build condition
 	message := _commonSuccessMessage
 	if err != nil {
@@ -335,7 +334,7 @@ func (c *Controller) ingressPublishAddresses() ([]string, error) {
 	switch svc.Spec.Type {
 	case apiv1.ServiceTypeLoadBalancer:
 		if len(svc.Status.LoadBalancer.Ingress) < 1 {
-			return addrs, fmt.Errorf(_gatewayLBNotReadyMessage)
+			return addrs, fmt.Errorf("%s", _gatewayLBNotReadyMessage)
 		}
 
 		for _, ip := range svc.Status.LoadBalancer.Ingress {