Skip to content

Commit

Permalink
remove incorrect error logging (kubeovn#4473)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
Signed-off-by: liyh <[email protected]>
  • Loading branch information
zhangzujian authored and liyh-yusur committed Sep 10, 2024
1 parent ae31853 commit 7492d80
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func CIDRContainIP(cidrStr, ipStr string) bool {
if len(cidrs) == 1 {
for _, ip := range ips {
if CheckProtocol(cidrStr) != CheckProtocol(ip) {
klog.Errorf("ip %s and cidr %s should be the same protocol", ip, cidrStr)
klog.Warningf("ip %q and cidr %q should be the same protocol", ip, cidrStr)
return false
}
}
Expand All @@ -140,12 +140,10 @@ func CIDRContainIP(cidrStr, ipStr string) bool {
}
ipAddr := net.ParseIP(ip)
if ipAddr == nil {
klog.Errorf("invalid ip %s", ip)
klog.Errorf("invalid ip %q", ip)
return false
}

if !cidrNet.Contains(ipAddr) {
klog.Errorf("ip %s is not in cidr %s", ip, cidr)
return false
}
}
Expand All @@ -155,6 +153,10 @@ func CIDRContainIP(cidrStr, ipStr string) bool {
}

func CheckProtocol(address string) string {
if address == "" {
return ""
}

ips := strings.Split(address, ",")
if len(ips) == 2 {
IP1 := net.ParseIP(strings.Split(ips[0], "/")[0])
Expand All @@ -165,7 +167,7 @@ func CheckProtocol(address string) string {
if IP2.To4() != nil && IP1.To4() == nil && IP1.To16() != nil {
return kubeovnv1.ProtocolDual
}
err := fmt.Errorf("invalid address %s", address)
err := fmt.Errorf("invalid address %q", address)
klog.Error(err)
return ""
}
Expand All @@ -179,7 +181,7 @@ func CheckProtocol(address string) string {
}

// cidr format error
err := fmt.Errorf("invalid address %s", address)
err := fmt.Errorf("invalid address %q", address)
klog.Error(err)
return ""
}
Expand Down

0 comments on commit 7492d80

Please sign in to comment.