|
6 | 6 | log "github.com/Sirupsen/logrus" |
7 | 7 | "github.com/docker/libnetwork/discoverapi" |
8 | 8 | "github.com/docker/libnetwork/ipamapi" |
| 9 | + "github.com/docker/libnetwork/netlabel" |
9 | 10 | "github.com/docker/libnetwork/types" |
10 | 11 | ) |
11 | 12 |
|
@@ -64,14 +65,19 @@ func (a *allocator) ReleasePool(poolID string) error { |
64 | 65 | // RequestAddress returns an address from the specified pool ID. |
65 | 66 | // Always allocate the 0.0.0.0/32 ip if no preferred address was specified |
66 | 67 | func (a *allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) { |
67 | | - log.Debugf("RequestAddress(%s, %v, %v) %s", poolID, prefAddress, opts, opts["RequestAddressType"]) |
| 68 | + log.Debugf("RequestAddress(%s, %v, %v)", poolID, prefAddress, opts) |
68 | 69 | _, ipNet, err := net.ParseCIDR(poolID) |
69 | 70 |
|
70 | 71 | if err != nil { |
71 | 72 | return nil, nil, err |
72 | 73 | } |
73 | | - if prefAddress == nil { |
| 74 | + |
| 75 | + // TODO Windows: Remove this once the bug in docker daemon is fixed |
| 76 | + // that causes it to throw an exception on nil gateway |
| 77 | + if opts[ipamapi.RequestAddressType] == netlabel.Gateway { |
74 | 78 | return ipNet, nil, nil |
| 79 | + } else if prefAddress == nil { |
| 80 | + return nil, nil, nil |
75 | 81 | } |
76 | 82 | return &net.IPNet{IP: prefAddress, Mask: ipNet.Mask}, nil, nil |
77 | 83 | } |
|
0 commit comments