wolgod commented on issue #1124:
URL: 
https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1173344543

   My test scenario is that when I cancel the label of an ns, I find that I can 
still listen to the events of apisixroute under this ns
   `
   func (c *namespaceController) onUpdate(pre, cur interface{}) {
        oldNamespace := pre.(*corev1.Namespace)
        newNamespace := cur.(*corev1.Namespace)
        if oldNamespace.ResourceVersion >= newNamespace.ResourceVersion {
                return
        }
        key, err := cache.MetaNamespaceKeyFunc(cur)
        if err != nil {
                log.Errorf("found Namespace resource with error: %s", err)
                return
        }
        c.workqueue.Add(&types.Event{
                Type:   types.EventUpdate,
                Object: key,
        })
   }
   `
   
   `
   func (c *namespaceController) sync(ctx context.Context, ev *types.Event) 
error {
        if ev.Type != types.EventDelete {
                // check the labels of specify namespace
                namespace, err := 
c.controller.kubeClient.Client.CoreV1().Namespaces().Get(ctx, 
ev.Object.(string), metav1.GetOptions{})
                if err != nil {
                        return err
                } else {
                        // if labels of namespace contains the watchingLabels, 
the namespace should be set to controller.watchingNamespace
                        if 
c.controller.watchingLabels.IsSubsetOf(namespace.Labels) {
                                
c.controller.watchingNamespace.Store(namespace.Name, struct{}{})
                        }
                }
        } else { // type == types.EventDelete
                namespace := ev.Tombstone.(*corev1.Namespace)
                if _, ok := 
c.controller.watchingNamespace.Load(namespace.Name); ok {
                        c.controller.watchingNamespace.Delete(namespace.Name)
                }
                // do nothing, if the namespace did not in 
controller.watchingNamespace
        }
        return nil
   }
   `
   
   In my opinion, the label removal triggers the update event, but the sync 
does not remove the monitoring of this ns. I wonder if this logic is originally 
designed like this?
   


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