mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 19:35:41 +03:00
Merge pull request #1074 from hashicorp/f-periodic-utc
Periodic jobs always are evaluated in UTC TZ
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user