Skip to content
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

fix(cron): correctly run when startingDeadlineSeconds and timezone are set #13795

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

Joibel
Copy link
Member

@Joibel Joibel commented Oct 21, 2024

Fixes #13786

Motivation

If a CronWorkflow is tested for whether it should run within startingDeadlineSeconds it tests it in the wrong timezone.

This doesn't matter for hourly or minutely CWFs.
This doesn't matter if a CWF doesn't have a timezone associated with it.

This test happens on Informer relist, so if the relist occurs at the wrong time the CWF can be erroneously fired.

This was introduced in #12616 (see linked issue) in version 3.6.

Modifications

The main change is to use GetSchedulesWithTimezone() rather than GetSchedules() when iterating over the schedules to check startingDeadlineSeconds.

The code was confusing (and confusing before #12616) in that it attempted to modify timeNow() to be in a local time. This was irrelevant and made spotting the bug harder. I have removed it. All time.Time comparisons are timezone aware, so modifying time.Now() using In() has no effect on any comparisons made.

Verification

Manual testing with a 20second relist interval.

Two new unit tests (in a single function). If you reverse the main modification above both tests will then not pass and give inverse results for the missedExecutionTime assertions.

These tests will assert if run in Auckland timezone. This could be improved by making the test more complex (pick one of two timezones), but I didn't think this was worthwhile at the moment.

Notes

This PR should not be backported to v3.5 or earlier

Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel Joibel added area/cron-workflows prioritized-review For members of the Sustainability Effort labels Oct 21, 2024
@Joibel Joibel marked this pull request as ready for review October 21, 2024 11:38
@agilgur5 agilgur5 added this to the v3.6.0 milestone Oct 21, 2024
@agilgur5 agilgur5 changed the title fix: CronWorkflows startingDeadlineSeconds with timezone fix fix(cron): correctly run when startingDeadlineSeconds and timezone are set Oct 21, 2024
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@isubasinghe isubasinghe merged commit 7d0d34e into argoproj:main Oct 21, 2024
29 checks passed
@Joibel Joibel deleted the cronwf-tz-deadline branch October 22, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cron-workflows prioritized-review For members of the Sustainability Effort
Projects
None yet
3 participants