Skip to content

Commit

Permalink
when update subnet's execpt ip,we should filter repeat ip
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyd1988 committed Dec 16, 2021
1 parent 5aacec5 commit 51365b4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func checkAndUpdateExcludeIps(subnet *kubeovnv1.Subnet) bool {
subnet.Spec.ExcludeIps = excludeIps
changed = true
} else {
checkAndFormatsExcludeIps(subnet)
changed = checkAndFormatsExcludeIps(subnet)
for _, gw := range excludeIps {
gwExists := false
for _, excludeIP := range subnet.Spec.ExcludeIps {
Expand Down Expand Up @@ -1196,7 +1196,7 @@ func isOvnSubnet(subnet *kubeovnv1.Subnet) bool {
return false
}

func checkAndFormatsExcludeIps(subnet *kubeovnv1.Subnet) {
func checkAndFormatsExcludeIps(subnet *kubeovnv1.Subnet) bool {
var excludeIps []string
mapIps := make(map[string]ipam.IPRange, len(subnet.Spec.ExcludeIps))

Expand All @@ -1223,7 +1223,11 @@ func checkAndFormatsExcludeIps(subnet *kubeovnv1.Subnet) {
}
}
klog.V(3).Infof("excludeips before format is %v, after format is %v", subnet.Spec.ExcludeIps, excludeIps)
subnet.Spec.ExcludeIps = excludeIps
if !reflect.DeepEqual(subnet.Spec.ExcludeIps, excludeIps) {
subnet.Spec.ExcludeIps = excludeIps
return true
}
return false
}

func filterRepeatIPRange(mapIps map[string]ipam.IPRange) map[string]ipam.IPRange {
Expand Down

0 comments on commit 51365b4

Please sign in to comment.