mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Unblock startup if kubernetes API is unavailable (#2126)
This commit is contained in:
committed by
Chris O'Haver
parent
fdb31a27f3
commit
6539a10a62
@@ -77,13 +77,19 @@ func (k *Kubernetes) RegisterKubeCache(c *caddy.Controller) {
|
||||
if k.APIProxy != nil {
|
||||
k.APIProxy.Run()
|
||||
}
|
||||
synced := false
|
||||
for synced == false {
|
||||
synced = k.APIConn.HasSynced()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
return nil
|
||||
timeout := time.After(5 * time.Second)
|
||||
ticker := time.NewTicker(100 * time.Millisecond)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if k.APIConn.HasSynced() {
|
||||
return nil
|
||||
}
|
||||
case <-timeout:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
c.OnShutdown(func() error {
|
||||
|
||||
Reference in New Issue
Block a user