|
@@ -274,25 +274,30 @@ func (c *controller) networkWatchLoop(nw *netWatch, ep *endpoint, ecCh <-chan da
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|
|
- if _, ok := nw.remoteEps[lEp.ID()]; ok {
|
|
|
|
- delete(delEpMap, lEp.ID())
|
|
|
|
- continue
|
|
|
|
|
|
+ if ep, ok := nw.remoteEps[lEp.ID()]; ok {
|
|
|
|
+ // On a container rename EP ID will remain
|
|
|
|
+ // the same but the name will change. service
|
|
|
|
+ // records should reflect the change.
|
|
|
|
+ // Keep old EP entry in the delEpMap and add
|
|
|
|
+ // EP from the store (which has the new name)
|
|
|
|
+ // into the new list
|
|
|
|
+ if lEp.name == ep.name {
|
|
|
|
+ delete(delEpMap, lEp.ID())
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
nw.remoteEps[lEp.ID()] = lEp
|
|
nw.remoteEps[lEp.ID()] = lEp
|
|
addEp = append(addEp, lEp)
|
|
addEp = append(addEp, lEp)
|
|
-
|
|
|
|
}
|
|
}
|
|
c.Unlock()
|
|
c.Unlock()
|
|
|
|
|
|
- for _, lEp := range addEp {
|
|
|
|
- ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), true)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for _, lEp := range delEpMap {
|
|
for _, lEp := range delEpMap {
|
|
ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), false)
|
|
ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), false)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ for _, lEp := range addEp {
|
|
|
|
+ ep.getNetwork().updateSvcRecord(lEp, c.getLocalEps(nw), true)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -378,13 +383,13 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi
|
|
c.Unlock()
|
|
c.Unlock()
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *controller) watchLoop(nmap map[string]*netWatch) {
|
|
|
|
|
|
+func (c *controller) watchLoop() {
|
|
for {
|
|
for {
|
|
select {
|
|
select {
|
|
case ep := <-c.watchCh:
|
|
case ep := <-c.watchCh:
|
|
- c.processEndpointCreate(nmap, ep)
|
|
|
|
|
|
+ c.processEndpointCreate(c.nmap, ep)
|
|
case ep := <-c.unWatchCh:
|
|
case ep := <-c.unWatchCh:
|
|
- c.processEndpointDelete(nmap, ep)
|
|
|
|
|
|
+ c.processEndpointDelete(c.nmap, ep)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -392,7 +397,7 @@ func (c *controller) watchLoop(nmap map[string]*netWatch) {
|
|
func (c *controller) startWatch() {
|
|
func (c *controller) startWatch() {
|
|
c.watchCh = make(chan *endpoint)
|
|
c.watchCh = make(chan *endpoint)
|
|
c.unWatchCh = make(chan *endpoint)
|
|
c.unWatchCh = make(chan *endpoint)
|
|
- nmap := make(map[string]*netWatch)
|
|
|
|
|
|
+ c.nmap = make(map[string]*netWatch)
|
|
|
|
|
|
- go c.watchLoop(nmap)
|
|
|
|
|
|
+ go c.watchLoop()
|
|
}
|
|
}
|