Skip to content

Commit 67f5a1e

Browse files
QEDQCDliwenjian
authored andcommitted
fix issue 4803: The two names should have a containment relationship (#4807)
* fix issue 4803: The two names should have a containment relationship Signed-off-by: liwenjian <liwenjian@tfcloud.com> * fix issue 4803: The two names should have a containment relationship Signed-off-by: liwenjian <liwenjian@tfcloud.com> --------- Signed-off-by: liwenjian <liwenjian@tfcloud.com> Co-authored-by: liwenjian <liwenjian@tfcloud.com>
1 parent ad46a78 commit 67f5a1e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/webhook/static_ip.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ func (v *ValidatingHook) checkIPConflict(ipAddress, annoSubnet, name string, ipL
195195
return err
196196
}
197197
if ipAddr.String() == v4IP || ipAddr.String() == v6IP {
198-
if name == ipCR.Spec.PodName {
198+
// The IP's spec podName does not equal the Pod name in the request;
199+
// The two names have a containment relationship.
200+
if name == ipCR.Spec.PodName || ipCR.Spec.PodType == util.VM && strings.Contains(ipCR.Spec.PodName, name) {
199201
klog.Infof("get same ip crd for %s", name)
200202
} else {
201203
err := fmt.Errorf("annotation static-ip %s is conflict with ip crd %s, ip %s", ipAddr.String(), ipCR.Name, ipCR.Spec.IPAddress)

0 commit comments

Comments
 (0)