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

zhangjintao 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 d30bef5  fix: endless retry if namespace doesn't exist (#882)
d30bef5 is described below

commit d30bef56d5502724901c7eae42b319ad1b92c76c
Author: Sarasa Kisaragi <[email protected]>
AuthorDate: Wed Feb 23 22:35:58 2022 +0800

    fix: endless retry if namespace doesn't exist (#882)
---
 pkg/ingress/apisix_consumer.go     |  6 ++--
 pkg/ingress/apisix_pluginconfig.go |  6 ++--
 pkg/ingress/apisix_route.go        |  6 ++--
 pkg/ingress/apisix_tls.go          |  6 ++--
 pkg/ingress/apisix_upstream.go     |  6 ++--
 pkg/ingress/compare.go             |  8 +++---
 pkg/ingress/controller.go          | 58 +++++++++++++++++++-------------------
 pkg/ingress/endpoint.go            |  8 +++---
 pkg/ingress/endpointslice.go       |  6 ++--
 pkg/ingress/gateway.go             |  2 +-
 pkg/ingress/ingress.go             |  4 +--
 pkg/ingress/namespace.go           | 40 +++++++++++++++++---------
 pkg/ingress/pod.go                 |  6 ++--
 pkg/ingress/pod_test.go            | 18 ++++++------
 pkg/ingress/secret.go              |  8 +++---
 15 files changed, 100 insertions(+), 88 deletions(-)

