Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ public AssignmentState calculateAssignmentState() {
if (assignmentState.equals(AssignmentState.STOPPING)) {
return assignmentState;
}
if (taskParams.getNumberOfAllocations() == 0) {
return AssignmentState.STARTED;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are code paths where you can get into state of numberOfAllocations=0 and assignmentState=STARTING. I think that can happen when the scheduler moves jobs around, which triggers the state to be recalculated here.

This causes issues, because assignments in a STARTING state cannot be updated, and an assignment with numberOfAllocations=0 won't get out of that state.

}
if (nodeRoutingTable.values().stream().anyMatch(r -> r.getState().equals(RoutingState.STARTED))) {
return AssignmentState.STARTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public void testCalculateAssignmentState_GivenNoStartedAssignments() {
assertThat(builder.calculateAssignmentState(), equalTo(AssignmentState.STARTING));
}

public void testCalculateAssignmentState_GivenNumAllocationsIsZero() {
TrainedModelAssignment.Builder builder = TrainedModelAssignment.Builder.empty(randomTaskParams(0), null);
assertThat(builder.calculateAssignmentState(), equalTo(AssignmentState.STARTED));
}

public void testCalculateAssignmentState_GivenOneStartedAssignment() {
TrainedModelAssignment.Builder builder = TrainedModelAssignment.Builder.empty(randomTaskParams(5), null);
builder.addRoutingEntry("node-1", new RoutingInfo(4, 4, RoutingState.STARTING, ""));
Expand Down
Loading