Repository: spidernet-io/spiderpool (go)

Issue:
The name of the application is too long to assign an IP
**Describe the version**
version about:
1. spiderpool v0.4.0


**Describe the bug**
The name of the application is too long to assign an IP

**How To Reproduce**
1. To construct a deploy with an extra-long name that does not exceed the k8s limit of 63 characters, yaml as follows:
```
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  namespace: ns4813-562811032
spec:
  selector:
    matchLabels:
      app: test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  template:
    metadata:
      annotations:
        ipam.spidernet.io/ippool-reclaim: "false"
        ipam.spidernet.io/subnet: '{"ipv4":["v4-ss-4814-630082592"],"ipv6":["v6-ss-4814-675208718"]}'

```
2. Create a deploy as described above
3. Failed to create, get the error log as follows
```
{"level":"ERROR","ts":"2023-05-08T02:55:35.139Z","logger":"SpiderSubnet-Application-Controllers","caller":"applicationcontroller/app_controller.go:579","msg":"encountered app controller syncHandler error 'failed to create or scale IPPool: failed to get auto-created IPPoolList with matchLabels map[ipam.spidernet.io/interface:eth0 ipam.spidernet.io/ip-version:IPv4 ipam.spidernet.io/owner-application:apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ipam.spidernet.io/owner-spider-subnet:v4-ss-4814-630082592], error: unable to parse requirement: values[0][ipam.spidernet.io/owner-application]: Invalid value: \"apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\": must be no more than 63 characters; failed to get auto-created IPPoolList with matchLabels map[ipam.spidernet.io/interface:eth0 ipam.spidernet.io/ip-version:IPv6 ipam.spidernet.io/owner-application:apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ipam.spidernet.io/owner-spider-subnet:v6-ss-4814-675208718], error: unable to parse requirement: values[0][ipam.spidernet.io/owner-application]: Invalid value: \"apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\": must be no more than 63 characters', requeue it after '5s'","OPERATION":"process_app_items","Application":"Deployment/ns4813-562811032/test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
```

**Additional context**
```
~# kubectl describe po -n ns4813-562811032   test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dhf4vm
Normal   Scheduled               12m                  default-scheduler  Successfully assigned ns4813-562811032/test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dhf4vm to spider-worker
  Warning  FailedCreatePodSandBox  11m                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "92985d986346bf1536c473fa13f1926924a276802aa4fd47e1e127b6dadf4417": plugin type="multus" name="multus-cni-network" failed (add): [ns4813-562811032/test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-dhf4vm:macvlan-cni-default]: error adding container to network "macvlan-cni-default": spiderpool IP allocation error: [POST /ipam/ip][500] postIpamIpFailure  failed to allocate IP addresses in standard mode: failed to get IPPool candidates from Subnet: no matching auto-created IPPool candidate with matchLables 'map[ipam.spidernet.io/interface:eth0 ipam.spidernet.io/ip-version:IPv4 ipam.spidernet.io/owner-application:apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ipam.spidernet.io/owner-application-uid:444e3b76-cce1-4462-aafe-f55761a14af1 ipam.spidernet.io/owner-spider-subnet:v4-ss-4814-630082592]'; no matching auto-created IPPool candidate with matchLables 'map[ipam.spidernet.io/interface:eth0 ipam.spidernet.io/ip-version:IPv6 ipam.spidernet.io/owner-application:apps_v1_Deployment_ns4813-562811032_test-app-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ipam.spidernet.io/owner-application-uid:444e3b76-cce1-4462-aafe-f55761a14af1 ipam.spidernet.io/owner-spider-subnet:v6-ss-4814-675208718]'
```


Pull request description:
fix Auto IPPool label value over maximum length limit
Change auto-created IPPool application NamespacedName label because of value max length limitation. 
In the past,  we would assemble the auto pool corresponding application APIVersion, kind, NS and name to one string. But the kubernetes limit the label value max length to 63.

