Skip to content

Commit

Permalink
fix: ns should unwatch after unlabeling it (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
tao12345666333 authored Jul 6, 2022
1 parent 398f816 commit e25abdb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/ingress/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ func (c *namespaceController) sync(ctx context.Context, ev *types.Event) error {
namespace, err := c.controller.kube.Client.CoreV1().Namespaces().Get(ctx, ev.Object.(string), metav1.GetOptions{})
if err != nil {
return err
}

// if labels of namespace contains the watchingLabels, the namespace should be set to controller.watchingNamespaces
if c.controller.watchingLabels.IsSubsetOf(namespace.Labels) {
c.controller.watchingNamespaces.Store(namespace.Name, struct{}{})
} else {
// if labels of namespace contains the watchingLabels, the namespace should be set to controller.watchingNamespaces
if c.controller.watchingLabels.IsSubsetOf(namespace.Labels) {
c.controller.watchingNamespaces.Store(namespace.Name, struct{}{})
}
c.controller.watchingNamespaces.Delete(namespace.Name)
}

} else { // type == types.EventDelete
namespace := ev.Tombstone.(*corev1.Namespace)
if _, ok := c.controller.watchingNamespaces.Load(namespace.Name); ok {
Expand Down

0 comments on commit e25abdb

Please sign in to comment.