Merge pull request #19580 from WeixuZhuang/node

resolve the bug when cluster CIDR is not /8
This commit is contained in:
Alex Mohr 2016-01-21 10:34:19 -08:00
commit 94b2490eba

View File

@ -19,6 +19,7 @@ package node
import ( import (
"errors" "errors"
"fmt" "fmt"
"math"
"net" "net"
"strconv" "strconv"
"strings" "strings"
@ -212,8 +213,9 @@ func (nc *NodeController) generateAvailableCIDRs() {
nc.generatedCIDR = true nc.generatedCIDR = true
// Generate all available CIDRs here, since there will not be manay // Generate all available CIDRs here, since there will not be manay
// available CIDRs. Set will be small, it will use less than 1MB memory // available CIDRs. Set will be small, it will use less than 1MB memory
cidrIP := nc.clusterCIDR.IP.To4()
nc.maxCIDRs = (256-int(cidrIP[1]))*256 - int(cidrIP[2]) cidrSize, _ := nc.clusterCIDR.Mask.Size()
nc.maxCIDRs = int(math.Pow(2, (float64)(24-cidrSize)))
for i := 0; i <= nc.maxCIDRs; i++ { for i := 0; i <= nc.maxCIDRs; i++ {
nc.availableCIDRs.Insert(i) nc.availableCIDRs.Insert(i)