And I realized the kubernetes metadata name length also limits to 63. So I separate it.



Signed-off-by: Icarus9913 [icaruswu66@qq.com](mailto:icaruswu66@qq.com)

**What this PR does / why we need it**:
fix bug

**Which issue(s) this PR fixes**:
close #1747 



Patch:
diff --git a/pkg/applicationcontroller/app_controller.go b/pkg/applicationcontroller/app_controller.go
index 1b446fdc2..f821a2e7b 100644
--- a/pkg/applicationcontroller/app_controller.go
+++ b/pkg/applicationcontroller/app_controller.go
@@ -756,10 +756,13 @@ func (sac *SubnetAppController) applyAutoIPPool(ctx context.Context, podSubnetCo
 		var tmpPool *spiderpoolv2beta1.SpiderIPPool
 		tmpPoolList := &spiderpoolv2beta1.SpiderIPPoolList{}
 		matchLabels := client.MatchingLabels{
-			constant.LabelIPPoolOwnerSpiderSubnet: subnetName,
-			constant.LabelIPPoolOwnerApplication:  applicationinformers.ApplicationNamespacedName(podController.AppNamespacedName),
-			constant.LabelIPPoolIPVersion:         ipVersionStr,
-			constant.LabelIPPoolInterface:         ifName,
+			constant.LabelIPPoolOwnerSpiderSubnet:         subnetName,
+			constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(podController.APIVersion),
+			constant.LabelIPPoolOwnerApplicationKind:      podController.Kind,
+			constant.LabelIPPoolOwnerApplicationNamespace: podController.Namespace,
+			constant.LabelIPPoolOwnerApplicationName:      podController.Name,
+			constant.LabelIPPoolIPVersion:                 ipVersionStr,
+			constant.LabelIPPoolInterface:                 ifName,
 		}
 
 		err := sac.apiReader.List(ctx, tmpPoolList, matchLabels)
diff --git a/pkg/applicationcontroller/applicationinformers/utils.go b/pkg/applicationcontroller/applicationinformers/utils.go
index 8deac045a..bd4795989 100644
--- a/pkg/applicationcontroller/applicationinformers/utils.go
+++ b/pkg/applicationcontroller/applicationinformers/utils.go
@@ -61,6 +61,37 @@ func AutoPoolName(controllerName string, ipVersion types.IPVersion, ifName strin
 	return fmt.Sprintf("auto%d-%s-%s-%s", ipVersion, strings.ToLower(controllerName), strings.ToLower(ifName), strings.ToLower(lastOne))
 }
 
+// ApplicationLabelGV switches the kubernetes APIVersion from "/" link format to "_" link format for kubernetes label value usage.
+func ApplicationLabelGV(apiVersion string) string {
+	// Kubernetes API Group might be empty, ref: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#api-versions
+	first, second, hasGroup := strings.Cut(apiVersion, "/")
+	if hasGroup {
+		return fmt.Sprintf("%s_%s", first, second)
+	}
+
+	return first
+}
+
+// ParseApplicationGVStr will parse a label value string back to apiVersion format string, its corresponding function is ApplicationLabelGV.
+func ParseApplicationGVStr(str string) (apiVersion string, isMatch bool) {
+	split := strings.Split(str, "_")
+
+	// no API Group
+	if len(split) == 1 {
+		return schema.GroupVersion{
+			Group:   "",
+			Version: split[0],
+		}.String(), true
+	} else if len(split) == 2 {
+		return schema.GroupVersion{
+			Group:   split[0],
+			Version: split[1],
+		}.String(), true
+	}
+
+	return
+}
+
 // ApplicationNamespacedName will joint the application apiVersion, application type, namespace and name as a string, then we need unpack it for tracing
 // [ns and object name constraint Ref]: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
 // We set format is "{apiVersion}:{appKind}:{appNS}:{appName}"
diff --git a/pkg/constant/k8s.go b/pkg/constant/k8s.go
index da9b9ae9a..5ec77758e 100644
--- a/pkg/constant/k8s.go
+++ b/pkg/constant/k8s.go
@@ -62,14 +62,17 @@ const (
 	AnnoSpiderSubnetPoolIPNumber  = AnnotationPre + "/ippool-ip-number"
 	AnnoSpiderSubnetReclaimIPPool = AnnotationPre + "/ippool-reclaim"
 
-	LabelIPPoolReclaimIPPool       = AnnoSpiderSubnetReclaimIPPool
-	LabelIPPoolOwnerSpiderSubnet   = AnnotationPre + "/owner-spider-subnet"
-	LabelIPPoolOwnerApplication    = AnnotationPre + "/owner-application"
-	LabelIPPoolOwnerApplicationUID = AnnotationPre + "/owner-application-uid"
-	LabelIPPoolInterface           = AnnotationPre + "/interface"
-	LabelIPPoolIPVersion           = AnnotationPre + "/ip-version"
-	LabelValueIPVersionV4          = "IPv4"
-	LabelValueIPVersionV6          = "IPv6"
+	LabelIPPoolReclaimIPPool             = AnnoSpiderSubnetReclaimIPPool
+	LabelIPPoolOwnerSpiderSubnet         = AnnotationPre + "/owner-spider-subnet"
+	LabelIPPoolOwnerApplicationGV        = AnnotationPre + "/owner-application-gv"
+	LabelIPPoolOwnerApplicationKind      = AnnotationPre + "/owner-application-kind"
+	LabelIPPoolOwnerApplicationNamespace = AnnotationPre + "/owner-application-namespace"
+	LabelIPPoolOwnerApplicationName      = AnnotationPre + "/owner-application-name"
+	LabelIPPoolOwnerApplicationUID       = AnnotationPre + "/owner-application-uid"
+	LabelIPPoolInterface                 = AnnotationPre + "/interface"
+	LabelIPPoolIPVersion                 = AnnotationPre + "/ip-version"
+	LabelValueIPVersionV4                = "IPv4"
+	LabelValueIPVersionV6                = "IPv6"
 
 	LabelSubnetCIDR = AnnotationPre + "/subnet-cidr"
 	LabelIPPoolCIDR = AnnotationPre + "/ippool-cidr"
diff --git a/pkg/ipam/pool_selections.go b/pkg/ipam/pool_selections.go
index c3956a17a..d8bc2a0b2 100644
--- a/pkg/ipam/pool_selections.go
+++ b/pkg/ipam/pool_selections.go
@@ -18,7 +18,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	"github.com/spidernet-io/spiderpool/api/v1/agent/models"
-	subnetmanagercontrollers "github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers"
+	"github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers"
 	"github.com/spidernet-io/spiderpool/pkg/constant"
 	spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
 	"github.com/spidernet-io/spiderpool/pkg/logutils"
@@ -81,13 +81,13 @@ func (i *ipam) getPoolFromSubnetAnno(ctx context.Context, pod *corev1.Pod, nic s
 	logger := logutils.FromContext(ctx)
 
 	// get SpiderSubnet configuration from pod annotation
-	subnetAnnoConfig, err := subnetmanagercontrollers.GetSubnetAnnoConfig(pod.Annotations, logger)
+	subnetAnnoConfig, err := applicationinformers.GetSubnetAnnoConfig(pod.Annotations, logger)
 	if nil != err {
 		return nil, err
 	}
 
 	// default IPPool mode
-	if subnetmanagercontrollers.IsDefaultIPPoolMode(subnetAnnoConfig) {
+	if applicationinformers.IsDefaultIPPoolMode(subnetAnnoConfig) {
 		return nil, nil
 	}
 
@@ -206,11 +206,14 @@ func (i *ipam) findAppAutoPool(ctx context.Context, subnetName, ifName, labelIPP
 
 	var pool *spiderpoolv2beta1.SpiderIPPool
 	matchLabels := client.MatchingLabels{
-		constant.LabelIPPoolOwnerSpiderSubnet:   subnetName,
-		constant.LabelIPPoolOwnerApplication:    subnetmanagercontrollers.ApplicationNamespacedName(podController.AppNamespacedName),
-		constant.LabelIPPoolOwnerApplicationUID: string(podController.UID),
-		constant.LabelIPPoolInterface:           ifName,
-		constant.LabelIPPoolIPVersion:           labelIPPoolIPVersionValue,
+		constant.LabelIPPoolOwnerSpiderSubnet:         subnetName,
+		constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(podController.APIVersion),
+		constant.LabelIPPoolOwnerApplicationKind:      podController.Kind,
+		constant.LabelIPPoolOwnerApplicationNamespace: podController.Namespace,
+		constant.LabelIPPoolOwnerApplicationName:      podController.Name,
+		constant.LabelIPPoolOwnerApplicationUID:       string(podController.UID),
+		constant.LabelIPPoolInterface:                 ifName,
+		constant.LabelIPPoolIPVersion:                 labelIPPoolIPVersionValue,
 	}
 	for j := 1; j <= i.config.OperationRetries; j++ {
 		poolList, err := i.ipPoolManager.ListIPPools(ctx, constant.UseCache, matchLabels)
@@ -259,10 +262,13 @@ func (i *ipam) applyThirdControllerAutoPool(ctx context.Context, subnetName stri
 
 	var pool *spiderpoolv2beta1.SpiderIPPool
 	matchLabels := client.MatchingLabels{
-		constant.LabelIPPoolOwnerSpiderSubnet: subnetName,
-		constant.LabelIPPoolOwnerApplication:  subnetmanagercontrollers.ApplicationNamespacedName(podController.AppNamespacedName),
-		constant.LabelIPPoolIPVersion:         labelIPPoolIPVersionValue,
-		constant.LabelIPPoolInterface:         autoPoolProperty.IfName,
+		constant.LabelIPPoolOwnerSpiderSubnet:         subnetName,
+		constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(podController.APIVersion),
+		constant.LabelIPPoolOwnerApplicationKind:      podController.Kind,
+		constant.LabelIPPoolOwnerApplicationNamespace: podController.Namespace,
+		constant.LabelIPPoolOwnerApplicationName:      podController.Name,
+		constant.LabelIPPoolIPVersion:                 labelIPPoolIPVersionValue,
+		constant.LabelIPPoolInterface:                 autoPoolProperty.IfName,
 	}
 	for j := 1; j <= i.config.OperationRetries; j++ {
 		poolList, err := i.ipPoolManager.ListIPPools(ctx, constant.UseCache, matchLabels)
diff --git a/pkg/ippoolmanager/ippool_informer.go b/pkg/ippoolmanager/ippool_informer.go
index 1ad465a6e..e5f34f4e4 100644
--- a/pkg/ippoolmanager/ippool_informer.go
+++ b/pkg/ippoolmanager/ippool_informer.go
@@ -32,6 +32,7 @@ import (
 	listers "github.com/spidernet-io/spiderpool/pkg/k8s/client/listers/spiderpool.spidernet.io/v2beta1"
 	"github.com/spidernet-io/spiderpool/pkg/logutils"
 	"github.com/spidernet-io/spiderpool/pkg/metric"
+	"github.com/spidernet-io/spiderpool/pkg/types"
 )
 
 var informerLogger *zap.Logger
@@ -366,31 +367,34 @@ func (ic *IPPoolController) cleanAutoIPPoolLegacy(ctx context.Context, pool *spi
 
 	if pool.Status.AllocatedIPs == nil {
 		// unpack the IPPool corresponding application type,namespace and name
-		appNamespacedNameStr := poolLabels[constant.LabelIPPoolOwnerApplication]
-		appNamespacedName, isMatch := applicationinformers.ParseApplicationNamespacedName(appNamespacedNameStr)
+		appGVStr := poolLabels[constant.LabelIPPoolOwnerApplicationGV]
+		appAPIVersion, isMatch := applicationinformers.ParseApplicationGVStr(appGVStr)
 		if !isMatch {
-			return fmt.Errorf("%w: invalid IPPool label '%s' value '%s'", constant.ErrWrongInput, constant.LabelIPPoolOwnerApplication, appNamespacedNameStr)
+			return fmt.Errorf("%w: invalid IPPool label '%s' value '%s'", constant.ErrWrongInput, constant.LabelIPPoolOwnerApplicationGV, appGVStr)
+		}
+
+		appNamespacedName := types.AppNamespacedName{
+			APIVersion: appAPIVersion,
+			Kind:       poolLabels[constant.LabelIPPoolOwnerApplicationKind],
+			Namespace:  poolLabels[constant.LabelIPPoolOwnerApplicationNamespace],
+			Name:       poolLabels[constant.LabelIPPoolOwnerApplicationName],
 		}
 
 		enableDelete := false
 		// check the IPPool's corresponding application whether is existed or not
-		informerLogger.Sugar().Debugf("try to get auto-created IPPool '%s' corresponding application '%s/%s/%s'",
-			pool.Name, appNamespacedName.Kind, appNamespacedName.Namespace, appNamespacedName.Name)
+		informerLogger.Sugar().Debugf("try to get auto-created IPPool '%s' corresponding application '%v'", pool.Name, appNamespacedName)
 		isAppExist, appUID, err := applicationinformers.IsAppExist(ctx, ic.client, ic.dynamicClient, appNamespacedName)
 		if nil != err {
-			return fmt.Errorf("failed to get auto-created IPPool '%s' corresponding application '%s/%s/%s': %w",
-				pool.Name, appNamespacedName.Kind, appNamespacedName.Namespace, appNamespacedName.Name, err)
+			return fmt.Errorf("failed to get auto-created IPPool '%s' corresponding application '%v': %w", pool.Name, appNamespacedName, err)
 		}
 
 		// mismatch application UID
 		if !isAppExist {
-			informerLogger.Sugar().Warnf("auto-created IPPool '%s' corresponding application '%s/%s/%s' no longer exist, try to delete IPPool",
-				pool.Name, appNamespacedName.Kind, appNamespacedName.Namespace, appNamespacedName.Name)
+			informerLogger.Sugar().Warnf("auto-created IPPool '%s' corresponding application '%v' no longer exist, try to delete IPPool", pool.Name, appNamespacedName)
 			enableDelete = true
 		} else {
 			if string(appUID) != poolLabels[constant.LabelIPPoolOwnerApplicationUID] {
-				informerLogger.Sugar().Warnf("auto-created IPPool '%s' mismatches application '%s/%s/%s' UID '%s', try to delete IPPool",
-					pool.Name, appNamespacedName.Kind, appNamespacedName.Namespace, appNamespacedName.Name, appUID)
+				informerLogger.Sugar().Warnf("auto-created IPPool '%s' mismatches application '%v' UID '%s', try to delete IPPool", pool.Name, appNamespacedName, appUID)
 				enableDelete = true
 			}
 		}
diff --git a/pkg/ippoolmanager/utils.go b/pkg/ippoolmanager/utils.go
index 85c470def..83a670317 100644
--- a/pkg/ippoolmanager/utils.go
+++ b/pkg/ippoolmanager/utils.go
@@ -17,7 +17,7 @@ import (
 func IsAutoCreatedIPPool(pool *spiderpoolv2beta1.SpiderIPPool) bool {
 	// only the auto-created IPPool owns the annotation "ipam.spidernet.io/owner-application"
 	poolLabels := pool.GetLabels()
-	_, ok := poolLabels[constant.LabelIPPoolOwnerApplication]
+	_, ok := poolLabels[constant.LabelIPPoolOwnerApplicationName]
 	return ok
 }
 
diff --git a/pkg/subnetmanager/subnet_manager.go b/pkg/subnetmanager/subnet_manager.go
index 783f8bca1..d6d2b2df5 100644
--- a/pkg/subnetmanager/subnet_manager.go
+++ b/pkg/subnetmanager/subnet_manager.go
@@ -147,10 +147,13 @@ func (sm *subnetManager) ReconcileAutoIPPool(ctx context.Context, pool *spiderpo
 
 		{
 			poolLabels := map[string]string{
-				constant.LabelIPPoolOwnerSpiderSubnet:   subnet.Name,
-				constant.LabelIPPoolOwnerApplication:    applicationinformers.ApplicationNamespacedName(podController.AppNamespacedName),
-				constant.LabelIPPoolOwnerApplicationUID: string(podController.UID),
-				constant.LabelIPPoolInterface:           autoPoolProperty.IfName,
+				constant.LabelIPPoolOwnerSpiderSubnet:         subnet.Name,
+				constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(podController.APIVersion),
+				constant.LabelIPPoolOwnerApplicationKind:      podController.Kind,
+				constant.LabelIPPoolOwnerApplicationNamespace: podController.Namespace,
+				constant.LabelIPPoolOwnerApplicationName:      podController.Name,
+				constant.LabelIPPoolOwnerApplicationUID:       string(podController.UID),
+				constant.LabelIPPoolInterface:                 autoPoolProperty.IfName,
 			}
 			// label IPPoolCIDR
 			cidrLabelValue, err := spiderpoolip.CIDRToLabelValue(*pool.Spec.IPVersion, pool.Spec.Subnet)


Test patch:
diff --git a/pkg/ippoolmanager/ippool_informer_test.go b/pkg/ippoolmanager/ippool_informer_test.go
index c5f3a280a..c62609655 100644
--- a/pkg/ippoolmanager/ippool_informer_test.go
+++ b/pkg/ippoolmanager/ippool_informer_test.go
@@ -27,7 +27,6 @@ import (
 	spiderpoolfake "github.com/spidernet-io/spiderpool/pkg/k8s/client/clientset/versioned/fake"
 	"github.com/spidernet-io/spiderpool/pkg/k8s/client/informers/externalversions"
 	"github.com/spidernet-io/spiderpool/pkg/metric"
-	"github.com/spidernet-io/spiderpool/pkg/types"
 )
 
 var _ = Describe("IPPool-informer", Label("unitest"), Ordered, func() {
@@ -130,13 +129,11 @@ var _ = Describe("IPPool-informer", Label("unitest"), Ordered, func() {
 				tmpPool := pool.DeepCopy()
 				tmpPool.Name = "auto4-deploy-abc"
 				labels := map[string]string{
-					constant.LabelIPPoolOwnerApplication: applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
-						APIVersion: appsv1.SchemeGroupVersion.String(),
-						Kind:       constant.KindDeployment,
-						Namespace:  "test-ns",
-						Name:       "test-name",
-					}),
-					constant.LabelIPPoolReclaimIPPool: constant.True,
+					constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(appsv1.SchemeGroupVersion.String()),
+					constant.LabelIPPoolOwnerApplicationKind:      constant.KindDeployment,
+					constant.LabelIPPoolOwnerApplicationNamespace: "test-ns",
+					constant.LabelIPPoolOwnerApplicationName:      "test-name",
+					constant.LabelIPPoolReclaimIPPool:             constant.True,
 				}
 				tmpPool.SetLabels(labels)
 
@@ -168,13 +165,11 @@ var _ = Describe("IPPool-informer", Label("unitest"), Ordered, func() {
 				now := metav1.Now()
 				tmpPool.DeletionTimestamp = now.DeepCopy()
 				labels := map[string]string{
-					constant.LabelIPPoolOwnerApplication: applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
-						APIVersion: appsv1.SchemeGroupVersion.String(),
-						Kind:       constant.KindDeployment,
-						Namespace:  "test-ns",
-						Name:       "test-name",
-					}),
-					constant.LabelIPPoolReclaimIPPool: constant.True,
+					constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(appsv1.SchemeGroupVersion.String()),
+					constant.LabelIPPoolOwnerApplicationKind:      constant.KindDeployment,
+					constant.LabelIPPoolOwnerApplicationNamespace: "test-ns",
+					constant.LabelIPPoolOwnerApplicationName:      "test-name",
+					constant.LabelIPPoolReclaimIPPool:             constant.True,
 				}
 				tmpPool.SetLabels(labels)
 				controllerutil.AddFinalizer(tmpPool, constant.SpiderFinalizer)
diff --git a/pkg/ippoolmanager/ippool_webhook_test.go b/pkg/ippoolmanager/ippool_webhook_test.go
index a50c7ebde..d5aab102d 100644
--- a/pkg/ippoolmanager/ippool_webhook_test.go
+++ b/pkg/ippoolmanager/ippool_webhook_test.go
@@ -1762,12 +1762,12 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
 					subnetT.Spec.IPs = append(subnetT.Spec.IPs, "172.18.40.1-172.18.40.2")
 
 					autoPool := ipPoolT.DeepCopy()
-					autoPool.Labels = map[string]string{constant.LabelIPPoolOwnerApplication: applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
-						APIVersion: appsv1.SchemeGroupVersion.String(),
-						Kind:       constant.KindDeployment,
-						Namespace:  autoPool.Namespace,
-						Name:       autoPool.Name,
-					})}
+					autoPool.Labels = map[string]string{
+						constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(appsv1.SchemeGroupVersion.String()),
+						constant.LabelIPPoolOwnerApplicationKind:      constant.KindDeployment,
+						constant.LabelIPPoolOwnerApplicationNamespace: "test-ns",
+						constant.LabelIPPoolOwnerApplicationName:      "test-name",
+					}
 					autoPool.Spec.IPVersion = pointer.Int64(constant.IPv4)
 					autoPool.Spec.Subnet = "172.18.40.0/24"
 					autoPool.Spec.IPs = append(autoPool.Spec.IPs, "172.18.40.1")
@@ -1775,8 +1775,13 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
 					err := controllerutil.SetControllerReference(subnetT, autoPool, scheme)
 					Expect(err).NotTo(HaveOccurred())
 					poolIPPreAllocations := spiderpoolv2beta1.PoolIPPreAllocations{autoPool.Name: spiderpoolv2beta1.PoolIPPreAllocation{
-						IPs:         []string{"172.18.40.1"},
-						Application: pointer.String(autoPool.Labels[constant.LabelIPPoolOwnerApplication]),
+						IPs: []string{"172.18.40.1"},
+						Application: pointer.String(applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
+							APIVersion: appsv1.SchemeGroupVersion.String(),
+							Kind:       constant.KindDeployment,
+							Namespace:  "test-ns",
+							Name:       "test-name",
+						})),
 					}}
 					subnetAllocatedIPPools, err := convert.MarshalSubnetAllocatedIPPools(poolIPPreAllocations)
 					Expect(err).NotTo(HaveOccurred())
@@ -1799,12 +1804,12 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
 					subnetT.Spec.IPs = append(subnetT.Spec.IPs, "172.18.40.1-172.18.40.2")
 
 					autoPool := ipPoolT.DeepCopy()
-					autoPool.Labels = map[string]string{constant.LabelIPPoolOwnerApplication: applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
-						APIVersion: appsv1.SchemeGroupVersion.String(),
-						Kind:       constant.KindDeployment,
-						Namespace:  autoPool.Namespace,
-						Name:       autoPool.Name,
-					})}
+					autoPool.Labels = map[string]string{
+						constant.LabelIPPoolOwnerApplicationGV:        applicationinformers.ApplicationLabelGV(appsv1.SchemeGroupVersion.String()),
+						constant.LabelIPPoolOwnerApplicationKind:      constant.KindDeployment,
+						constant.LabelIPPoolOwnerApplicationNamespace: "test-ns",
+						constant.LabelIPPoolOwnerApplicationName:      "test-name",
+					}
 					autoPool.Spec.IPVersion = pointer.Int64(constant.IPv4)
 					autoPool.Spec.Subnet = "172.18.40.0/24"
 					autoPool.Spec.IPs = append(autoPool.Spec.IPs, "172.18.40.1")
@@ -1812,8 +1817,13 @@ var _ = Describe("IPPoolWebhook", Label("ippool_webhook_test"), func() {
 					err := controllerutil.SetControllerReference(subnetT, autoPool, scheme)
 					Expect(err).NotTo(HaveOccurred())
 					poolIPPreAllocations := spiderpoolv2beta1.PoolIPPreAllocations{autoPool.Name: spiderpoolv2beta1.PoolIPPreAllocation{
-						IPs:         []string{"172.18.40.1"},
-						Application: pointer.String(autoPool.Labels[constant.LabelIPPoolOwnerApplication]),
+						IPs: []string{"172.18.40.1"},
+						Application: pointer.String(applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
+							APIVersion: appsv1.SchemeGroupVersion.String(),
+							Kind:       constant.KindDeployment,
+							Namespace:  "test-ns",
+							Name:       "test-name",
+						})),
 					}}
 					subnetAllocatedIPPools, err := convert.MarshalSubnetAllocatedIPPools(poolIPPreAllocations)
 					Expect(err).NotTo(HaveOccurred())
diff --git a/pkg/ippoolmanager/utils_test.go b/pkg/ippoolmanager/utils_test.go
index 4b63059fe..d1136bb6e 100644
--- a/pkg/ippoolmanager/utils_test.go
+++ b/pkg/ippoolmanager/utils_test.go
@@ -9,7 +9,6 @@ import (
 	appsv1 "k8s.io/api/apps/v1"
 	types2 "k8s.io/apimachinery/pkg/types"
 
-	"github.com/spidernet-io/spiderpool/pkg/applicationcontroller/applicationinformers"
 	"github.com/spidernet-io/spiderpool/pkg/constant"
 	spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
 	"github.com/spidernet-io/spiderpool/pkg/types"
@@ -20,12 +19,7 @@ var _ = Describe("IPPoolManager-utils", Label("ippool_manager_utils"), func() {
 		It("normal IPPool", func() {
 			var pool spiderpoolv2beta1.SpiderIPPool
 
-			label := map[string]string{constant.LabelIPPoolOwnerApplication: applicationinformers.ApplicationNamespacedName(types.AppNamespacedName{
-				APIVersion: appsv1.SchemeGroupVersion.String(),
-				Kind:       constant.KindDeployment,
-				Namespace:  "test-ns",
-				Name:       "test-name",
-			})}
+			label := map[string]string{constant.LabelIPPoolOwnerApplicationName: "test-name"}
 			pool.SetLabels(label)
 
 			isAutoCreatedIPPool := IsAutoCreatedIPPool(&pool)
diff --git a/test/e2e/kruise/kruise_test.go b/test/e2e/kruise/kruise_test.go
index 3b2e8484a..facf558be 100644
--- a/test/e2e/kruise/kruise_test.go
+++ b/test/e2e/kruise/kruise_test.go
@@ -19,7 +19,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client"
 )
 
-var _ = PDescribe("Third party control:OpenKruise", Label("kruise"), func() {
+var _ = Describe("Third party control:OpenKruise", Label("kruise"), func() {
 	var namespace, kruiseCloneSetName, kruiseStatefulSetName, v4SubnetName, v6SubnetName, v4PoolName, v6PoolName string
 	var v4SubnetObject, v6SubnetObject *spiderpool.SpiderSubnet
 	var v4PoolObj, v6PoolObj *spiderpool.SpiderIPPool