Skip to content

Commit

Permalink
controllers: added keep failed iterations
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 19, 2023
1 parent c996086 commit 9b9a766
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion 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 jobDeadLineSeconds int64 = 155
var podDeadLineSeconds int64 = 120
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 Expand Up @@ -470,7 +480,6 @@ func (s *StorageClientReconciler) reconcileClientStatusReporterJob(instance *v1a
},
},
},
ConcurrencyPolicy: "Forbid",
}
return nil
})
Expand Down

0 comments on commit 9b9a766

Please sign in to comment.