Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
d80tb7 committed Dec 1, 2024
1 parent 05b5f29 commit 34f31b7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions internal/scheduler/nodedb/nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ func (nodeDb *NodeDb) selectNodeForJobWithFairPreemption(txn *memdb.Txn, jctx *c
for obj := it.Next(); obj != nil && selectedNode == nil; obj = it.Next() {
evictedJobSchedulingContext := obj.(*EvictedJobSchedulingContext)
evictedJctx := evictedJobSchedulingContext.JobSchedulingContext
println(fmt.Sprintf("evicting job with ts %d", evictedJctx.Job.SubmitTime()))
nodeId := evictedJctx.GetAssignedNodeId()
if nodeId == "" {
return nil, errors.Errorf("evicted job %s does not have an assigned nodeId", evictedJctx.JobId)
Expand Down
30 changes: 23 additions & 7 deletions internal/scheduler/scheduling/jobiteration.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func (it *MultiJobsIterator) Next() (*schedulercontext.JobSchedulingContext, err
type MarketDrivenMultiJobsIterator struct {
it1 JobContextIterator
it2 JobContextIterator

// TOOD: ideally we add peek() to JobContextIterator and remove these

Check failure on line 178 in internal/scheduler/scheduling/jobiteration.go

View workflow job for this annotation

GitHub Actions / lint / Lint Go

`TOOD` is a misspelling of `TODO` (misspell)
it1Value *schedulercontext.JobSchedulingContext
it2Value *schedulercontext.JobSchedulingContext
}

func NewMarketDrivenMultiJobsIterator(it1, it2 JobContextIterator) *MarketDrivenMultiJobsIterator {
Expand All @@ -184,32 +188,44 @@ func NewMarketDrivenMultiJobsIterator(it1, it2 JobContextIterator) *MarketDriven
}

func (it *MarketDrivenMultiJobsIterator) Next() (*schedulercontext.JobSchedulingContext, error) {
j1, err := it.it1.Next()
if err != nil {
return nil, err
if it.it1Value == nil {
j, err := it.it1.Next()
if err != nil {
return nil, err
}
it.it1Value = j
}

j2, err := it.it2.Next()
if err != nil {
return nil, err
if it.it2Value == nil {
j, err := it.it2.Next()
if err != nil {
return nil, err
}
it.it2Value = j
}

j1 := it.it1Value
j2 := it.it2Value
// Both iterators active.
if j1 != nil && j2 != nil {
if it.it1Value != nil && j2 != nil {
if (jobdb.MarketSchedulingOrderCompare(j1.Job, j2.Job)) < 0 {
it.it1Value = nil
return j1, nil
} else {
it.it2Value = nil
return j2, nil
}
}

// Only first iterator has job
if j1 != nil {
it.it1Value = nil
return j1, nil
}

// Only second iterator has job
if j2 != nil {
it.it2Value = nil
return j2, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ func TestMarketDrivenPreemptingQueueScheduler(t *testing.T) {

result, err := sch.Schedule(ctx)
require.NoError(t, err)
for _, j := range result.PreemptedJobs {
ctx.Infof("Preempted job with submittred time %d", j.Job.SubmitTime())
}
jobIdsByGangId = sch.jobIdsByGangId
gangIdByJobId = sch.gangIdByJobId

Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/scheduling/queue_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (sch *QueueScheduler) Schedule(ctx *armadacontext.Context) (*SchedulerResul
return nil, err
default:
}

ctx.Infof("Scheduling job in queue %s with price %d and submit time %s", gctx.Queue, gctx.JobSchedulingContexts[0].Job.BidPrice(), gctx.JobSchedulingContexts[0].Job.SubmitTime())
start := time.Now()
scheduledOk, unschedulableReason, err := sch.gangScheduler.Schedule(ctx, gctx)
if err != nil {
Expand Down

0 comments on commit 34f31b7

Please sign in to comment.