Skip to content

Commit

Permalink
check the error when checking if cidrs intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobTanenbaum committed Jun 13, 2017
1 parent bcf5a72 commit 5e73345
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
5 changes: 4 additions & 1 deletion pkg/sdn/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func SetDefaultClusterNetwork(cn sdnapi.ClusterNetwork) {

//intersect tests two CIDR addresses to see if the first contains the second
func intersect(cidr1, cidr2 string) bool {
_, net1, _ := net.ParseCIDR(cidr1)
_, net1, err := net.ParseCIDR(cidr1)
if err != nil {
return false
}
_, net2, err := net.ParseCIDR(cidr2)
if err != nil {
//cidr2 was not a cidr address which will be caught later
Expand Down
23 changes: 0 additions & 23 deletions pkg/sdn/plugin/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ func (master *OsdnMaster) checkClusterNetworkAgainstClusterObjects() error {
func clusterNetworkChanged(obj *osapi.ClusterNetwork, old *osapi.ClusterNetwork) (bool, error) {
changed := false

if !clusterDefEquals(old.ClusterNetworks, obj.ClusterNetworks) {
//KEYWORD
//Not sure what to do here...

//A valid change should be splitting a network into its smaller components
}

if old.Network != obj.Network {
changed = true
Expand Down Expand Up @@ -190,20 +184,3 @@ func clusterNetworkChanged(obj *osapi.ClusterNetwork, old *osapi.ClusterNetwork)

return changed, nil
}

func clusterDefEquals(obj, old []osapi.ClusterNetworkEntry) bool {
if obj == nil && old == nil {
//this should never happen
return true
}
if (obj == nil || old == nil) || (len(obj) != len(old)) {
//first case should never happen
return false
}
for i := range old {
if old[i] != obj[i] {
return false
}
}
return true
}

0 comments on commit 5e73345

Please sign in to comment.