tokers commented on a change in pull request #163:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/163#discussion_r554294528



##########
File path: pkg/apisix/resource.go
##########
@@ -116,6 +116,7 @@ func (i *item) upstream(clusterName string) (*v1.Upstream, 
error) {
        }
 
        var ups upstreamItem
+       log.Info(string(i.Value))

Review comment:
       It already logs `i.Value` in line 112.

##########
File path: pkg/ingress/controller/apisix_upstream.go
##########
@@ -112,30 +112,46 @@ func (c *ApisixUpstreamController) processNextWorkItem() 
bool {
        return true
 }
 
-func (c *ApisixUpstreamController) syncHandler(key string) error {
-       namespace, name, err := cache.SplitMetaNamespaceKey(key)
+func (c *ApisixUpstreamController) syncHandler(sqo *UpstreamQueueObj) error {
+       namespace, name, err := cache.SplitMetaNamespaceKey(sqo.Key)
        if err != nil {
-               log.Errorf("invalid resource key: %s", key)
-               return fmt.Errorf("invalid resource key: %s", key)
+               log.Errorf("invalid resource key: %s", sqo.Key)
+               return fmt.Errorf("invalid resource key: %s", sqo.Key)
        }
-
-       apisixUpstreamYaml, err := 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
-       if err != nil {
-               if errors.IsNotFound(err) {
-                       log.Infof("apisixUpstream %s is removed", key)
+       apisixUpstreamYaml := sqo.OldObj
+       if sqo.Ope == DELETE {
+               apisixIngressUpstream, _ := 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
+               if apisixIngressUpstream != nil && 
apisixIngressUpstream.ResourceVersion > sqo.OldObj.ResourceVersion {
+                       log.Warnf("Upstram %s has been covered when retry", 
sqo.Key)
                        return nil
                }
-               runtime.HandleError(fmt.Errorf("failed to list apisixUpstream 
%s/%s", key, err.Error()))
-               return err
+       } else {
+               apisixUpstreamYaml, err = 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
+               if err != nil {
+                       if errors.IsNotFound(err) {
+                               log.Infof("apisixUpstraem %s is removed", 
sqo.Key)
+                               return nil
+                       }
+                       runtime.HandleError(fmt.Errorf("failed to list 
apisixService %s/%s", sqo.Key, err.Error()))

Review comment:
       Type: here we are listing `ApisixUpstream`.

##########
File path: pkg/ingress/controller/apisix_upstream.go
##########
@@ -112,30 +112,46 @@ func (c *ApisixUpstreamController) processNextWorkItem() 
bool {
        return true
 }
 
-func (c *ApisixUpstreamController) syncHandler(key string) error {
-       namespace, name, err := cache.SplitMetaNamespaceKey(key)
+func (c *ApisixUpstreamController) syncHandler(sqo *UpstreamQueueObj) error {
+       namespace, name, err := cache.SplitMetaNamespaceKey(sqo.Key)
        if err != nil {
-               log.Errorf("invalid resource key: %s", key)
-               return fmt.Errorf("invalid resource key: %s", key)
+               log.Errorf("invalid resource key: %s", sqo.Key)
+               return fmt.Errorf("invalid resource key: %s", sqo.Key)
        }
-
-       apisixUpstreamYaml, err := 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
-       if err != nil {
-               if errors.IsNotFound(err) {
-                       log.Infof("apisixUpstream %s is removed", key)
+       apisixUpstreamYaml := sqo.OldObj
+       if sqo.Ope == DELETE {
+               apisixIngressUpstream, _ := 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
+               if apisixIngressUpstream != nil && 
apisixIngressUpstream.ResourceVersion > sqo.OldObj.ResourceVersion {
+                       log.Warnf("Upstram %s has been covered when retry", 
sqo.Key)
                        return nil
                }
-               runtime.HandleError(fmt.Errorf("failed to list apisixUpstream 
%s/%s", key, err.Error()))
-               return err
+       } else {
+               apisixUpstreamYaml, err = 
c.apisixUpstreamList.ApisixUpstreams(namespace).Get(name)
+               if err != nil {
+                       if errors.IsNotFound(err) {
+                               log.Infof("apisixUpstraem %s is removed", 
sqo.Key)

Review comment:
       Type: `apisixUpstraem` => `apisixUpstream`

##########
File path: test/e2e/scaffold/ingress.go
##########
@@ -77,7 +77,7 @@ spec:
             tcpSocket:
               port: 8080
             timeoutSeconds: 2
-          image: "apache/apisix-ingress-controller:dev"
+          image: "apisix-ingress-controller:dev"

Review comment:
       Why change it again?

##########
File path: test/e2e/scaffold/crd.go
##########
@@ -22,14 +22,13 @@ import (
        "strconv"
        "time"
 
+       "github.com/api7/ingress-controller/pkg/apisix"

Review comment:
       Style: put these lines at the end of import block.

##########
File path: pkg/ingress/controller/apisix_upstream.go
##########
@@ -145,25 +161,45 @@ func (c *ApisixUpstreamController) addFunc(obj 
interface{}) {
                runtime.HandleError(err)
                return
        }
-       c.workqueue.AddRateLimited(key)
+       sqo := &UpstreamQueueObj{Key: key, OldObj: nil, Ope: ADD}
+       c.workqueue.AddRateLimited(sqo)
 }
 
 func (c *ApisixUpstreamController) updateFunc(oldObj, newObj interface{}) {
-       oldRoute := oldObj.(*apisixV1.ApisixUpstream)
-       newRoute := newObj.(*apisixV1.ApisixUpstream)
-       if oldRoute.ResourceVersion == newRoute.ResourceVersion {
+       oldUpstream := oldObj.(*apisixV1.ApisixUpstream)
+       newUpstream := newObj.(*apisixV1.ApisixUpstream)
+       if oldUpstream.ResourceVersion >= newUpstream.ResourceVersion {
                return
        }
-       c.addFunc(newObj)
+       var key string

Review comment:
       Style:
   
   ```go
   var (
       key string
       err  error
   )
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to