From 69e766e042ed8fe7702a40efa7bb36e8ce8e30e3 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Fri, 4 Aug 2017 14:22:06 -0400 Subject: [PATCH] Remove unnecessary periodic sync --- core/pkg/ingress/controller/controller.go | 8 +++++--- core/pkg/ingress/controller/launch.go | 9 +++++++-- core/pkg/ingress/status/status.go | 17 ----------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/core/pkg/ingress/controller/controller.go b/core/pkg/ingress/controller/controller.go index 1d5073d1be..5ad25cb860 100644 --- a/core/pkg/ingress/controller/controller.go +++ b/core/pkg/ingress/controller/controller.go @@ -232,7 +232,9 @@ func newIngressController(config *Configuration) *GenericController { ic.syncQueue.Enqueue(obj) }, UpdateFunc: func(old, cur interface{}) { - if !reflect.DeepEqual(old, cur) { + oep := old.(*api.Endpoints) + ocur := cur.(*api.Endpoints) + if !reflect.DeepEqual(ocur.Subsets, oep.Subsets) { ic.syncQueue.Enqueue(cur) } }, @@ -410,7 +412,7 @@ func (ic *GenericController) syncIngress(key interface{}) error { PassthroughBackends: passUpstreams, } - if !ic.forceReload || ic.runningConfig != nil && ic.runningConfig.Equal(&pcfg) { + if !ic.forceReload && ic.runningConfig != nil && ic.runningConfig.Equal(&pcfg) { glog.V(3).Infof("skipping backend reload (no changes detected)") return nil } @@ -1257,7 +1259,7 @@ func (ic GenericController) Start() { runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync")) } - go ic.syncQueue.Run(10*time.Second, ic.stopCh) + go ic.syncQueue.Run(time.Second, ic.stopCh) if ic.syncStatus != nil { go ic.syncStatus.Run(ic.stopCh) diff --git a/core/pkg/ingress/controller/launch.go b/core/pkg/ingress/controller/launch.go index 04458234f4..c11ef4aec3 100644 --- a/core/pkg/ingress/controller/launch.go +++ b/core/pkg/ingress/controller/launch.go @@ -8,6 +8,7 @@ import ( "net/http/pprof" "os" "syscall" + "time" "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -64,8 +65,8 @@ func NewIngressController(backend ingress.Controller) *GenericController { service with the format namespace/serviceName and the port of the service could be a number of the name of the port.`) - resyncPeriod = flags.Duration("sync-period", 0, - `Relist and confirm cloud resources this often. Default is 0 (no resync)`) + resyncPeriod = flags.Duration("sync-period", 600*time.Second, + `Relist and confirm cloud resources this often. Default is 10 minutes`) watchNamespace = flags.String("watch-namespace", api.NamespaceAll, `Namespace to watch for Ingress. Default is to watch all namespaces`) @@ -148,6 +149,10 @@ func NewIngressController(backend ingress.Controller) *GenericController { } } + if resyncPeriod.Seconds() < 10 { + glog.Fatalf("resync period (%vs) is too low", resyncPeriod.Seconds()) + } + err = os.MkdirAll(ingress.DefaultSSLDirectory, 0655) if err != nil { glog.Errorf("Failed to mkdir SSL directory: %v", err) diff --git a/core/pkg/ingress/status/status.go b/core/pkg/ingress/status/status.go index 9150ba5e24..036057a325 100644 --- a/core/pkg/ingress/status/status.go +++ b/core/pkg/ingress/status/status.go @@ -92,10 +92,7 @@ type statusSync struct { // Run starts the loop to keep the status in sync func (s statusSync) Run(stopCh <-chan struct{}) { go wait.Forever(s.elector.Run, 0) - go s.run() - go s.syncQueue.Run(time.Second, stopCh) - <-stopCh } @@ -136,20 +133,6 @@ func (s statusSync) Shutdown() { s.updateStatus([]v1.LoadBalancerIngress{}) } -func (s *statusSync) run() { - err := wait.PollInfinite(updateInterval, func() (bool, error) { - if s.syncQueue.IsShuttingDown() { - return true, nil - } - // send a dummy object to the queue to force a sync - s.syncQueue.Enqueue("dummy") - return false, nil - }) - if err != nil { - glog.Errorf("error waiting shutdown: %v", err) - } -} - func (s *statusSync) sync(key interface{}) error { s.runLock.Lock() defer s.runLock.Unlock()