From 61f3d9139b543dedfdb2fb06379a848f3cabaddc Mon Sep 17 00:00:00 2001 From: Mario Kleinsasser Date: Tue, 25 Jul 2017 15:21:07 +0200 Subject: [PATCH] Add hostname to DNS service discovery This closes #1854 which is related to moby/moby#34239 and docker/swarmkit#2325. Details of this patch are in the PR. Signed-off-by: Mario Kleinsasser --- agent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agent.go b/agent.go index b93ca288e0..cb1196c586 100644 --- a/agent.go +++ b/agent.go @@ -634,6 +634,11 @@ func (ep *endpoint) addServiceInfoToCluster(sb *sandbox) error { } } + // In any case, add the container hostName to the service discovery DNS + if err := c.addContainerNameResolution(n.ID(), ep.ID(), sb.config.hostName, ep.myAliases, ep.Iface().Address().IP, "addServiceInfoToCluster"); err != nil { + return err + } + buf, err := proto.Marshal(&EndpointRecord{ Name: name, ServiceName: ep.svcName, @@ -707,6 +712,11 @@ func (ep *endpoint) deleteServiceInfoFromCluster(sb *sandbox, method string) err } } + // In any case, delete the container hostName to the service discovery DNS + if err := c.delContainerNameResolution(n.ID(), ep.ID(), sb.config.hostName, ep.myAliases, ep.Iface().Address().IP, "deleteServiceInfoFromCluster"); err != nil { + return err + } + logrus.Debugf("deleteServiceInfoFromCluster from %s END for %s %s", method, ep.svcName, ep.ID()) return nil