d2iq-archive / mesos-dns

DNS-based service discovery for Mesos.
https://mesosphere.github.com/mesos-dns
Apache License 2.0
483 stars 137 forks source link

Wait for a reload before serving DNS #491

Closed nlsun closed 7 years ago

nlsun commented 7 years ago

@mesosphere-ci retest me please

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

gpaul commented 7 years ago

Consider using a channel instead of a bool for ready in the resolver. Then where you set ready=true, res.readyCh <- true instead. And change Ready() to WaitUntilReady()

func WaitUntilReady() {
  <-res.readyCh
}

This way you don't need the sleep.

If you had several people calling Ready() (or WaitUntilReady()) you would have to use close(res.readyCh) instead of just sending a bool to it. In that case, just be careful because you will need to replace res.readyCh with a fresh channel at the top of Reload() so you don't get a close of closed channel error. And then you'll need the lock to prevent racing on res.readyCh :p

nlsun commented 7 years ago

@gpaul Agreed, I've switched to using a channel.

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

nlsun commented 7 years ago

@mesosphere-ci Retest this please.

gpaul commented 7 years ago

Nice one :ship:

nlsun commented 7 years ago

@mesosphere-ci Retest this please.