5

I have a configured a cronjob in OpenShift. Its crontab entry looks like this:

spec:
  schedule: "0 3 * * 1-5"
  jobTemplate:

So it should run at 03:00 in the morning on weekdays. All cluster nodes are configured to use our local timezone, CET, which is UTC+1. This is visible via the date command. OpenShift documentation says that cronjobs are executed via the crontab matching the configured time zone of the master nodes, so i expect the cronjobs to actually run at 03:00 CET.

However, according to the logs, the cronjobs are executed at 04:00 which is 03:00 CET in UTC. The strange part is that oc describe cronjob reveals:

Last Schedule Time:  Mon, 14 Jan 2019 04:00:00 +0100

So, the server actually knows that the cronjob is executed one hour too late.

My question is: Why is the cronjob executed one hour too late, why does the server know about it, and how can i fix this?

2
  • Check the system timezone of your master nodes. – Michael Hampton Jan 14 '19 at 15:43
  • They are configured as CET as well. – simonszu Jan 15 '19 at 13:46
6

CronJobs are controlled by the master-controller.

In Openshift (after ~v3.10), the controllers are run as a pod, defined in /etc/origin/node/pods (at least in our setup).

We had the exact same problem and noticed that the timestamp in controller-logs was one hour off.

This was fixed by adding a mount in /etc/origin/node/pods/controller.yaml

Under volumeMounts:, add:

   - mountPath: /etc/localtime
      name: localtime

Under volumes:, add:

  - hostPath:
      path: /etc/localtime
    name: localtime

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.