Skip to content

Commit

Permalink
Merge pull request #2671 from chrischdi/pr-fix-ip-incluster-label-length
Browse files Browse the repository at this point in the history
🌱 test: change labels used for creating IPAddressClaims to not hit the 63 characters length limit
  • Loading branch information
k8s-ci-robot authored Jan 29, 2024
2 parents ba8b131 + fdbc40d commit 156564e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/framework/ip/incluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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))
Expand Down

0 comments on commit 156564e

Please sign in to comment.