From fdbc40d1c0aae6063e9420f0667e49def39de169 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 26 Jan 2024 19:07:46 +0100 Subject: [PATCH] test: change labels used for creating IPAddressClaims to not hit the 63 characters length limit --- test/framework/ip/incluster.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/framework/ip/incluster.go b/test/framework/ip/incluster.go index 59a2461ff1..7c603ad587 100644 --- a/test/framework/ip/incluster.go +++ b/test/framework/ip/incluster.go @@ -145,8 +145,8 @@ func GetIPAddressClaimLabels() map[string]string { if val := os.Getenv("BUILD_ID"); val != "" { labels["prow.k8s.io/build-id"] = val } - if val := os.Getenv("JOB_NAME"); val != "" { - labels["prow.k8s.io/job"] = val + if val := os.Getenv("REPO_NAME"); val != "" { + labels["prow.k8s.io/repo-name"] = val } if len(labels) == 0 { // Adding a custom label so we don't accidentally cleanup other IPAddressClaims @@ -274,9 +274,10 @@ func getVirtualMachineIPAddresses(ctx context.Context, folderName string, vSpher func (h *inCluster) claimIPAddress(ctx context.Context) (_ string, _ *ipamv1.IPAddressClaim, err error) { claim := &ipamv1.IPAddressClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: "ipclaim-" + rand.String(32), - Namespace: metav1.NamespaceDefault, - Labels: h.labels, + Name: "ipclaim-" + rand.String(32), + Namespace: metav1.NamespaceDefault, + Labels: h.labels, + Annotations: map[string]string{}, }, Spec: ipamv1.IPAddressClaimSpec{ PoolRef: corev1.TypedLocalObjectReference{ @@ -286,6 +287,10 @@ func (h *inCluster) claimIPAddress(ctx context.Context) (_ string, _ *ipamv1.IPA }, }, } + // Set job name as annotation if environment variable is set. + if val := os.Getenv("JOB_NAME"); val != "" { + claim.ObjectMeta.Annotations["prow.k8s.io/job"] = val + } // Create an IPAddressClaim Byf("Creating IPAddressClaim %s", klog.KObj(claim))