How to fail a (cron) job after a certain number of retries?

0 votes

I have a kubernetes cluster of web scrapping cron job set up.Everything works fine until a cron job fails to start.

Whats the issue?

Here is the config for reference:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: scrape-al
spec:
  schedule: '*/15 * * * *'
  concurrencyPolicy: Allow
  failedJobsHistoryLimit: 0
  successfulJobsHistoryLimit: 0
  jobTemplate:
    metadata:
      labels:
        app: scrape
        scrape: al
    spec:
      template:
        spec:
          containers:
            - name: scrape-al
              image: 'govhawk/openstates:1.3.1-beta'
              command:
                - /opt/openstates/openstates/pupa-scrape.sh
              args:
                - al bills --scrape
          restartPolicy: Never
      backoffLimit: 3
Sep 17, 2018 in Kubernetes by Hannah
• 14,080 points
54 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You're trying to set 3 asbackoffLimit of your Job. That means when a Job is created by CronJob, It will retry 3 times if fails. This controls Job, not CronJob

You need to suspend CronJob so than it stop scheduling new Job.

Suspend: true

You can do this manually. If you do not want to do this manually, you need to setup a watcher, that will watch your CronJob status, and will update CronJob to suspend if necessary.

answered Sep 17, 2018 by Kalgi
• 35,720 points

Related Questions In Kubernetes

0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,000 points
163 views
0 votes
1 answer

Run a cron job once in N hours

If you want your cron job to ...READ MORE

answered Sep 18, 2018 in Kubernetes by Kalgi
• 35,720 points
19 views
0 votes
2 answers

Change the schedule of Kubernetes cron job

Hey @Lina, You can use the keyword ...READ MORE

answered Sep 18, 2018 in Kubernetes by Hannah
• 14,080 points
131 views
0 votes
1 answer

Do not wantthe cron job to restart with failure

you have to set a backoffLimit: 0 in combination ...READ MORE

answered Sep 18, 2018 in Kubernetes by Kalgi
• 35,720 points
61 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
447 views
+3 votes
1 answer
0 votes
2 answers

Is there a way to start a cron job manually

You can create a simple job based ...READ MORE

answered Sep 18, 2018 in Kubernetes by Nilesh
• 6,900 points
188 views
0 votes
1 answer

Connect to existing pod, execute script, disconnect - Kubernetes cron job

As far as i know there's no ...READ MORE

answered Sep 17, 2018 in Kubernetes by Kalgi
• 35,720 points
302 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.