Skip to content

Commit

Permalink
controllers: insert ConcurrencyPolicy field to CronJob
Browse files Browse the repository at this point in the history
added the capability to keep resources on failed job execution with a timeout

Signed-off-by: Amit Berner <[email protected]>
  • Loading branch information
bernerhat committed Nov 20, 2023
1 parent 1969a71 commit 7fb2735
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/storageclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,24 @@ func (s *StorageClientReconciler) reconcileClientStatusReporterJob(instance *v1a
cronJob.Namespace = s.OperatorNamespace
addLabel(cronJob, storageClientNameLabel, instance.Name)
addLabel(cronJob, storageClientNamespaceLabel, instance.Namespace)
var podDeadLineSeconds int64 = 120
jobDeadLineSeconds := podDeadLineSeconds + 35
var keepJobResourceSeconds int32 = 600
var reducedKeptSuccecsful int32 = 1


_, err := controllerutil.CreateOrUpdate(s.ctx, s.Client, cronJob, func() error {
cronJob.Spec = batchv1.CronJobSpec{
Schedule: "* * * * *",
ConcurrencyPolicy: batchv1.ForbidConcurrent,
SuccessfulJobsHistoryLimit: &reducedKeptSuccecsful,
JobTemplate: batchv1.JobTemplateSpec{
Spec: batchv1.JobSpec{
ActiveDeadlineSeconds: &jobDeadLineSeconds,
TTLSecondsAfterFinished: &keepJobResourceSeconds,
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
ActiveDeadlineSeconds: &podDeadLineSeconds,
Containers: []corev1.Container{
{
Name: "heartbeat",
Expand Down

0 comments on commit 7fb2735

Please sign in to comment.