From 51a781fa7cdf38659f49ca301db390e43c504c49 Mon Sep 17 00:00:00 2001 From: Jason Parraga Date: Mon, 9 Dec 2024 23:19:09 -0800 Subject: [PATCH] Update cronjobs to forbid concurrency Signed-off-by: Jason Parraga --- internal/controller/install/lookout_controller.go | 3 ++- internal/controller/install/lookout_controller_test.go | 1 + internal/controller/install/scheduler_controller.go | 3 ++- internal/controller/install/scheduler_controller_test.go | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/controller/install/lookout_controller.go b/internal/controller/install/lookout_controller.go index 7e20bb0..1b65d16 100644 --- a/internal/controller/install/lookout_controller.go +++ b/internal/controller/install/lookout_controller.go @@ -479,7 +479,8 @@ func createLookoutCronJob(lookout *installv1alpha1.Lookout, serviceAccountName s Annotations: map[string]string{"checksum/config": GenerateChecksumConfig(lookout.Spec.ApplicationConfig.Raw)}, }, Spec: batchv1.CronJobSpec{ - Schedule: dbPruningSchedule, + ConcurrencyPolicy: batchv1.ForbidConcurrent, + Schedule: dbPruningSchedule, JobTemplate: batchv1.JobTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/internal/controller/install/lookout_controller_test.go b/internal/controller/install/lookout_controller_test.go index 96fcfbc..f868cd4 100644 --- a/internal/controller/install/lookout_controller_test.go +++ b/internal/controller/install/lookout_controller_test.go @@ -783,6 +783,7 @@ func TestLookoutReconciler_CreateCronJob(t *testing.T) { }, }, Spec: batchv1.CronJobSpec{ + ConcurrencyPolicy: batchv1.ForbidConcurrent, JobTemplate: batchv1.JobTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: "lookout-db-pruner", diff --git a/internal/controller/install/scheduler_controller.go b/internal/controller/install/scheduler_controller.go index d79bc4d..cba6587 100644 --- a/internal/controller/install/scheduler_controller.go +++ b/internal/controller/install/scheduler_controller.go @@ -520,7 +520,8 @@ func newSchedulerCronJob(scheduler *installv1alpha1.Scheduler, serviceAccountNam Annotations: map[string]string{"checksum/config": GenerateChecksumConfig(scheduler.Spec.ApplicationConfig.Raw)}, }, Spec: batchv1.CronJobSpec{ - Schedule: scheduler.Spec.Pruner.Schedule, + Schedule: scheduler.Spec.Pruner.Schedule, + ConcurrencyPolicy: batchv1.ForbidConcurrent, JobTemplate: batchv1.JobTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/internal/controller/install/scheduler_controller_test.go b/internal/controller/install/scheduler_controller_test.go index 58f77fc..c180720 100644 --- a/internal/controller/install/scheduler_controller_test.go +++ b/internal/controller/install/scheduler_controller_test.go @@ -969,6 +969,7 @@ func TestSchedulerReconciler_createSchedulerCronJob(t *testing.T) { }, }, Spec: batchv1.CronJobSpec{ + ConcurrencyPolicy: batchv1.ForbidConcurrent, JobTemplate: batchv1.JobTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: "scheduler-db-pruner",