-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kube_cronjob_next_schedule_time in the past when cronjob timezone specified #2206
Comments
/assign @dgrisonnet |
The source code is here: kube-state-metrics/internal/store/cronjob.go Lines 238 to 263 in b91dd31
Could you dive into it and help debug if you are available? |
I'm not a go developer, but I suspect that what's happening is that j.Spec.Schedule doesn't include the timezone, so the cron library is interpreting it in local time (UTC). So if this code were to run just after the cronjob had run (in UTC+1), it would say the next scheduled time was still 1 hour away. The cronjob library expects the timezone to be specified like this: I'm not sure if this is being done. |
Hi @paulclark222, j.Spec does have a field named timezone, which hasn't been used https://github.com/kubernetes/api/blob/master/batch/v1/types.go#L637 |
Could you ramp up golang and try to fix this issue, if you are available and have enough time? |
The code for the metric predates the support for timezone, so it is not taken into account. We would need to had support for it in ksm. /help |
@dgrisonnet: GuidelinesPlease ensure that the issue body includes answers to the following questions:
For more details on the requirements of such an issue, please see here and ensure that they are met. If this request no longer meets these requirements, the label can be removed In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I encountered the same issue after configuring the timezone. Any recent updates or ETA on a resolution? Thanks! |
+1 |
+1 |
/assign |
I have a fix in #2376 Can you test if this resolves your issue? |
Any idea when the fix will be merged and released? Without the fix, it is not possible to monitor cron jobs with mixed time zones. |
What happened:
Defined a timezone for a cronjob:
timeZone: "Europe/London"
Now kube_cronjob_next_schedule_time is always returning the last schedule time rather than the next one.
What you expected to happen:
kube_cronjob_next_schedule_time should be the next scheduled time.
How to reproduce it (as minimally and precisely as possible):
Define a cronjob with non-UTC timezone (may only happen on zones east of UTC). Wait for the job to execute and then check kube_cronjob_next_schedule_time - you will see it's in the past.
kubectl version
): 1.27The text was updated successfully, but these errors were encountered: