Skip to content

Commit 58ebea1

Browse files
committed
add err log to help find conflict ip owner (#2939)
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
1 parent 8246b8b commit 58ebea1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/ipam/subnet.go

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (subnet *Subnet) GetRandomMac(podName, nicName string) string {
143143
func (subnet *Subnet) GetStaticMac(podName, nicName, mac string, checkConflict bool) error {
144144
if checkConflict {
145145
if p, ok := subnet.MacToPod[mac]; ok && p != podName {
146+
klog.Errorf("mac %s has been allocated to pod %s", mac, p)
146147
return ErrConflict
147148
}
148149
}
@@ -231,6 +232,7 @@ func (subnet *Subnet) getV4RandomAddress(podName, nicName string, mac string, sk
231232
}
232233
}
233234
if ip == "" {
235+
klog.Errorf("no available ip in subnet %s, v4 free ip list %v", subnet.Name, subnet.V4FreeIPList)
234236
return "", "", "", ErrConflict
235237
}
236238

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

@@ -365,6 +368,7 @@ func (subnet *Subnet) GetStaticAddress(podName, nicName string, ip IP, mac strin
365368
subnet.V4IPToPod[ip] = fmt.Sprintf("%s,%s", subnet.V4IPToPod[ip], podName)
366369
return ip, mac, nil
367370
}
371+
klog.Errorf("v4 ip %s has been allocated to %v", ip, pods)
368372
return ip, mac, ErrConflict
369373
}
370374
if !force {
@@ -400,6 +404,7 @@ func (subnet *Subnet) GetStaticAddress(podName, nicName string, ip IP, mac strin
400404
subnet.V6IPToPod[ip] = fmt.Sprintf("%s,%s", subnet.V6IPToPod[ip], podName)
401405
return ip, mac, nil
402406
}
407+
klog.Errorf("v6 ip %s has been allocated to %v", ip, pods)
403408
return ip, mac, ErrConflict
404409
}
405410
if !force {

0 commit comments

Comments
 (0)