Skip to content

Commit

Permalink
add err log to help find conflict ip owner (#2939)
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
bobz965 committed Sep 8, 2023
1 parent 8246b8b commit 58ebea1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/ipam/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (subnet *Subnet) GetRandomMac(podName, nicName string) string {
func (subnet *Subnet) GetStaticMac(podName, nicName, mac string, checkConflict bool) error {
if checkConflict {
if p, ok := subnet.MacToPod[mac]; ok && p != podName {
klog.Errorf("mac %s has been allocated to pod %s", mac, p)
return ErrConflict
}
}
Expand Down Expand Up @@ -231,6 +232,7 @@ func (subnet *Subnet) getV4RandomAddress(podName, nicName string, mac string, sk
}
}
if ip == "" {
klog.Errorf("no available ip in subnet %s, v4 free ip list %v", subnet.Name, subnet.V4FreeIPList)
return "", "", "", ErrConflict
}

Expand Down Expand Up @@ -292,6 +294,7 @@ func (subnet *Subnet) getV6RandomAddress(podName, nicName string, mac string, sk
}
}
if ip == "" {
klog.Errorf("no available ip in subnet %s, v6 free ip list %v", subnet.Name, subnet.V6FreeIPList)
return "", "", "", ErrConflict
}

Expand Down Expand Up @@ -365,6 +368,7 @@ func (subnet *Subnet) GetStaticAddress(podName, nicName string, ip IP, mac strin
subnet.V4IPToPod[ip] = fmt.Sprintf("%s,%s", subnet.V4IPToPod[ip], podName)
return ip, mac, nil
}
klog.Errorf("v4 ip %s has been allocated to %v", ip, pods)
return ip, mac, ErrConflict
}
if !force {
Expand Down Expand Up @@ -400,6 +404,7 @@ func (subnet *Subnet) GetStaticAddress(podName, nicName string, ip IP, mac strin
subnet.V6IPToPod[ip] = fmt.Sprintf("%s,%s", subnet.V6IPToPod[ip], podName)
return ip, mac, nil
}
klog.Errorf("v6 ip %s has been allocated to %v", ip, pods)
return ip, mac, ErrConflict
}
if !force {
Expand Down

0 comments on commit 58ebea1

Please sign in to comment.