Skip to content

Commit

Permalink
JobContext Should Not Report Leased Returned Jobs As Away (#3999)
Browse files Browse the repository at this point in the history
* fix job state

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>

* add test

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>

---------

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>
  • Loading branch information
d80tb7 authored Oct 11, 2024
1 parent 7248240 commit a6f6af7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/scheduler/scheduling/context/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ type JobSchedulingContext struct {
}

func (jctx *JobSchedulingContext) IsHomeJob(currentPool string) bool {
// Away jobs will only even be evicted in this round - and by definition have a run
// Therefore any job without a run we can assume is a home job
if jctx.Job.LatestRun() == nil {
// Away jobs can never have been scheduled in this round
// and therefore must have an active run
if jctx.Job.Queued() || jctx.Job.LatestRun() == nil {
return true
}
return jctx.Job.LatestRun().Pool() == currentPool
Expand Down
5 changes: 5 additions & 0 deletions internal/scheduler/scheduling/context/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ func TestJobSchedulingContext_IsHomePool(t *testing.T) {
job = job.WithNewRun("executor", "node-id", "node", "other", 1)
jctx = &JobSchedulingContext{Job: job}
assert.False(t, jctx.IsHomeJob(testfixtures.TestPool))

// Add returned run for a different pool
job = job.WithNewRun("executor", "node-id", "node", "other", 1).WithQueued(true)
jctx = &JobSchedulingContext{Job: job}
assert.True(t, jctx.IsHomeJob(testfixtures.TestPool))
}

0 comments on commit a6f6af7

Please sign in to comment.