Periodic jobs always are evaluated in UTC TZ

This commit is contained in:
Alex Dadgar
2016-04-12 09:47:25 -07:00
parent e263f91463
commit b63f3bb078
5 changed files with 11 additions and 7 deletions

View File

@@ -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)
}

View File

@@ -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))

View File

@@ -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)
@@ -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.
@@ -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)
}

View File

@@ -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.

View File

@@ -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.