mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add anonymous container alias to service record on attachable network
- Currently when a non-named container with network aliases is connected to a swarm attachable network, its aliases are not added to the service records. This is not in line with what we do when connecting to a local scope network, or to a kv-store based overlay network. Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
1b8c4b421b
commit
d718efd92f
1 changed files with 52 additions and 40 deletions
|
@ -463,6 +463,10 @@ func (ep *endpoint) deleteDriverInfoFromCluster() error {
|
|||
}
|
||||
|
||||
func (ep *endpoint) addServiceInfoToCluster() error {
|
||||
if ep.isAnonymous() && len(ep.myAliases) == 0 || ep.Iface().Address() == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
n := ep.getNetwork()
|
||||
if !n.isClusterEligible() {
|
||||
return nil
|
||||
|
@ -470,7 +474,7 @@ func (ep *endpoint) addServiceInfoToCluster() error {
|
|||
|
||||
c := n.getController()
|
||||
agent := c.getAgent()
|
||||
if !ep.isAnonymous() && ep.Iface().Address() != nil {
|
||||
|
||||
var ingressPorts []*PortConfig
|
||||
if ep.svcID != "" {
|
||||
// Gossip ingress ports only in ingress network.
|
||||
|
@ -483,8 +487,13 @@ func (ep *endpoint) addServiceInfoToCluster() error {
|
|||
}
|
||||
}
|
||||
|
||||
name := ep.Name()
|
||||
if ep.isAnonymous() {
|
||||
name = ep.MyAliases()[0]
|
||||
}
|
||||
|
||||
buf, err := proto.Marshal(&EndpointRecord{
|
||||
Name: ep.Name(),
|
||||
Name: name,
|
||||
ServiceName: ep.svcName,
|
||||
ServiceID: ep.svcID,
|
||||
VirtualIP: ep.virtualIP.String(),
|
||||
|
@ -503,12 +512,15 @@ func (ep *endpoint) addServiceInfoToCluster() error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ep *endpoint) deleteServiceInfoFromCluster() error {
|
||||
if ep.isAnonymous() && len(ep.myAliases) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
n := ep.getNetwork()
|
||||
if !n.isClusterEligible() {
|
||||
return nil
|
||||
|
@ -517,7 +529,6 @@ func (ep *endpoint) deleteServiceInfoFromCluster() error {
|
|||
c := n.getController()
|
||||
agent := c.getAgent()
|
||||
|
||||
if !ep.isAnonymous() {
|
||||
if ep.svcID != "" && ep.Iface().Address() != nil {
|
||||
var ingressPorts []*PortConfig
|
||||
if n.ingress {
|
||||
|
@ -528,12 +539,13 @@ func (ep *endpoint) deleteServiceInfoFromCluster() error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if agent != nil {
|
||||
if err := agent.networkDB.DeleteEntry("endpoint_table", n.ID(), ep.ID()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue