diff options
author | 2017-10-20 22:53:17 +0100 | |
---|---|---|
committer | 2017-10-20 22:53:17 +0100 | |
commit | d64b684831aff2df86d9cea8e23bf57c85b6772f (patch) | |
tree | 7bf9e27b01d11b648255be9dc00e5964747772ba /plugin/kubernetes/controller.go | |
parent | c1f67493de3f13373082ee2e1ec6234c15642854 (diff) | |
download | coredns-d64b684831aff2df86d9cea8e23bf57c85b6772f.tar.gz coredns-d64b684831aff2df86d9cea8e23bf57c85b6772f.tar.zst coredns-d64b684831aff2df86d9cea8e23bf57c85b6772f.zip |
plugin/kubernetes: implement HasSynced() (#1155)
* plugin/kubernetes: wait until api is ready
Wait for HasSynced before allowing startup to avoid startup race.
Also do a small refactor in findServices() to pull a check out of the
loop - only needs to be done once.
* sigh
Diffstat (limited to 'plugin/kubernetes/controller.go')
-rw-r--r-- | plugin/kubernetes/controller.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/plugin/kubernetes/controller.go b/plugin/kubernetes/controller.go index a3145bf3d..3cad9e6c2 100644 --- a/plugin/kubernetes/controller.go +++ b/plugin/kubernetes/controller.go @@ -38,6 +38,7 @@ type dnsController interface { GetNodeByName(string) (*api.Node, error) Run() + HasSynced() bool Stop() error } @@ -229,17 +230,6 @@ func endpointsWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) } } -func (dns *dnsControl) controllersInSync() bool { - hs := dns.svcController.HasSynced() && - dns.epController.HasSynced() - - if dns.podController != nil { - hs = hs && dns.podController.HasSynced() - } - - return hs -} - // Stop stops the controller. func (dns *dnsControl) Stop() error { dns.stopLock.Lock() @@ -266,6 +256,17 @@ func (dns *dnsControl) Run() { <-dns.stopCh } +// HasSynced calls on all controllers. +func (dns *dnsControl) HasSynced() bool { + a := dns.svcController.HasSynced() + b := dns.epController.HasSynced() + c := true + if dns.podController != nil { + c = dns.podController.HasSynced() + } + return a && b && c +} + func (dns *dnsControl) ServiceList() (svcs []*api.Service) { os := dns.svcLister.List() for _, o := range os { |