Skip to content

Commit 3f0307a

Browse files
authored
Merge pull request #792 from aledbf/refactor-has-synced
Avoid checking if the controllers are synced
2 parents 5f71bde + 5472555 commit 3f0307a

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

core/pkg/ingress/controller/backend_ssl.go

-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121
"reflect"
2222
"strings"
23-
"time"
2423

2524
"github.com/golang/glog"
2625

@@ -37,12 +36,6 @@ import (
3736
func (ic *GenericController) syncSecret() {
3837
glog.V(3).Infof("starting syncing of secrets")
3938

40-
if !ic.controllersInSync() {
41-
time.Sleep(podStoreSyncedPollPeriod)
42-
glog.Warningf("deferring sync till endpoints controller has synced")
43-
return
44-
}
45-
4639
var cert *ingress.SSLCert
4740
var err error
4841

core/pkg/ingress/controller/controller.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"k8s.io/apimachinery/pkg/fields"
3232
"k8s.io/apimachinery/pkg/util/intstr"
33+
"k8s.io/apimachinery/pkg/util/runtime"
3334
"k8s.io/apimachinery/pkg/util/wait"
3435
clientset "k8s.io/client-go/kubernetes"
3536
"k8s.io/client-go/kubernetes/scheme"
@@ -322,15 +323,6 @@ func newIngressController(config *Configuration) *GenericController {
322323
return &ic
323324
}
324325

325-
func (ic *GenericController) controllersInSync() bool {
326-
return ic.ingController.HasSynced() &&
327-
ic.svcController.HasSynced() &&
328-
ic.endpController.HasSynced() &&
329-
ic.secrController.HasSynced() &&
330-
ic.mapController.HasSynced() &&
331-
ic.nodeController.HasSynced()
332-
}
333-
334326
// Info returns information about the backend
335327
func (ic GenericController) Info() *ingress.BackendInfo {
336328
return ic.cfg.Backend.Info()
@@ -379,11 +371,6 @@ func (ic *GenericController) syncIngress(key interface{}) error {
379371
return nil
380372
}
381373

382-
if !ic.controllersInSync() {
383-
time.Sleep(podStoreSyncedPollPeriod)
384-
return fmt.Errorf("deferring sync till endpoints controller has synced")
385-
}
386-
387374
upstreams, servers := ic.getBackendServers()
388375
var passUpstreams []*ingress.SSLPassthroughBackend
389376
for _, server := range servers {
@@ -1161,6 +1148,18 @@ func (ic GenericController) Start() {
11611148
go ic.secrController.Run(ic.stopCh)
11621149
go ic.mapController.Run(ic.stopCh)
11631150

1151+
// Wait for all involved caches to be synced, before processing items from the queue is started
1152+
if !cache.WaitForCacheSync(ic.stopCh,
1153+
ic.ingController.HasSynced,
1154+
ic.svcController.HasSynced,
1155+
ic.endpController.HasSynced,
1156+
ic.secrController.HasSynced,
1157+
ic.mapController.HasSynced,
1158+
ic.nodeController.HasSynced,
1159+
) {
1160+
runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync"))
1161+
}
1162+
11641163
go ic.syncQueue.Run(10*time.Second, ic.stopCh)
11651164

11661165
go wait.Forever(ic.syncSecret, 10*time.Second)

0 commit comments

Comments
 (0)