1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1419 from mrjana/lb

Do not try LB populate on interface-less endpoint
This commit is contained in:
Alessandro Boch 2016-08-30 21:40:28 +02:00 committed by GitHub
commit 622ea9d39a
2 changed files with 27 additions and 13 deletions

View file

@ -213,35 +213,44 @@ func TestNetworkRequest(t *testing.T) {
defer testutils.SetupTestOSContext(t)()
ipamutils.InitNetworks()
_, exp, err := net.ParseCIDR("172.17.0.0/16")
if err != nil {
t.Fatal(err)
}
nw, err := FindAvailableNetwork(ipamutils.PredefinedBroadNetworks)
if err != nil {
t.Fatal(err)
}
if !types.CompareIPNet(exp, nw) {
t.Fatalf("exected %s. got %s", exp, nw)
var found bool
for _, exp := range ipamutils.PredefinedBroadNetworks {
if types.CompareIPNet(exp, nw) {
found = true
break
}
}
_, exp, err = net.ParseCIDR("10.0.0.0/24")
if err != nil {
t.Fatal(err)
if !found {
t.Fatalf("Found unexpected broad network %s", nw)
}
nw, err = FindAvailableNetwork(ipamutils.PredefinedGranularNetworks)
if err != nil {
t.Fatal(err)
}
if !types.CompareIPNet(exp, nw) {
t.Fatalf("exected %s. got %s", exp, nw)
found = false
for _, exp := range ipamutils.PredefinedGranularNetworks {
if types.CompareIPNet(exp, nw) {
found = true
break
}
}
if !found {
t.Fatalf("Found unexpected granular network %s", nw)
}
// Add iface and ssert returned address on request
createInterface(t, "test", "172.17.42.1/16")
_, exp, err = net.ParseCIDR("172.18.0.0/16")
_, exp, err := net.ParseCIDR("172.18.0.0/16")
if err != nil {
t.Fatal(err)
}

View file

@ -267,6 +267,11 @@ func (n *network) connectedLoadbalancers() []*loadBalancer {
func (sb *sandbox) populateLoadbalancers(ep *endpoint) {
var gwIP net.IP
// This is an interface less endpoint. Nothing to do.
if ep.Iface() == nil {
return
}
n := ep.getNetwork()
eIP := ep.Iface().Address()