hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.55k stars 1.92k forks source link

Systemd timer format for periodic jobs #18079

Open aneustroev opened 11 months ago

aneustroev commented 11 months ago

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.

tgross commented 11 months ago

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

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.

aneustroev commented 11 months ago

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

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.

tgross commented 11 months ago

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.

aneustroev commented 3 months ago

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?

tgross commented 2 months ago

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