Refactor: additional DNS names registration
This commit is contained in:
1 parent
fa5e032e49
commit
acbd744372
1 file changed
+16
-4
+16
-4
@@ -29,6 +29,12 @@ func (w *watcher) ContainerStarted(id string) {
|
|||||||
w.driver.warn("ContainerStarted", "error inspecting container %s: %s", id, err)
|
w.driver.warn("ContainerStarted", "error inspecting container %s: %s", id, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
domain, err := w.weave.DNSDomain()
|
||||||
|
if err != nil {
|
||||||
|
w.driver.warn("ContainerStarted", "unable to get weave dns domain: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
// check that it's on our network
|
// check that it's on our network
|
||||||
for _, net := range info.NetworkSettings.Networks {
|
for _, net := range info.NetworkSettings.Networks {
|
||||||
network, err := w.driver.findNetworkInfo(net.NetworkID)
|
network, err := w.driver.findNetworkInfo(net.NetworkID)
|
||||||
@@ -39,11 +45,17 @@ func (w *watcher) ContainerStarted(id string) {
|
|||||||
if network.isOurs {
|
if network.isOurs {
|
||||||
if w.driver.dns {
|
if w.driver.dns {
|
||||||
fqdn := fmt.Sprintf("%s.%s", info.Config.Hostname, info.Config.Domainname)
|
fqdn := fmt.Sprintf("%s.%s", info.Config.Hostname, info.Config.Domainname)
|
||||||
weaveDomain, _ := w.weave.DNSDomain()
|
|
||||||
// Container name is prefixed with '/' so we cut first character
|
aliases := make([]string, 0, len(net.Aliases)+2)
|
||||||
name := fmt.Sprintf("%s.%s", info.Name[1:], weaveDomain)
|
aliases = append(aliases, fqdn)
|
||||||
aliases := append([]string(nil), fqdn, name)
|
|
||||||
|
if len(domain) > 0 && len(info.Name) > 1 && info.Name[0] == "/" {
|
||||||
|
name := fmt.Sprintf("%s.%s", info.Name[1:], domain)
|
||||||
|
aliases = append(aliases, name)
|
||||||
|
}
|
||||||
|
|
||||||
aliases = append(aliases, net.Aliases...)
|
aliases = append(aliases, net.Aliases...)
|
||||||
|
|
||||||
for _, alias := range aliases {
|
for _, alias := range aliases {
|
||||||
w.driver.debug("ContainerStarted", "going to register %s with weaveDNS", alias)
|
w.driver.debug("ContainerStarted", "going to register %s with weaveDNS", alias)
|
||||||
if err := w.weave.RegisterWithDNS(id, alias, net.IPAddress); err != nil {
|
if err := w.weave.RegisterWithDNS(id, alias, net.IPAddress); err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user