From a1a24728cfb43088bd5dbc7204c1fda4f4474044 Mon Sep 17 00:00:00 2001 From: liwenjian Date: Mon, 9 Dec 2024 23:27:32 +0800 Subject: [PATCH] fix issue 4803: The two names should have a containment relationship Signed-off-by: liwenjian --- pkg/webhook/static_ip.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/webhook/static_ip.go b/pkg/webhook/static_ip.go index e8dfb460b2d..a85d215cd25 100644 --- a/pkg/webhook/static_ip.go +++ b/pkg/webhook/static_ip.go @@ -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 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)