Skip to content

Commit

Permalink
backport of commit ec17aab (#16653)
Browse files Browse the repository at this point in the history
This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core committed Mar 27, 2023
1 parent 55251b7 commit 44664f7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ func (s *Server) restorePeriodicDispatcher() error {
continue
}

if _, err := s.periodicDispatcher.ForceRun(job.Namespace, job.ID); err != nil {
if _, err := s.periodicDispatcher.ForceEval(job.Namespace, job.ID); err != nil {
logger.Error("force run of periodic job failed", "job", job.NamespacedID(), "error", err)
return fmt.Errorf("force run of periodic job %q failed: %v", job.NamespacedID(), err)
}
Expand Down
4 changes: 2 additions & 2 deletions nomad/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ func (p *PeriodicDispatch) removeLocked(jobID structs.NamespacedID) error {
return nil
}

// ForceRun causes the periodic job to be evaluated immediately and returns the
// ForceEval causes the periodic job to be evaluated immediately and returns the
// subsequent eval.
func (p *PeriodicDispatch) ForceRun(namespace, jobID string) (*structs.Evaluation, error) {
func (p *PeriodicDispatch) ForceEval(namespace, jobID string) (*structs.Evaluation, error) {
p.l.Lock()

// Do nothing if not enabled
Expand Down
2 changes: 1 addition & 1 deletion nomad/periodic_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *Periodic) Force(args *structs.PeriodicForceRequest, reply *structs.Peri
}

// Force run the job.
eval, err := p.srv.periodicDispatcher.ForceRun(args.RequestNamespace(), job.ID)
eval, err := p.srv.periodicDispatcher.ForceEval(args.RequestNamespace(), job.ID)
if err != nil {
return fmt.Errorf("force launch for job %q failed: %v", job.ID, err)
}
Expand Down
14 changes: 7 additions & 7 deletions nomad/periodic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ func TestPeriodicDispatch_Remove_TriggersUpdate(t *testing.T) {
}
}

func TestPeriodicDispatch_ForceRun_Untracked(t *testing.T) {
func TestPeriodicDispatch_ForceEval_Untracked(t *testing.T) {
ci.Parallel(t)
p, _ := testPeriodicDispatcher(t)

if _, err := p.ForceRun("ns", "foo"); err == nil {
t.Fatal("ForceRun of untracked job should fail")
if _, err := p.ForceEval("ns", "foo"); err == nil {
t.Fatal("ForceEval of untracked job should fail")
}
}

func TestPeriodicDispatch_ForceRun_Tracked(t *testing.T) {
func TestPeriodicDispatch_ForceEval_Tracked(t *testing.T) {
ci.Parallel(t)
p, m := testPeriodicDispatcher(t)

Expand All @@ -377,9 +377,9 @@ func TestPeriodicDispatch_ForceRun_Tracked(t *testing.T) {
t.Fatalf("Add failed %v", err)
}

// ForceRun the job
if _, err := p.ForceRun(job.Namespace, job.ID); err != nil {
t.Fatalf("ForceRun failed %v", err)
// ForceEval the job
if _, err := p.ForceEval(job.Namespace, job.ID); err != nil {
t.Fatalf("ForceEval failed %v", err)
}

// Check that job was launched correctly.
Expand Down

0 comments on commit 44664f7

Please sign in to comment.