Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Apr 26, 2024
1 parent a584763 commit bfd3de0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ will automatically call Reconcile on the underlying CronJob when a Job changes,
deleted, etc.
*/
var (
jobOwnerKey = ".metadata.controller"
jobOwnerKey = "metadata.my-controller"
apiGVStr = batchv1.GroupVersion.String()
)

Expand All @@ -565,8 +565,8 @@ func (r *CronJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
return nil
}

// ...and if so, return it
return []string{owner.Name}
// Return the job's owner name using a label set on the job itself.
return []string{job.Labels[jobOwnerKey]}
}); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ var _ = Describe("CronJob Controller", func() {
ObjectMeta: metav1.ObjectMeta{
Name: resourceName,
Namespace: "default",
Labels: map[string]string{
jobOwnerKey: "metadata.my-controller",
},
},
Spec: batchv1.CronJobSpec{
Schedule: "*/1 * * * *", // Example: runs every minute
Expand Down

0 comments on commit bfd3de0

Please sign in to comment.