From 379609e362013a5ed81367c19dbdc5c8193c2edc Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Tue, 20 Oct 2015 23:03:51 -0700 Subject: [PATCH] Allow remote ipam driver to return nil address - This brings the remote ipam driver in pair with the local one. As of now remote driver package is assuming a valid address in CIDR form is always present in a nil error AddressRequestResponse, which is no longer true as community has requested to remove this limitation. - We are ok to remove it until we can provide a null ipam driver option in future releases. Signed-off-by: Alessandro Boch --- libnetwork/ipams/remote/remote.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnetwork/ipams/remote/remote.go b/libnetwork/ipams/remote/remote.go index f9df525ced..3aefd430ab 100644 --- a/libnetwork/ipams/remote/remote.go +++ b/libnetwork/ipams/remote/remote.go @@ -78,7 +78,11 @@ func (a *allocator) ReleasePool(poolID string) error { // RequestAddress requests an address from the address pool func (a *allocator) RequestAddress(poolID string, address net.IP, options map[string]string) (*net.IPNet, map[string]string, error) { - var prefAddress string + var ( + prefAddress string + retAddress *net.IPNet + err error + ) if address != nil { prefAddress = address.String() } @@ -87,7 +91,9 @@ func (a *allocator) RequestAddress(poolID string, address net.IP, options map[st if err := a.call("RequestAddress", req, res); err != nil { return nil, nil, err } - retAddress, err := types.ParseCIDR(res.Address) + if res.Address != "" { + retAddress, err = types.ParseCIDR(res.Address) + } return retAddress, res.Data, err }