From ac81ac29f9027fc23f069eb255ccdf20f91b59e7 Mon Sep 17 00:00:00 2001 From: QEDQCD <52378994+QEDQCD@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:22:59 +0800 Subject: [PATCH] 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 * fix issue 4803: The two names should have a containment relationship Signed-off-by: liwenjian --------- Signed-off-by: liwenjian Co-authored-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..0a62d02ad49 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 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)