Merge pull request #792 from aledbf/refactor-has-synced

Avoid checking if the controllers are synced
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-05-29 20:38:30 -04:00 committed by GitHub
commit 3f0307a96e
2 changed files with 13 additions and 21 deletions

View file

@ -20,7 +20,6 @@ import (
"fmt"
"reflect"
"strings"
"time"
"github.com/golang/glog"
@ -37,12 +36,6 @@ import (
func (ic *GenericController) syncSecret() {
glog.V(3).Infof("starting syncing of secrets")
if !ic.controllersInSync() {
time.Sleep(podStoreSyncedPollPeriod)
glog.Warningf("deferring sync till endpoints controller has synced")
return
}
var cert *ingress.SSLCert
var err error

View file

@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
@ -322,15 +323,6 @@ func newIngressController(config *Configuration) *GenericController {
return &ic
}
func (ic *GenericController) controllersInSync() bool {
return ic.ingController.HasSynced() &&
ic.svcController.HasSynced() &&
ic.endpController.HasSynced() &&
ic.secrController.HasSynced() &&
ic.mapController.HasSynced() &&
ic.nodeController.HasSynced()
}
// Info returns information about the backend
func (ic GenericController) Info() *ingress.BackendInfo {
return ic.cfg.Backend.Info()
@ -379,11 +371,6 @@ func (ic *GenericController) syncIngress(key interface{}) error {
return nil
}
if !ic.controllersInSync() {
time.Sleep(podStoreSyncedPollPeriod)
return fmt.Errorf("deferring sync till endpoints controller has synced")
}
upstreams, servers := ic.getBackendServers()
var passUpstreams []*ingress.SSLPassthroughBackend
for _, server := range servers {
@ -1161,6 +1148,18 @@ func (ic GenericController) Start() {
go ic.secrController.Run(ic.stopCh)
go ic.mapController.Run(ic.stopCh)
// Wait for all involved caches to be synced, before processing items from the queue is started
if !cache.WaitForCacheSync(ic.stopCh,
ic.ingController.HasSynced,
ic.svcController.HasSynced,
ic.endpController.HasSynced,
ic.secrController.HasSynced,
ic.mapController.HasSynced,
ic.nodeController.HasSynced,
) {
runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync"))
}
go ic.syncQueue.Run(10*time.Second, ic.stopCh)
go wait.Forever(ic.syncSecret, 10*time.Second)