Skip to content

Commit

Permalink
Set assignment state to "started" in case of zero allocations (elasti…
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-elastic authored Oct 29, 2024
1 parent b6a5192 commit aad4fc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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;
}
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

0 comments on commit aad4fc9

Please sign in to comment.