hashicorp / hashicorp/nomad

periodic job start at a later date and time

Open
#12,796 3 comments 0 reactions 0 assignees View on GitHub
stage/needs-discussion theme/batch type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal
The current meaning of a `batch` job is to be "enabled" from the moment the job is `run`, i.e. "now".
_The use case for this is primarily in context of `periodic` (`cron`) jobs, but can also be thought of for regular `batch` jobs._

I propose, two new fields for the `job` which can be used to activate (or enable) the `batch` job from a future date and also be able to govern when the job ends, i.e. not run past a certain time.

Current stanza:

```hcl
type = "batch"

periodic {
cron = "*/15 * * * * *"
}
```

Proposed solution:

```hcl
type = "batch"

start_at = "2022-MAY-04" # timestamp can be a standard format, strings used here only for sake of clarity.
end_at = "2022-JUNE-04"

periodic {
cron = "*/15 * * * * *"
}
```

### Use-cases
The use case is to be able to have a job be "run" now, but not activate (i.e. start) until a future date.

### Attempted Solutions
1. For a time spec which repeats within a day, this can be achieved by submitting three separate jobs (but seems hacky):

* from the **specified date** to end of the month.
* from the **subsequent month** to the end of the year.
* from the **subsequent year** to the end-of-time.

2. Submit two jobs, one which runs at the specific time (`2022-MAY-04`) which in turn submits the actual simple periodic job. (this too seems hacky).
A third job can be scheduled to run on `2022-JUNE-04`, which does a `stop -purge` on the first job.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue does not name files, tests, or an entry point. Start by tracing Nomad's batch and periodic job scheduling paths; done means agreeing on and implementing a supported way to activate jobs at a future time and stop them after a specified time.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.