HOW TO FIX: K8 job stoped and is not schedule any more

7/19/2019

I had to stop a job in k8 by killing the pod, and now the job is not schedule anymore.

# Import
  - name: cron-xml-import-foreman
    schedule: "*/7 * * * *"
    args:
      - /bin/sh
      - -c
      /var/www/bash.sh; /usr/bin/php /var/www/import-products.php -->env=prod;
    resources:
      request_memory: "3Gi"
      request_cpu: "2"
      limit_memory: "4Gi"
      limit_cpu: "4"

Error :

Warning FailedNeedsStart 5m34s (x7883 over 29h) cronjob-controller Cannot determine if job needs to be started: Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.

-- Criste Horge Lucian
cron
devops
kubernetes
kubernetes-jobs

1 Answer

7/19/2019

According to the official documentation:

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.


A CronJob is counted as missed if it has failed to be created at its scheduled time. For example, If concurrencyPolicy is set to Forbid and a CronJob was attempted to be scheduled when there was a previous schedule still running, then it would count as missed.


And regarding the concurrencyPolicy

It specifies how to treat concurrent executions of a job that is created by this cron job.

Check your CronJob configuration and adjust those values accordingly.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow