Skip to content

Commit

Permalink
fix github issue 17475
Browse files Browse the repository at this point in the history
If there are multiple clusterNetworkCIDR values on startup when generating the SubnetAllocators for each range
"Provided subnet doesn't belong to network" gets printed after each subnet that belongs to a different range.

I sorted the list of subnets so that each call to NewSubnetAllocator has the list of subnets that are within the clusterNetworkCIDR's range
  • Loading branch information
JacobTanenbaum committed Jan 3, 2018
1 parent 607caee commit 659a4ae
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/network/master/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,34 @@ import (
)

func (master *OsdnMaster) SubnetStartMaster(clusterNetworks []common.ClusterNetwork) error {
subrange := make([]string, 0)
subrange := make(map[common.ClusterNetwork][]string)
subnets, err := master.networkClient.Network().HostSubnets().List(metav1.ListOptions{})
if err != nil {
glog.Errorf("Error in initializing/fetching subnets: %v", err)
return err
}
for _, sub := range subnets.Items {
subrange = append(subrange, sub.Subnet)
if err = master.networkInfo.ValidateNodeIP(sub.HostIP); err != nil {
// Don't error out; just warn so the error can be corrected with 'oc'
glog.Errorf("Failed to validate HostSubnet %s: %v", common.HostSubnetToString(&sub), err)
} else {
glog.Infof("Found existing HostSubnet %s", common.HostSubnetToString(&sub))
_, subnetIP, err := net.ParseCIDR(sub.Subnet)
if err != nil {
return fmt.Errorf("Failed to parse network address: %q", sub.Subnet)
}

for _, cn := range clusterNetworks {
if cn.ClusterCIDR.Contains(subnetIP.IP) {
subrange[cn] = append(subrange[cn], sub.Subnet)
break
}
}
}
}
var subnetAllocatorList []*netutils.SubnetAllocator
for _, cn := range clusterNetworks {
subnetAllocator, err := netutils.NewSubnetAllocator(cn.ClusterCIDR.String(), cn.HostSubnetLength, subrange)
subnetAllocator, err := netutils.NewSubnetAllocator(cn.ClusterCIDR.String(), cn.HostSubnetLength, subrange[cn])
if err != nil {
return err
}
Expand Down

0 comments on commit 659a4ae

Please sign in to comment.