Skip to content

Commit

Permalink
Do not default the managedBy field
Browse files Browse the repository at this point in the history
  • Loading branch information
mimowo authored and kannon92 committed Apr 19, 2024
1 parent cb941fc commit 035ba66
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions pkg/webhooks/jobset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ func (j *jobSetWebhook) Default(ctx context.Context, obj runtime.Object) error {
}
}

if js.Spec.ManagedBy == nil {
js.Spec.ManagedBy = ptr.To(jobset.JobSetControllerName)
}
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/webhooks/jobset_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func TestJobSetDefaulting(t *testing.T) {
},
},
},
ManagedBy: ptr.To(jobset.JobSetControllerName),
},
},
want: &jobset.JobSet{
Expand Down Expand Up @@ -440,7 +441,7 @@ func TestJobSetDefaulting(t *testing.T) {
},
},
{
name: "managed-by label is unset",
name: "managedBy field is left nil",
js: &jobset.JobSet{
Spec: jobset.JobSetSpec{
SuccessPolicy: defaultSuccessPolicy,
Expand Down Expand Up @@ -472,12 +473,11 @@ func TestJobSetDefaulting(t *testing.T) {
},
},
},
ManagedBy: ptr.To(jobset.JobSetControllerName),
},
},
},
{
name: "when provided, managed-by label is preserved",
name: "when provided, managedBy field is preserved",
js: &jobset.JobSet{
Spec: jobset.JobSetSpec{
SuccessPolicy: defaultSuccessPolicy,
Expand Down
4 changes: 2 additions & 2 deletions test/integration/webhook/jobset_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ var _ = ginkgo.Describe("jobset webhook defaulting", func() {
},
updateShouldFail: true,
}),
ginkgo.Entry("validate jobSet immutable for managed-by label", &testCase{
ginkgo.Entry("validate jobSet immutable for managedBy field", &testCase{
makeJobSet: func(ns *corev1.Namespace) *testing.JobSetWrapper {
return testing.MakeJobSet("js-hostnames-non-indexed", ns.Name).
Suspend(true).
Expand All @@ -347,7 +347,7 @@ var _ = ginkgo.Describe("jobset webhook defaulting", func() {
Obj())
},
defaultsApplied: func(js *jobset.JobSet) bool {
return ptr.Deref(js.Spec.ManagedBy, "") == jobset.JobSetControllerName
return true
},
updateJobSet: func(js *jobset.JobSet) {
js.Spec.ManagedBy = ptr.To("new-manager")
Expand Down

0 comments on commit 035ba66

Please sign in to comment.