Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
fix: allocator restarting unnecessarily (#666)
Browse files Browse the repository at this point in the history
Fixes an issue whereby everytime a job runs the allocator service would
restart.
  • Loading branch information
leg100 committed Dec 10, 2023
1 parent e196837 commit 47f8e6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/agent/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ func (a *allocator) allocate(ctx context.Context) error {
a.agents[*job.AgentID].CurrentJobs--
continue
default:
return fmt.Errorf("unknown job status: %s", job.Status)
// job running; ignore
continue
}
// allocate job to available agent
var available []*Agent
Expand Down
8 changes: 8 additions & 0 deletions internal/agent/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ func TestAllocator_allocate(t *testing.T) {
wantJob: nil,
wantAgents: map[string]*Agent{"agent-1": {ID: "agent-1", CurrentJobs: 0}},
},
{
name: "ignore running job",
job: &Job{
Spec: JobSpec{RunID: "run-123", Phase: internal.PlanPhase},
Status: JobRunning,
AgentID: internal.String("agent-1"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 47f8e6f

Please sign in to comment.