Merge pull request #792 from aledbf/refactor-has-synced
Avoid checking if the controllers are synced
This commit is contained in:
commit
3f0307a96e
2 changed files with 13 additions and 21 deletions
|
@ -20,7 +20,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
@ -37,12 +36,6 @@ import (
|
||||||
func (ic *GenericController) syncSecret() {
|
func (ic *GenericController) syncSecret() {
|
||||||
glog.V(3).Infof("starting syncing of secrets")
|
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 cert *ingress.SSLCert
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import (
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
|
@ -322,15 +323,6 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
return &ic
|
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
|
// Info returns information about the backend
|
||||||
func (ic GenericController) Info() *ingress.BackendInfo {
|
func (ic GenericController) Info() *ingress.BackendInfo {
|
||||||
return ic.cfg.Backend.Info()
|
return ic.cfg.Backend.Info()
|
||||||
|
@ -379,11 +371,6 @@ func (ic *GenericController) syncIngress(key interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ic.controllersInSync() {
|
|
||||||
time.Sleep(podStoreSyncedPollPeriod)
|
|
||||||
return fmt.Errorf("deferring sync till endpoints controller has synced")
|
|
||||||
}
|
|
||||||
|
|
||||||
upstreams, servers := ic.getBackendServers()
|
upstreams, servers := ic.getBackendServers()
|
||||||
var passUpstreams []*ingress.SSLPassthroughBackend
|
var passUpstreams []*ingress.SSLPassthroughBackend
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
|
@ -1161,6 +1148,18 @@ func (ic GenericController) Start() {
|
||||||
go ic.secrController.Run(ic.stopCh)
|
go ic.secrController.Run(ic.stopCh)
|
||||||
go ic.mapController.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 ic.syncQueue.Run(10*time.Second, ic.stopCh)
|
||||||
|
|
||||||
go wait.Forever(ic.syncSecret, 10*time.Second)
|
go wait.Forever(ic.syncSecret, 10*time.Second)
|
||||||
|
|
Loading…
Reference in a new issue