AlinsRan commented on code in PR #1780:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1780#discussion_r1166357757


##########
pkg/providers/ingress/ingress.go:
##########
@@ -152,6 +152,36 @@ func (c *ingressController) sync(ctx context.Context, ev 
*types.Event) error {
                }
                ing = ev.Tombstone.(kube.Ingress)
        }
+       if ing == nil {

Review Comment:
   Same reason as above.
   ```golang
   return nil
   ```



##########
pkg/providers/ingress/ingress.go:
##########
@@ -131,7 +130,7 @@ func (c *ingressController) sync(ctx context.Context, ev 
*types.Event) error {
        }
 
        if err != nil {
-               if !k8serrors.IsNotFound(err) {
+               if !k8serrors.IsNotFound(err) || (k8serrors.IsNotFound(err) && 
ev.Type != types.EventDelete) {

Review Comment:
   There are two questions here
   1. Events are not always up-to-date. We always retrieve the latest object, 
which may have been deleted. This logic can lead to infinite retries.
   2. Redundant logic, same as line 138.
   
   
![image](https://user-images.githubusercontent.com/79972061/231963858-9486017a-acec-4b9c-afc5-06b3ee747a1e.png)
   
   ```go
   if !k8serrors.IsNotFound(err) || (k8serrors.IsNotFound(err) && ev.Type != 
types.EventDelete) { return }
   if ev.Type != types.EventDelete { return } # Redundant 
   
   <==>
   
   if !k8serrors.IsNotFound(err) { return }
   if ev.Type != types.EventDelete { return }
   
   ```



-- 
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: [email protected]

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

Reply via email to