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

fix: allocator restarting unnecessarily #666

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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