nomad icon indicating copy to clipboard operation
nomad copied to clipboard

Systemd timer format for periodic jobs

Open aneustroev opened this issue 2 years ago • 5 comments

Hi there, I want to suggest implement PeriodicSpecSystemd

Proposal

I want to add another one PeriodicSpecType. https://www.freedesktop.org/software/systemd/man/systemd.time.html It is more flexible and usefull for many system administration who knows how to managing systemd.

I forked you cronexpr library, and add systemd timers functionality. (also rewrite some tests and add my) https://github.com/WinnerSoftLab/cronexpr

I can implement it in Nomad, but after my PR https://github.com/hashicorp/nomad/pull/17858 will be merged , because it will have a lot conflicts if I violate the order merges.

Use-cases

Nomad get more flexible and famous format for describe periodic job times.

aneustroev avatar Jul 27 '23 08:07 aneustroev

Hi @aneustroev! This proposal raises a couple of questions for me:

  • Is the systemd.time syntax equivalently expressive as cron syntax? That is, are there intervals that systemd.time that cron cannot or vice-versa?
  • We typically talk about two "personas" of Nomad user: the cluster administrator and the job author. Typically the cluster administrator is someone with more of a sysadmin background, where they might be familiar with cron syntax or systemd.time syntax from their use with cron (or modern replacements) and systemd timers. Whereas the job author might also be the cluster administrator but for many organizations is an application developer. The job author might not be familiar with cron syntax, but I'm not sure that the same author would be more familiar with systemd.time syntax either?

In any case, even if we were to do this, the systemd.time parsing would need to live alongside the cron syntax for backwards compatibility purposes. And we definitely wouldn't want that parsing to be in the cronexpr library; that's specifically for cron syntax so adding another Linux-specific syntax there doesn't make a lot of sense from a library design standpoint.

tgross avatar Jul 28 '23 18:07 tgross

Hi. I don't ask about change format, just about option. :smile: Now you have job.SpecType in Nomad code, but it use only for tests.

Is the systemd.time syntax equivalently expressive as cron syntax? Yes, a little bit spec

  • seconds support
  • year's support And about second question, systemd.time format more human-readable, because it follow nnative time format.
5 4 * * *
# vs
*-*-* 04:05:00 
# or just 
04:05

and with dates

5 4 */2 4-5 *
# vs
*-4..5-01/2 04:05:00 
# or shorter form 
*-4..5-01/2 04:05

Our programmers have no problems and prefer it.

I agree with you about cronexpr design, but parsing systemd.time on 99% similar that cron :smile: that because I extend library for my PoC. It doesn't look like problem, I can create another one separate repository.

aneustroev avatar Jul 31 '23 07:07 aneustroev

Thanks for the clarification @aneustroev. I'm not sure we're definitely going to accept this but I'll move it into roadmapping for further discussion.

tgross avatar Jul 31 '23 12:07 tgross

I made PR https://github.com/hashicorp/nomad/pull/19682, and we use it in production for a month without any problems. Also this allowed us easy migrate from systemd timers to nomad. @tgross Can you pay attention for my PR please?

aneustroev avatar Apr 03 '24 15:04 aneustroev

Hi @aneustroev, I'll try to get that reviewed in the next week.

tgross avatar Apr 04 '24 12:04 tgross