Skip to content

Hash steps not working as expected #381

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

Open
darthmaim opened this issue May 22, 2025 · 2 comments · May be fixed by #382
Open

Hash steps not working as expected #381

darthmaim opened this issue May 22, 2025 · 2 comments · May be fixed by #382
Assignees

Comments

@darthmaim
Copy link

darthmaim commented May 22, 2025

Usually expressions like H/5 * * * * mean "Every 5 minutes starting at a random offset between 0 and 4 minutes", guaranteeing 12 runs per hour.1

This library on the other hand evaluates this to "Every 5 minutes starting at a random offset between 0 and 59 minutes". Depending on the hashSeed this can be between 12 or even just 1 time per hour.

As this is in my opinion unexpected and I can't think of any real usecases for this, I would consider this a bug.

If for any reason this behavior is kept, this library should support hash ranges, so H(0-4)/5 * * * * could be used instead.2

Footnotes

  1. For example in jenkins, which the PR Adding support for the H syntax, allowing to add jitter to a cron expression #377 was based on: https://www.jenkins.io/doc/book/pipeline/syntax/#cron-syntax

  2. Note that jenkins also evaluates this differently, taken from the documentation:
    H(0-29)/10 * * * *: every ten minutes in the first half of every hour (three times, perhaps at :04, :14, :24)

@harrisiirak
Copy link
Owner

Hi @darthmaim!

Thanks for explaining this clearly and pointing out the core of the missing functionality. Without support for steps and ranges, it's indeed missing half of its functionality, and also current behavior isn't expected. I'll add it to my backlog and look into it as soon as I can.

Best regards

@harrisiirak harrisiirak linked a pull request May 23, 2025 that will close this issue
@harrisiirak
Copy link
Owner

Opened draft PR #382. If I didn’t miss anything, it should include all the missing features for H syntax. I’ll clean it up a bit over the weekend.

@darthmaim, any feedback is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants