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

Periodic jobs for system scheduler #1944

Closed
kak-tus opened this issue Nov 5, 2016 · 19 comments
Closed

Periodic jobs for system scheduler #1944

kak-tus opened this issue Nov 5, 2016 · 19 comments
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/scheduling type/enhancement

Comments

@kak-tus
Copy link

kak-tus commented Nov 5, 2016

Now (0.5.0rc1) nomad not support periodic jobs for system scheduler.

* Periodic can only be used with "batch" scheduler

I think, that it is normal use case that someone want to do periodic job on each host.
Yes, I can use system scheduler with docker container with crond inside, but periodic+system is more simple to use, then cron-in-docker solution.

@kak-tus kak-tus changed the title Periodic jobs for system sheduler Periodic jobs for system scheduler Nov 5, 2016
@jippi
Copy link
Contributor

jippi commented Nov 5, 2016

I don't think nomad ever supported periodic jobs for any type but batch - but having a way to run something across all hosts could be nice.

today we use rundeck for that :)

@dadgar
Copy link
Contributor

dadgar commented Nov 7, 2016

Hey as @jippi mentioned, this has never been supported but it is a valid use case. Tagged as an enhancement. Thanks!

@oribaldi
Copy link

oribaldi commented Dec 9, 2016

@dadgar Is there a way to simulate this with the batch scheduler? In other words, how can we run a periodic job on each host with the batch scheduler? Setting the distinct_host constraint is not enough.

@dadgar
Copy link
Contributor

dadgar commented Dec 12, 2016

@oribaldi There really is no elegant workaround with out scheduler support. You could run the batch scheduler with distinct_host and a count equal to the number of nodes on the cluster but there is no guarantee that will target every node. It may be worth just running the system scheduler as is, and wrapping your "batch" job in a script that acts as a cron and starts up the task every N minutes.

Sorry that there isn't a great work around.

@oribaldi
Copy link

@dadgar Thanks for the reply! We will go for the cron job then.

@huntercatalan
Copy link

+1. for now, i have a master job that restarts scheduled system jobs maintained in a separate config.

@ketzacoatl
Copy link
Contributor

I would love to use nomad as a distributed cron, and move my "management tasks" running on various CM systems over to nomad, but need this to do so.

@shantanugadgil
Copy link
Contributor

My use case is to run a "cleanup" of the docker directory at '/var/lib/docker'.
(even though I have image cleanup set to true in my agents)

@henyxia
Copy link

henyxia commented Jul 3, 2019

Any chance to have this feature developed any time soon? 🙏

@kcajf
Copy link

kcajf commented Nov 14, 2019

This would be super useful for important periodic cleanup jobs

@ndobbs
Copy link

ndobbs commented Feb 27, 2020

This would be great to have, I have a few scenarios where a 'system' job could be scheduled periodically.

@shantanugadgil
Copy link
Contributor

shantanugadgil commented Feb 27, 2020

based on a suggestion by Tommy Alatalo in the Gitter room, you can leverage the restart section of the system job to mimic the periodic behavior:

ref: https://gitter.im/hashicorp-nomad/Lobby?at=5e4beee0d97c107ed25e3a91
(sorry, I could not find his previous reply, which made me post this)

@ndobbs
Copy link

ndobbs commented Feb 27, 2020

based on a suggestion by Tommy Alatalo in the Gitter room, you can leverage the restart section of the system job to mimic the periodic behavior:

ref: https://gitter.im/hashicorp-nomad/Lobby?at=5e4beee0d97c107ed25e3a91
(sorry, I could his previous reply, which made me post this)

Thanks a ton!

@tgross tgross added the stage/accepted Confirmed, and intend to work on. No timeline committment though. label Aug 24, 2020
@tino
Copy link

tino commented Oct 27, 2020

@jippi: I don't think nomad ever supported periodic jobs for any type but batch - but having a way to run something across all hosts could be nice.

As in: "I don't think it will ever"?

Is there any chance this enhancment will be added? It sounds like an easy add, as both the system & cron types already exist ☺️. But I haven't looked at the code.

today we use rundeck for that :)

Looks like a nice tool but I really think it would be something nomad could easily provide, saving me from having yet another tool to manage things in our infra... :)

@shantanugadgil
Copy link
Contributor

@tino you could try the restart stanza trick to simulate periodic behavior ...
ref: #1944 (comment)

@tino
Copy link

tino commented Nov 5, 2020

I could but that means I have to fail the task, which will give noise. ("The restart stanza configures a tasks's behavior on task failure. Restarts happen on the client that is running the task.")

I currently implemented it by running a 24h sleep around the actual task in a loop. Also ugly, hence my request to the Nomad team to take another look at this 😉

@shantanugadgil
Copy link
Contributor

@tino I too once had something similar ... a "while 1" loop with a sleep of 24h 😄

Just for the record ... I am mentioning the restart stanza here to get the hack to work.
(I keep searching for this from time to time myself)

Note delay is the "cadence" with which you want the job to execute.
interval should be double than the delay

group "something" {
  ...
  restart {
    interval = "4h"
    attempts = 1
    delay    = "2h"
    mode     = "delay"
  }
  ...

@tgross tgross added this to Needs Roadmapping in Nomad - Community Issues Triage Feb 12, 2021
@tgross tgross removed this from Needs Roadmapping in Nomad - Community Issues Triage Mar 3, 2021
@lgfa29
Copy link
Contributor

lgfa29 commented Oct 14, 2021

Thank you all the input and waiting for this feature. sysbatch jobs are now supported in Nomad 1.2 and they can be set as periodic just like regular batch jobs 🎉

Feel free to open new issues if you find any problems with sysbatch jobs 🙂

Closed by #9160.

@lgfa29 lgfa29 closed this as completed Oct 14, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/scheduling type/enhancement
Projects
None yet
Development

No branches or pull requests