diff --git a/pkg/ingress/apisix_consumer.go b/pkg/ingress/apisix_consumer.go
index ce65cca..e007c3e 100644
--- a/pkg/ingress/apisix_consumer.go
+++ b/pkg/ingress/apisix_consumer.go
@@ -158,7 +158,7 @@ func (c *apisixConsumerController) onAdd(obj interface{}) {
                log.Errorf("found ApisixConsumer resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixConsumer add event arrived",
@@ -184,7 +184,7 @@ func (c *apisixConsumerController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorf("found ApisixConsumer resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixConsumer update event arrived",
@@ -215,7 +215,7 @@ func (c *apisixConsumerController) onDelete(obj 
interface{}) {
                log.Errorf("found ApisixConsumer resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixConsumer delete event arrived",
diff --git a/pkg/ingress/apisix_pluginconfig.go 
b/pkg/ingress/apisix_pluginconfig.go
index 6b79299..be90735 100644
--- a/pkg/ingress/apisix_pluginconfig.go
+++ b/pkg/ingress/apisix_pluginconfig.go
@@ -248,7 +248,7 @@ func (c *apisixPluginConfigController) onAdd(obj 
interface{}) {
                log.Errorf("found ApisixPluginConfig resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixPluginConfig add event arrived",
@@ -277,7 +277,7 @@ func (c *apisixPluginConfigController) onUpdate(oldObj, 
newObj interface{}) {
                log.Errorf("found ApisixPluginConfig resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixPluginConfig update event arrived",
@@ -310,7 +310,7 @@ func (c *apisixPluginConfigController) onDelete(obj 
interface{}) {
                log.Errorf("found ApisixPluginConfig resource with bad meta 
namesapce key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixPluginConfig delete event arrived",
diff --git a/pkg/ingress/apisix_route.go b/pkg/ingress/apisix_route.go
index 8d601a4..7b6ed53 100644
--- a/pkg/ingress/apisix_route.go
+++ b/pkg/ingress/apisix_route.go
@@ -337,7 +337,7 @@ func (c *apisixRouteController) onAdd(obj interface{}) {
                log.Errorf("found ApisixRoute resource with bad meta namespace 
key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixRoute add event arrived",
@@ -366,7 +366,7 @@ func (c *apisixRouteController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorf("found ApisixRoute resource with bad meta namespace 
key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixRoute update event arrived",
@@ -399,7 +399,7 @@ func (c *apisixRouteController) onDelete(obj interface{}) {
                log.Errorf("found ApisixRoute resource with bad meta namesapce 
key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixRoute delete event arrived",
diff --git a/pkg/ingress/apisix_tls.go b/pkg/ingress/apisix_tls.go
index dfad187..c2865f8 100644
--- a/pkg/ingress/apisix_tls.go
+++ b/pkg/ingress/apisix_tls.go
@@ -189,7 +189,7 @@ func (c *apisixTlsController) onAdd(obj interface{}) {
                log.Errorf("found ApisixTls object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixTls add event arrived",
@@ -214,7 +214,7 @@ func (c *apisixTlsController) onUpdate(prev, curr 
interface{}) {
                log.Errorf("found ApisixTls object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixTls update event arrived",
@@ -246,7 +246,7 @@ func (c *apisixTlsController) onDelete(obj interface{}) {
                log.Errorf("found ApisixTls resource with bad meta namespace 
key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixTls delete event arrived",
diff --git a/pkg/ingress/apisix_upstream.go b/pkg/ingress/apisix_upstream.go
index 3a1aab2..835ec64 100644
--- a/pkg/ingress/apisix_upstream.go
+++ b/pkg/ingress/apisix_upstream.go
@@ -221,7 +221,7 @@ func (c *apisixUpstreamController) onAdd(obj interface{}) {
                log.Errorf("found ApisixUpstream resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixUpstream add event arrived",
@@ -246,7 +246,7 @@ func (c *apisixUpstreamController) onUpdate(oldObj, newObj 
interface{}) {
                log.Errorf("found ApisixUpstream resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixUpstream update event arrived",
@@ -277,7 +277,7 @@ func (c *apisixUpstreamController) onDelete(obj 
interface{}) {
                log.Errorf("found ApisixUpstream resource with bad meta 
namespace key: %s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("ApisixUpstream delete event arrived",
diff --git a/pkg/ingress/compare.go b/pkg/ingress/compare.go
index 9acd7dd..05c7521 100644
--- a/pkg/ingress/compare.go
+++ b/pkg/ingress/compare.go
@@ -46,8 +46,8 @@ func (c *Controller) CompareResources(ctx context.Context) 
error {
                consumerMapA6     = make(map[string]string)
                pluginConfigMapA6 = make(map[string]string)
        )
-       // watchingNamespace == nil means to monitor all namespaces
-       if !validation.HasValueInSyncMap(c.watchingNamespace) {
+       // watchingNamespaces == nil means to monitor all namespaces
+       if !validation.HasValueInSyncMap(c.watchingNamespaces) {
                opts := v1.ListOptions{}
                // list all namespaces
                nsList, err := 
c.kubeClient.Client.CoreV1().Namespaces().List(ctx, opts)
@@ -59,11 +59,11 @@ func (c *Controller) CompareResources(ctx context.Context) 
error {
                        for _, v := range nsList.Items {
                                wns.Store(v.Name, struct{}{})
                        }
-                       c.watchingNamespace = wns
+                       c.watchingNamespaces = wns
                }
        }
 
-       c.watchingNamespace.Range(func(key, value interface{}) bool {
+       c.watchingNamespaces.Range(func(key, value interface{}) bool {
                wg.Add(1)
                go func(ns string) {
                        defer wg.Done()
diff --git a/pkg/ingress/controller.go b/pkg/ingress/controller.go
index 0496a78..ecb8c00 100644
--- a/pkg/ingress/controller.go
+++ b/pkg/ingress/controller.go
@@ -68,18 +68,18 @@ const (
 
 // Controller is the ingress apisix controller object.
 type Controller struct {
-       name              string
-       namespace         string
-       cfg               *config.Config
-       wg                sync.WaitGroup
-       watchingNamespace *sync.Map
-       watchingLabels    types.Labels
-       apisix            apisix.APISIX
-       podCache          types.PodCache
-       translator        translation.Translator
-       apiServer         *api.Server
-       MetricsCollector  metrics.Collector
-       kubeClient        *kube.KubeClient
+       name               string
+       namespace          string
+       cfg                *config.Config
+       wg                 sync.WaitGroup
+       watchingNamespaces *sync.Map
+       watchingLabels     types.Labels
+       apisix             apisix.APISIX
+       podCache           types.PodCache
+       translator         translation.Translator
+       apiServer          *api.Server
+       MetricsCollector   metrics.Collector
+       kubeClient         *kube.KubeClient
        // recorder event
        recorder record.EventRecorder
        // this map enrolls which ApisixTls objects refer to a Kubernetes
@@ -181,17 +181,17 @@ func NewController(cfg *config.Config) (*Controller, 
error) {
        
eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: 
kubeClient.Client.CoreV1().Events("")})
 
        c := &Controller{
-               name:              podName,
-               namespace:         podNamespace,
-               cfg:               cfg,
-               apiServer:         apiSrv,
-               apisix:            client,
-               MetricsCollector:  metrics.NewPrometheusCollector(),
-               kubeClient:        kubeClient,
-               watchingNamespace: watchingNamespace,
-               watchingLabels:    watchingLabels,
-               secretSSLMap:      new(sync.Map),
-               recorder:          eventBroadcaster.NewRecorder(scheme.Scheme, 
v1.EventSource{Component: _component}),
+               name:               podName,
+               namespace:          podNamespace,
+               cfg:                cfg,
+               apiServer:          apiSrv,
+               apisix:             client,
+               MetricsCollector:   metrics.NewPrometheusCollector(),
+               kubeClient:         kubeClient,
+               watchingNamespaces: watchingNamespace,
+               watchingLabels:     watchingLabels,
+               secretSSLMap:       new(sync.Map),
+               recorder:           eventBroadcaster.NewRecorder(scheme.Scheme, 
v1.EventSource{Component: _component}),
 
                podCache: types.NewPodCache(),
        }
@@ -442,8 +442,8 @@ func (c *Controller) run(ctx context.Context) {
 
        c.initWhenStartLeading()
 
-       // list namesapce and init watchingNamespace
-       if err := c.initWatchingNamespaceByLabels(ctx); err != nil {
+       // list namespaces and init watchingNamespaces
+       if err := c.initWatchingNamespacesByLabels(ctx); err != nil {
                ctx.Done()
                return
        }
@@ -552,10 +552,10 @@ func (c *Controller) run(ctx context.Context) {
        c.wg.Wait()
 }
 
-// namespaceWatching accepts a resource key, getting the namespace part
+// isWatchingNamespace accepts a resource key, getting the namespace part
 // and checking whether the namespace is being watched.
-func (c *Controller) namespaceWatching(key string) (ok bool) {
-       if !validation.HasValueInSyncMap(c.watchingNamespace) {
+func (c *Controller) isWatchingNamespace(key string) (ok bool) {
+       if !validation.HasValueInSyncMap(c.watchingNamespaces) {
                ok = true
                return
        }
@@ -566,7 +566,7 @@ func (c *Controller) namespaceWatching(key string) (ok 
bool) {
                log.Warnf("resource %s was ignored since: %s", key, err)
                return
        }
-       _, ok = c.watchingNamespace.Load(ns)
+       _, ok = c.watchingNamespaces.Load(ns)
        return
 }
 
diff --git a/pkg/ingress/endpoint.go b/pkg/ingress/endpoint.go
index a85d588..9464d59 100644
--- a/pkg/ingress/endpoint.go
+++ b/pkg/ingress/endpoint.go
@@ -106,7 +106,7 @@ func (c *endpointsController) onAdd(obj interface{}) {
                log.Errorf("found endpoints object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("endpoints add event arrived",
@@ -133,7 +133,7 @@ func (c *endpointsController) onUpdate(prev, curr 
interface{}) {
                log.Errorf("found endpoints object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("endpoints update event arrived",
@@ -160,10 +160,10 @@ func (c *endpointsController) onDelete(obj interface{}) {
                ep = tombstone.Obj.(*corev1.Endpoints)
        }
 
-       // FIXME Refactor Controller.namespaceWatching to just use
+       // FIXME Refactor Controller.isWatchingNamespace to just use
        // namespace after all controllers use the same way to fetch
        // the object.
-       if !c.controller.namespaceWatching(ep.Namespace + "/" + ep.Name) {
+       if !c.controller.isWatchingNamespace(ep.Namespace + "/" + ep.Name) {
                return
        }
        log.Debugw("endpoints delete event arrived",
diff --git a/pkg/ingress/endpointslice.go b/pkg/ingress/endpointslice.go
index aece7ce..5c09998 100644
--- a/pkg/ingress/endpointslice.go
+++ b/pkg/ingress/endpointslice.go
@@ -124,7 +124,7 @@ func (c *endpointSliceController) onAdd(obj interface{}) {
        if err != nil {
                log.Errorf("found endpointSlice object with bad namespace")
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        ep := obj.(*discoveryv1.EndpointSlice)
@@ -165,7 +165,7 @@ func (c *endpointSliceController) onUpdate(prev, curr 
interface{}) {
                log.Errorf("found endpointSlice object with bad namespace/name: 
%s, ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        if currEp.Labels[discoveryv1.LabelManagedBy] != 
_endpointSlicesManagedBy {
@@ -209,7 +209,7 @@ func (c *endpointSliceController) onDelete(obj interface{}) 
{
                log.Errorf("found endpointSlice object with bad namespace/name: 
%s, ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        if ep.Labels[discoveryv1.LabelManagedBy] != _endpointSlicesManagedBy {
diff --git a/pkg/ingress/gateway.go b/pkg/ingress/gateway.go
index af92eb4..6f3eefa 100644
--- a/pkg/ingress/gateway.go
+++ b/pkg/ingress/gateway.go
@@ -139,7 +139,7 @@ func (c *gatewayController) onAdd(obj interface{}) {
                log.Errorf("found gateway resource with bad meta namespace key: 
%s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("gateway add event arrived",
diff --git a/pkg/ingress/ingress.go b/pkg/ingress/ingress.go
index c97dc83..f3d650f 100644
--- a/pkg/ingress/ingress.go
+++ b/pkg/ingress/ingress.go
@@ -259,7 +259,7 @@ func (c *ingressController) onAdd(obj interface{}) {
                log.Errorf("found ingress resource with bad meta namespace key: 
%s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
 
@@ -340,7 +340,7 @@ func (c *ingressController) OnDelete(obj interface{}) {
                log.Errorf("found ingress resource with bad meta namespace key: 
%s", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        valid := c.isIngressEffective(ing)
diff --git a/pkg/ingress/namespace.go b/pkg/ingress/namespace.go
index 31da666..0307151 100644
--- a/pkg/ingress/namespace.go
+++ b/pkg/ingress/namespace.go
@@ -20,6 +20,7 @@ import (
 
        "go.uber.org/zap"
        corev1 "k8s.io/api/core/v1"
+       k8serrors "k8s.io/apimachinery/pkg/api/errors"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/apimachinery/pkg/labels"
        "k8s.io/client-go/tools/cache"
@@ -51,7 +52,7 @@ func (c *Controller) newNamespaceController() 
*namespaceController {
        return ctl
 }
 
-func (c *Controller) initWatchingNamespaceByLabels(ctx context.Context) error {
+func (c *Controller) initWatchingNamespacesByLabels(ctx context.Context) error 
{
        labelSelector := metav1.LabelSelector{MatchLabels: c.watchingLabels}
        opts := metav1.ListOptions{
                LabelSelector: labels.Set(labelSelector.MatchLabels).String(),
@@ -59,22 +60,25 @@ func (c *Controller) initWatchingNamespaceByLabels(ctx 
context.Context) error {
        namespaces, err := c.kubeClient.Client.CoreV1().Namespaces().List(ctx, 
opts)
        if err != nil {
                return err
-       } else {
-               for _, ns := range namespaces.Items {
-                       c.watchingNamespace.Store(ns.Name, struct{}{})
-               }
        }
+       var nss []string
+
+       for _, ns := range namespaces.Items {
+               nss = append(nss, ns.Name)
+               c.watchingNamespaces.Store(ns.Name, struct{}{})
+       }
+       log.Infow("label selector watching namespaces", 
zap.Strings("namespaces", nss))
+
        return nil
 }
 
 func (c *namespaceController) run(ctx context.Context) {
-       log.Info("namespace controller started")
-       defer log.Info("namespace controller exited")
-
        if ok := cache.WaitForCacheSync(ctx.Done(), 
c.controller.namespaceInformer.HasSynced); !ok {
-               log.Error("informers sync failed")
+               log.Error("namespace informers sync failed")
                return
        }
+       log.Info("namespace controller started")
+       defer log.Info("namespace controller exited")
        for i := 0; i < c.workers; i++ {
                go c.runWorker(ctx)
        }
@@ -100,17 +104,17 @@ func (c *namespaceController) sync(ctx context.Context, 
ev *types.Event) error {
                if err != nil {
                        return err
                } else {
-                       // if labels of namespace contains the watchingLabels, 
the namespace should be set to controller.watchingNamespace
+                       // if labels of namespace contains the watchingLabels, 
the namespace should be set to controller.watchingNamespaces
                        if 
c.controller.watchingLabels.IsSubsetOf(namespace.Labels) {
-                               
c.controller.watchingNamespace.Store(namespace.Name, struct{}{})
+                               
c.controller.watchingNamespaces.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)
+               if _, ok := 
c.controller.watchingNamespaces.Load(namespace.Name); ok {
+                       c.controller.watchingNamespaces.Delete(namespace.Name)
                }
-               // do nothing, if the namespace did not in 
controller.watchingNamespace
+               // do nothing, if the namespace did not in 
controller.watchingNamespaces
        }
        return nil
 }
@@ -118,6 +122,14 @@ func (c *namespaceController) sync(ctx context.Context, ev 
*types.Event) error {
 func (c *namespaceController) handleSyncErr(event *types.Event, err error) {
        name := event.Object.(string)
        if err != nil {
+               if k8serrors.IsNotFound(err) && event.Type != types.EventDelete 
{
+                       log.Infow("sync namespace but not found, ignore",
+                               zap.String("event_type", event.Type.String()),
+                               zap.String("namespace", event.Object.(string)),
+                       )
+                       c.workqueue.Forget(event)
+                       return
+               }
                log.Warnw("sync namespace info failed, will retry",
                        zap.String("namespace", name),
                        zap.Error(err),
diff --git a/pkg/ingress/pod.go b/pkg/ingress/pod.go
index be961a8..51a5cea 100644
--- a/pkg/ingress/pod.go
+++ b/pkg/ingress/pod.go
@@ -61,7 +61,7 @@ func (c *podController) onAdd(obj interface{}) {
                log.Errorf("found pod with bad namespace/name: %s, ignore it", 
err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("pod add event arrived",
@@ -87,7 +87,7 @@ func (c *podController) onAdd(obj interface{}) {
 func (c *podController) onUpdate(_, cur interface{}) {
        pod := cur.(*corev1.Pod)
 
-       if !c.controller.namespaceWatching(pod.Namespace + "/" + pod.Name) {
+       if !c.controller.isWatchingNamespace(pod.Namespace + "/" + pod.Name) {
                return
        }
        log.Debugw("pod update event arrived",
@@ -125,7 +125,7 @@ func (c *podController) onDelete(obj interface{}) {
                pod = tombstone.Obj.(*corev1.Pod)
        }
 
-       if !c.controller.namespaceWatching(pod.Namespace + "/" + pod.Name) {
+       if !c.controller.isWatchingNamespace(pod.Namespace + "/" + pod.Name) {
                return
        }
        log.Debugw("pod delete event arrived",
diff --git a/pkg/ingress/pod_test.go b/pkg/ingress/pod_test.go
index 10a2fe0..e12248d 100644
--- a/pkg/ingress/pod_test.go
+++ b/pkg/ingress/pod_test.go
@@ -32,9 +32,9 @@ func TestPodOnAdd(t *testing.T) {
        watchingNamespace.Store("default", struct{}{})
        ctl := &podController{
                controller: &Controller{
-                       watchingNamespace: watchingNamespace,
-                       podCache:          types.NewPodCache(),
-                       MetricsCollector:  metrics.NewPrometheusCollector(),
+                       watchingNamespaces: watchingNamespace,
+                       podCache:           types.NewPodCache(),
+                       MetricsCollector:   metrics.NewPrometheusCollector(),
                },
        }
 
@@ -74,9 +74,9 @@ func TestPodOnDelete(t *testing.T) {
        watchingNamespace.Store("default", struct{}{})
        ctl := &podController{
                controller: &Controller{
-                       watchingNamespace: watchingNamespace,
-                       podCache:          types.NewPodCache(),
-                       MetricsCollector:  metrics.NewPrometheusCollector(),
+                       watchingNamespaces: watchingNamespace,
+                       podCache:           types.NewPodCache(),
+                       MetricsCollector:   metrics.NewPrometheusCollector(),
                },
        }
 
@@ -119,9 +119,9 @@ func TestPodOnUpdate(t *testing.T) {
        watchingNamespace.Store("default", struct{}{})
        ctl := &podController{
                controller: &Controller{
-                       watchingNamespace: watchingNamespace,
-                       podCache:          types.NewPodCache(),
-                       MetricsCollector:  metrics.NewPrometheusCollector(),
+                       watchingNamespaces: watchingNamespace,
+                       podCache:           types.NewPodCache(),
+                       MetricsCollector:   metrics.NewPrometheusCollector(),
                },
        }
 
diff --git a/pkg/ingress/secret.go b/pkg/ingress/secret.go
index c42719a..d8e9b23 100644
--- a/pkg/ingress/secret.go
+++ b/pkg/ingress/secret.go
@@ -235,7 +235,7 @@ func (c *secretController) onAdd(obj interface{}) {
                log.Errorf("found secret object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
 
@@ -262,7 +262,7 @@ func (c *secretController) onUpdate(prev, curr interface{}) 
{
                log.Errorf("found secrets object with bad namespace/name: %s, 
ignore it", err)
                return
        }
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("secret update event arrived",
@@ -293,10 +293,10 @@ func (c *secretController) onDelete(obj interface{}) {
                log.Errorf("found secret resource with bad meta namespace key: 
%s", err)
                return
        }
-       // FIXME Refactor Controller.namespaceWatching to just use
+       // FIXME Refactor Controller.isWatchingNamespace to just use
        // namespace after all controllers use the same way to fetch
        // the object.
-       if !c.controller.namespaceWatching(key) {
+       if !c.controller.isWatchingNamespace(key) {
                return
        }
        log.Debugw("secret delete event arrived",

Reply via email to