How resume suspended cron job having concurrency policy as forbid

39 Views Asked by At

I am facing a unique issue with CronJob. I have created a CronJob with concurrency Policy value as 'Forbid'. I have a requirement of suspending and resuming the job as and when needed. When I suspend a job by setting suspend Flag to 'true' in cron job. The job spawned by CronJob remains in Suspended mode which is expected. Now when I toggle the flag to 'False', I expect normal job execution.

However since concurrency policy is 'Forbid', the new job doesn't get spawned by CronJob and existing job remains in suspended mode only. Since the current job is in suspended status and not in Completed or Failed status the forceful termination setting will not affect it.

I see below message in Kubernetes events - 'Not starting job because prior execution is running and concurrency policy is Forbid'

How can I overcome this issue? I want to avoid altering concurrency policy and also don't want to add explicit command to delete the job in suspended mode in my CI/CD pipeline.

1

There are 1 best solutions below

0
Dion V On

Checking on a previous post with the similar concerns, as per P Ekambaram, it might be related to startingDeadlineSeconds. Based on the documentation referred to by user21944236:

If startingDeadlineSeconds is set to a large value or left unset (the default) and if concurrencyPolicy is set to Allow, the Jobs will always run at least once.