Skip to content

Commit

Permalink
Add hostname to DNS service discovery
Browse files Browse the repository at this point in the history
This closes #1854 which is related to moby/moby#34239 and
moby/swarmkit#2325.

Details of this patch are in the PR.

Signed-off-by: Mario Kleinsasser <[email protected]>
  • Loading branch information
m4r10k committed Jul 25, 2017
1 parent c3393f1 commit 61f3d91
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 61f3d91

@abhi
Copy link
Contributor

@abhi abhi commented on 61f3d91 Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change by itself LGTM. But there is no way to prevent duplicate hostnames. With service names and task.servicename or task.servicename.network there is a unique dns name to resolve to.
In case of etcd or consul which I understand is the use case it causes an issue if I just launch a container with the etcd servicename.task_slot and I am part of the cluster. Would it be less overhead to start etcd cluster pointing to the cluster dns itself ? I havent really tried this. I feel this might just be a way to misconfig and screw up of a one service by a standlone container. I am still thinking over the possiblities. I will probably circle back if there might be other simpler solutions.

Please sign in to comment.