Skip to content

Commit

Permalink
fix issue 4803: The two names should have a containment relationship (#…
Browse files Browse the repository at this point in the history
…4807)

* fix issue 4803: The two names should have a containment relationship

Signed-off-by: liwenjian <[email protected]>

* fix issue 4803: The two names should have a containment relationship

Signed-off-by: liwenjian <[email protected]>

---------

Signed-off-by: liwenjian <[email protected]>
Co-authored-by: liwenjian <[email protected]>
  • Loading branch information
QEDQCD and liwenjian authored Dec 10, 2024
1 parent bc6379b commit ac81ac2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/webhook/static_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ func (v *ValidatingHook) checkIPConflict(ipAddress, annoSubnet, name string, ipL
return err
}
if ipAddr.String() == v4IP || ipAddr.String() == v6IP {
if name == ipCR.Spec.PodName {
// The IP's spec podName does not equal the Pod name in the request;
// The two names have a containment relationship.
if name == ipCR.Spec.PodName || ipCR.Spec.PodType == util.VM && strings.Contains(ipCR.Spec.PodName, name) {
klog.Infof("get same ip crd for %s", name)
} else {
err := fmt.Errorf("annotation static-ip %s is conflict with ip crd %s, ip %s", ipAddr.String(), ipCR.Name, ipCR.Spec.IPAddress)
Expand Down

0 comments on commit ac81ac2

Please sign in to comment.