diff --git a/pkg/allocate/allocate.go b/pkg/allocate/allocate.go index afb5d14c4..76ac2ce64 100644 --- a/pkg/allocate/allocate.go +++ b/pkg/allocate/allocate.go @@ -119,12 +119,12 @@ func IterateForAssignment(ipnet net.IPNet, rangeStart net.IP, rangeEnd net.IP, r // within ipnet, and make sure that ip is smaller than lastIP. for ip := firstIP; ipnet.Contains(ip) && iphelpers.CompareIPs(ip, lastIP) <= 0; ip = iphelpers.IncIP(ip) { // If already reserved, skip it. - if reserved[ip.String()] { - if reserved[ip.String()] == podRef { - logging.Debugf("Found existing reservation %v with matching podRef %s", ip.String(), podRef) - } else { - continue; - } + ref, exist := reserved[ip.String()] + if exist { + if ref != podRef { + continue + } + logging.Debugf("Found existing reservation %v with matching podRef %s", ip.String(), podRef) } // If this IP is within the range of one of the excluded subnets, jump to the exluded subnet's broadcast address // and skip.