From 0640632e2e5342b6fcf9867553ff5a1f92cf27d5 Mon Sep 17 00:00:00 2001 From: avanish23 Date: Wed, 22 Jan 2025 00:41:05 +0530 Subject: [PATCH] fix cronjob status.lastSuccessfulTime not populated by a manually triggered job --- modules/api/pkg/resource/cronjob/jobs.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/api/pkg/resource/cronjob/jobs.go b/modules/api/pkg/resource/cronjob/jobs.go index 4e269d2ffc35..7250cf316bec 100644 --- a/modules/api/pkg/resource/cronjob/jobs.go +++ b/modules/api/pkg/resource/cronjob/jobs.go @@ -114,16 +114,11 @@ func TriggerCronJob(client client.Interface, jobToCreate := &batch.Job{ ObjectMeta: meta.ObjectMeta{ - Name: newJobName, - Namespace: namespace, - Annotations: annotations, - Labels: labels, - OwnerReferences: []meta.OwnerReference{{ - APIVersion: CronJobAPIVersion, - Kind: CronJobKindName, - Name: cronJob.Name, - UID: cronJob.UID, - }}, + Name: newJobName, + Namespace: namespace, + Annotations: annotations, + Labels: labels, + OwnerReferences: []meta.OwnerReference{*meta.NewControllerRef(cronJob, batch.SchemeGroupVersion.WithKind("CronJob"))}, }, Spec: cronJob.Spec.JobTemplate.Spec, }