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 always are evaluated in UTC TZ #1074

Merged
merged 1 commit into from
Apr 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (c *RunCommand) Run(args []string) int {
if detach || periodic {
c.Ui.Output("Job registration successful")
if periodic {
c.Ui.Output(fmt.Sprintf("Approximate next launch time: %v", job.Periodic.Next(time.Now())))
c.Ui.Output(fmt.Sprintf("Approximate next launch time: %v", job.Periodic.Next(time.Now().UTC())))
} else {
c.Ui.Output("Evaluation ID: " + evalID)
}
Expand Down
2 changes: 1 addition & 1 deletion command/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (c *StatusCommand) Run(args []string) int {

if periodic {
basic = append(basic, fmt.Sprintf("Next Periodic Launch|%v",
sJob.Periodic.Next(time.Now())))
sJob.Periodic.Next(time.Now().UTC())))
}

c.Ui.Output(formatKV(basic))
Expand Down
6 changes: 3 additions & 3 deletions nomad/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (p *PeriodicDispatch) Add(job *structs.Job) error {

// Add or update the job.
p.tracked[job.ID] = job
next := job.Periodic.Next(time.Now())
next := job.Periodic.Next(time.Now().UTC())
if tracked {
if err := p.heap.Update(job, next); err != nil {
return fmt.Errorf("failed to update job %v launch time: %v", job.ID, err)
Expand Down Expand Up @@ -281,7 +281,7 @@ func (p *PeriodicDispatch) ForceRun(jobID string) (*structs.Evaluation, error) {
}

p.l.Unlock()
return p.createEval(job, time.Now())
return p.createEval(job, time.Now().UTC())
}

// shouldRun returns whether the long lived run function should run.
Expand All @@ -301,7 +301,7 @@ func (p *PeriodicDispatch) run() {
if launch.IsZero() {
launchCh = nil
} else {
launchDur := launch.Sub(time.Now())
launchDur := launch.Sub(time.Now().UTC())
launchCh = time.After(launchDur)
p.logger.Printf("[DEBUG] nomad.periodic: launching job %q in %s", job.ID, launchDur)
}
Expand Down
4 changes: 3 additions & 1 deletion website/source/docs/jobspec/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ The `job` object supports the following keys:
```

* `periodic` - `periodic` allows the job to be scheduled at fixed times, dates
or intervals. The `periodic` block supports the following keys:
or intervals. The periodic expression is always evaluated in the UTC
timezone to ensure consistent evaluation when Nomad Servers span multiple
time zones. The `periodic` block supports the following keys:

* `enabled` - `enabled` determines whether the periodic job will spawn child
jobs. `enabled` is defaulted to true if the block is included.
Expand Down
4 changes: 3 additions & 1 deletion website/source/docs/jobspec/json.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ The `Job` object supports the following keys:
```

* `Periodic` - `Periodic` allows the job to be scheduled at fixed times, dates
or intervals. The `Periodic` object supports the following attributes:
or intervals. The periodic expression is always evaluated in the UTC
timezone to ensure consistent evaluation when Nomad Servers span multiple
time zones. The `Periodic` object supports the following attributes:

* `Enabled` - `Enabled` determines whether the periodic job will spawn child
jobs.
Expand Down