From 866a09a7185ead8aa7bdf17a70c08d5165ed7e14 Mon Sep 17 00:00:00 2001 From: Aleksei Chernevskii Date: Wed, 2 Aug 2023 22:29:04 -0500 Subject: [PATCH] Rename parent-uid label to job-uid, change label validation --- pkg/controller/constants/constants.go | 6 +++--- pkg/controller/jobframework/reconciler.go | 5 ++--- pkg/controller/jobs/job/job_controller_test.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/controller/constants/constants.go b/pkg/controller/constants/constants.go index 2bb567a4a6..26864f686c 100644 --- a/pkg/controller/constants/constants.go +++ b/pkg/controller/constants/constants.go @@ -33,7 +33,7 @@ const ( // status based on the admission status of the parent workload. ParentWorkloadAnnotation = "kueue.x-k8s.io/parent-workload" - // ParentUIDLabel is the label key in the workload resource, that holds the UID of - // a parent. - ParentUIDLabel = "kueue.x-k8s.io/parent-uid" + // JobUIDLabel is the label key in the workload resource, that holds the UID of + // a parent job. + JobUIDLabel = "kueue.x-k8s.io/job-uid" ) diff --git a/pkg/controller/jobframework/reconciler.go b/pkg/controller/jobframework/reconciler.go index 82cd2da585..21eaacbe5e 100644 --- a/pkg/controller/jobframework/reconciler.go +++ b/pkg/controller/jobframework/reconciler.go @@ -17,7 +17,6 @@ import ( "context" "errors" "fmt" - "unicode/utf8" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -471,8 +470,8 @@ func (r *JobReconciler) constructWorkload(ctx context.Context, job GenericJob, o }, } - if uid := string(job.Object().GetUID()); utf8.RuneCountInString(uid) < 64 && uid != "" { - wl.Labels[controllerconsts.ParentUIDLabel] = uid + if uid := string(job.Object().GetUID()); len(uid) < 64 && uid != "" { + wl.Labels[controllerconsts.JobUIDLabel] = uid } priorityClassName, p, err := r.extractPriority(ctx, podSets, job) diff --git a/pkg/controller/jobs/job/job_controller_test.go b/pkg/controller/jobs/job/job_controller_test.go index 670a0cf7ec..85ca34284f 100644 --- a/pkg/controller/jobs/job/job_controller_test.go +++ b/pkg/controller/jobs/job/job_controller_test.go @@ -442,7 +442,7 @@ func TestReconciler(t *testing.T) { Queue("test-queue"). Priority(0). SetLabels(map[string]string{ - controllerconsts.ParentUIDLabel: "test-uid", + controllerconsts.JobUIDLabel: "test-uid", }). Obj(), },