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

ashishtiwari 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 e1a1b95b fix: replace string comparison with 64 bit int (#2062)
e1a1b95b is described below

commit e1a1b95bbde3f326cfa743de9a5f4469edbacc49
Author: Ashish Tiwari <[email protected]>
AuthorDate: Thu Nov 23 00:32:59 2023 +0530

    fix: replace string comparison with 64 bit int (#2062)
    
    Signed-off-by: Ashish Tiwari <[email protected]>
---
 pkg/providers/apisix/apisix_cluster_config.go | 5 ++++-
 pkg/providers/apisix/apisix_consumer.go       | 5 ++++-
 pkg/providers/apisix/apisix_global_rule.go    | 5 ++++-
 pkg/providers/apisix/apisix_plugin_config.go  | 5 ++++-
 pkg/providers/apisix/apisix_route.go          | 5 ++++-
 pkg/providers/apisix/apisix_tls.go            | 5 ++++-
 pkg/providers/apisix/apisix_upstream.go       | 5 ++++-
 pkg/providers/ingress/ingress.go              | 5 ++++-
 8 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/pkg/providers/apisix/apisix_cluster_config.go 
b/pkg/providers/apisix/apisix_cluster_config.go
index cee98424..8b0da5e2 100644
--- a/pkg/providers/apisix/apisix_cluster_config.go
+++ b/pkg/providers/apisix/apisix_cluster_config.go
@@ -17,6 +17,7 @@ package apisix
 import (
        "context"
        "fmt"
+       "strconv"
        "time"
 
        "go.uber.org/zap"
@@ -277,7 +278,9 @@ func (c *apisixClusterConfigController) onUpdate(oldObj, 
newObj interface{}) {
                log.Errorw("found ApisixClusterConfig resource with bad type", 
zap.Error(err))
                return
        }
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        key, err := cache.MetaNamespaceKeyFunc(newObj)
diff --git a/pkg/providers/apisix/apisix_consumer.go 
b/pkg/providers/apisix/apisix_consumer.go
index e896f1a7..6c358df2 100644
--- a/pkg/providers/apisix/apisix_consumer.go
+++ b/pkg/providers/apisix/apisix_consumer.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "time"
 
        "go.uber.org/zap"
@@ -243,7 +244,9 @@ func (c *apisixConsumerController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorw("found ApisixConsumer resource with bad type", 
zap.Error(err))
                return
        }
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.
diff --git a/pkg/providers/apisix/apisix_global_rule.go 
b/pkg/providers/apisix/apisix_global_rule.go
index df86a8da..69b3d11f 100644
--- a/pkg/providers/apisix/apisix_global_rule.go
+++ b/pkg/providers/apisix/apisix_global_rule.go
@@ -17,6 +17,7 @@ package apisix
 import (
        "context"
        "fmt"
+       "strconv"
        "time"
 
        "go.uber.org/zap"
@@ -274,7 +275,9 @@ func (c *apisixGlobalRuleController) onAdd(obj interface{}) 
{
 func (c *apisixGlobalRuleController) onUpdate(oldObj, newObj interface{}) {
        prev := kube.MustNewApisixGlobalRule(oldObj)
        curr := kube.MustNewApisixGlobalRule(newObj)
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        key, err := cache.MetaNamespaceKeyFunc(newObj)
diff --git a/pkg/providers/apisix/apisix_plugin_config.go 
b/pkg/providers/apisix/apisix_plugin_config.go
index 5b480da9..c806c49e 100644
--- a/pkg/providers/apisix/apisix_plugin_config.go
+++ b/pkg/providers/apisix/apisix_plugin_config.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "time"
 
        "go.uber.org/zap"
@@ -317,7 +318,9 @@ func (c *apisixPluginConfigController) onAdd(obj 
interface{}) {
 func (c *apisixPluginConfigController) onUpdate(oldObj, newObj interface{}) {
        prev := kube.MustNewApisixPluginConfig(oldObj)
        curr := kube.MustNewApisixPluginConfig(newObj)
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.
diff --git a/pkg/providers/apisix/apisix_route.go 
b/pkg/providers/apisix/apisix_route.go
index 073345d5..937f02fa 100644
--- a/pkg/providers/apisix/apisix_route.go
+++ b/pkg/providers/apisix/apisix_route.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "sync"
        "time"
 
@@ -530,7 +531,9 @@ func (c *apisixRouteController) onAdd(obj interface{}) {
 func (c *apisixRouteController) onUpdate(oldObj, newObj interface{}) {
        prev := kube.MustNewApisixRoute(oldObj)
        curr := kube.MustNewApisixRoute(newObj)
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.
diff --git a/pkg/providers/apisix/apisix_tls.go 
b/pkg/providers/apisix/apisix_tls.go
index 3d6e3cbb..c4281e36 100644
--- a/pkg/providers/apisix/apisix_tls.go
+++ b/pkg/providers/apisix/apisix_tls.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "sync"
        "time"
 
@@ -326,7 +327,9 @@ func (c *apisixTlsController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorw("found ApisixTls resource with bad type", 
zap.Error(err))
                return
        }
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.
diff --git a/pkg/providers/apisix/apisix_upstream.go 
b/pkg/providers/apisix/apisix_upstream.go
index 03ba07e5..02866ef5 100644
--- a/pkg/providers/apisix/apisix_upstream.go
+++ b/pkg/providers/apisix/apisix_upstream.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "sync"
        "time"
 
@@ -536,7 +537,9 @@ func (c *apisixUpstreamController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorw("found ApisixUpstream resource with bad type", 
zap.Error(err))
                return
        }
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.
diff --git a/pkg/providers/ingress/ingress.go b/pkg/providers/ingress/ingress.go
index 502441cd..9cb9f75a 100644
--- a/pkg/providers/ingress/ingress.go
+++ b/pkg/providers/ingress/ingress.go
@@ -18,6 +18,7 @@ import (
        "context"
        "fmt"
        "reflect"
+       "strconv"
        "strings"
        "sync"
        "time"
@@ -335,7 +336,9 @@ func (c *ingressController) onAdd(obj interface{}) {
 func (c *ingressController) onUpdate(oldObj, newObj interface{}) {
        prev := kube.MustNewIngress(oldObj)
        curr := kube.MustNewIngress(newObj)
-       if prev.ResourceVersion() >= curr.ResourceVersion() {
+       oldRV, _ := strconv.ParseInt(prev.ResourceVersion(), 0, 64)
+       newRV, _ := strconv.ParseInt(curr.ResourceVersion(), 0, 64)
+       if oldRV >= newRV {
                return
        }
        // Updates triggered by status are ignored.

Reply via email to