Skip to content

Commit

Permalink
chore: shorten job names to avoid being over limit (#1045)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
whynowy committed Sep 14, 2023
1 parent 4369d65 commit 2d8062c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 42 deletions.
14 changes: 7 additions & 7 deletions config/advanced-install/namespaced-controller-wo-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -49,6 +42,13 @@ rules:
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ rules:
- vertices/finalizers
- vertices/status
- vertices/scale
- apiGroups:
- ""
resources:
- "events"
verbs:
- "create"
- "patch"
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -44,6 +37,13 @@ rules:
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
Expand Down
14 changes: 7 additions & 7 deletions config/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16171,13 +16171,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -16190,6 +16183,13 @@ rules:
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
Expand Down
14 changes: 7 additions & 7 deletions config/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16084,13 +16084,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -16103,6 +16096,13 @@ rules:
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ rules:
- vertices/finalizers
- vertices/status
- vertices/scale
- apiGroups:
- ""
resources:
- "events"
verbs:
- "create"
- "patch"
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -44,6 +37,13 @@ rules:
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
Expand Down
11 changes: 6 additions & 5 deletions pkg/reconciler/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (r *pipelineReconciler) reconcileNonLifecycleChanges(ctx context.Context, p
}
args := []string{fmt.Sprintf("--buffers=%s", strings.Join(bfs, ",")), fmt.Sprintf("--buckets=%s", strings.Join(bks, ","))}
args = append(args, fmt.Sprintf("--side-inputs-store=%s", pl.GetSideInputsStoreName()))
batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-create", args, "create")
batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-create", args, "cre")
if err := r.client.Create(ctx, batchJob); err != nil && !apierrors.IsAlreadyExists(err) {
pl.Status.MarkDeployFailed("CreateISBSvcCreatingJobFailed", err.Error())
return ctrl.Result{}, fmt.Errorf("failed to create ISB Svc creating job, err: %w", err)
Expand All @@ -306,7 +306,7 @@ func (r *pipelineReconciler) reconcileNonLifecycleChanges(ctx context.Context, p
bks = append(bks, k)
}
args := []string{fmt.Sprintf("--buffers=%s", strings.Join(bfs, ",")), fmt.Sprintf("--buckets=%s", strings.Join(bks, ","))}
batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-delete", args, "delete")
batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-delete", args, "del")
if err := r.client.Create(ctx, batchJob); err != nil && !apierrors.IsAlreadyExists(err) {
pl.Status.MarkDeployFailed("CreateISBSvcDeletingJobFailed", err.Error())
return ctrl.Result{}, fmt.Errorf("failed to create ISB Svc deleting job, err: %w", err)
Expand Down Expand Up @@ -517,7 +517,7 @@ func (r *pipelineReconciler) cleanUpBuffers(ctx context.Context, pl *dfv1.Pipeli
args = append(args, fmt.Sprintf("--buckets=%s", strings.Join(allBuckets, ",")))
args = append(args, fmt.Sprintf("--side-inputs-store=%s", pl.GetSideInputsStoreName()))

batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-delete", args, "cleanup")
batchJob := buildISBBatchJob(pl, r.image, isbSvc.Status.Config, "isbsvc-delete", args, "cln")
batchJob.OwnerReferences = []metav1.OwnerReference{}
if err := r.client.Create(ctx, batchJob); err != nil && !apierrors.IsAlreadyExists(err) {
return fmt.Errorf("failed to create buffer clean up job, err: %w", err)
Expand Down Expand Up @@ -697,8 +697,9 @@ func buildISBBatchJob(pl *dfv1.Pipeline, image string, isbSvcConfig dfv1.BufferS
return &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Namespace: pl.Namespace,
Name: fmt.Sprintf("%s-buffer-bucket-%s-%v", pl.Name, jobType, randomStr),
Labels: l,
// The name won't be over length limit, because we have validated "{pipeline}-{vertex}-headless" is no longer than 63.
Name: fmt.Sprintf("%s-%s-%v", pl.Name, jobType, randomStr),
Labels: l,
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(pl.GetObjectMeta(), dfv1.PipelineGroupVersionKind),
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipeline/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func Test_buildISBBatchJob(t *testing.T) {
j := buildISBBatchJob(testPipeline, testFlowImage, fakeIsbSvcConfig, "subcmd", []string{"sss"}, "test")
assert.Equal(t, 1, len(j.Spec.Template.Spec.Containers))
assert.True(t, len(j.Spec.Template.Spec.Containers[0].Args) > 0)
assert.Contains(t, j.Name, testPipeline.Name+"-buffer-bucket-test-")
assert.Contains(t, j.Name, testPipeline.Name+"-test-")
envNames := []string{}
for _, e := range j.Spec.Template.Spec.Containers[0].Env {
envNames = append(envNames, e.Name)
Expand Down Expand Up @@ -436,7 +436,7 @@ func Test_cleanupBuffers(t *testing.T) {
err = r.client.List(ctx, jobs, &client.ListOptions{Namespace: testNamespace, LabelSelector: selector})
assert.NoError(t, err)
assert.Equal(t, 1, len(jobs.Items))
assert.Contains(t, jobs.Items[0].Name, "cleanup")
assert.Contains(t, jobs.Items[0].Name, "cln")
assert.Equal(t, 0, len(jobs.Items[0].OwnerReferences))
})
}
Expand Down

0 comments on commit 2d8062c

Please sign in to comment.