mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 03:45:41 +03:00
Use desired launch time in periodic launch table
This commit is contained in:
@@ -244,7 +244,13 @@ func (n *nomadFSM) applyUpsertJob(buf []byte, index uint64) interface{} {
|
||||
}
|
||||
|
||||
if parent.IsPeriodic() {
|
||||
launch := &structs.PeriodicLaunch{ID: parentID, Launch: time.Now()}
|
||||
t, err := n.periodicDispatcher.LaunchTime(req.Job.ID)
|
||||
if err != nil {
|
||||
n.logger.Printf("[ERR] nomad.fsm: LaunchTime(%v) failed: %v", req.Job.ID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
launch := &structs.PeriodicLaunch{ID: parentID, Launch: t}
|
||||
if err := n.state.UpsertPeriodicLaunch(index, launch); err != nil {
|
||||
n.logger.Printf("[ERR] nomad.fsm: UpsertPeriodicLaunch failed: %v", err)
|
||||
return err
|
||||
|
||||
@@ -388,13 +388,13 @@ func TestLeader_PeriodicDispatcher_Restore_NoEvals(t *testing.T) {
|
||||
// Flush the periodic dispatcher, ensuring that no evals will be created.
|
||||
s1.periodicDispatcher.SetEnabled(false)
|
||||
|
||||
// Sleep till after the job should have been launched.
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
// Get the current time to ensure the launch time is after this once we
|
||||
// restore.
|
||||
now := time.Now()
|
||||
|
||||
// Sleep till after the job should have been launched.
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
// Restore the periodic dispatcher.
|
||||
s1.periodicDispatcher.SetEnabled(true)
|
||||
s1.periodicDispatcher.Start()
|
||||
@@ -412,7 +412,7 @@ func TestLeader_PeriodicDispatcher_Restore_NoEvals(t *testing.T) {
|
||||
}
|
||||
|
||||
if last.Launch.Before(now) {
|
||||
t.Fatalf("restorePeriodicDispatcher did not force launch")
|
||||
t.Fatalf("restorePeriodicDispatcher did not force launch: last %v; want after %v", last.Launch, now)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user