mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1274 from aboch/gsr
Make getSvcRecords() more robust
This commit is contained in:
commit
467ac53445
1 changed files with 10 additions and 2 deletions
|
@ -1099,14 +1099,22 @@ func (n *network) getSvcRecords(ep *endpoint) []etchosts.Record {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
defer n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
|
if ep == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var recs []etchosts.Record
|
var recs []etchosts.Record
|
||||||
sr, _ := n.ctrlr.svcRecords[n.id]
|
sr, _ := n.ctrlr.svcRecords[n.id]
|
||||||
|
epName := ep.Name()
|
||||||
|
|
||||||
for h, ip := range sr.svcMap {
|
for h, ip := range sr.svcMap {
|
||||||
if ep != nil && strings.Split(h, ".")[0] == ep.Name() {
|
if strings.Split(h, ".")[0] == epName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(ip) == 0 {
|
||||||
|
log.Warnf("Found empty list of IP addresses for service %s on network %s (%s)", h, n.Name(), n.ID())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
recs = append(recs, etchosts.Record{
|
recs = append(recs, etchosts.Record{
|
||||||
Hosts: h,
|
Hosts: h,
|
||||||
IP: ip[0].String(),
|
IP: ip[0].String(),
|
||||||
|
|
Loading…
Reference in a new issue