Conversation
|
Could you add a unit test for this? |
|
test added |
| List<SingularityTaskId> sortedOtherTasks = new ArrayList<>(otherActiveTasks); | ||
| Collections.sort(sortedOtherTasks, SingularityTaskId.INSTANCE_NO_COMPARATOR); | ||
| return sortedOtherTasks.subList(0, numTasksToShutDown); | ||
| return sortedOtherTasks.subList(0, Math.min(numTasksToShutDown, sortedOtherTasks.size() - 1)); |
There was a problem hiding this comment.
i might be misunderstanding something obvious, but why subtract one here?
There was a problem hiding this comment.
e.g. size of the array is 2, so the max index we can use for the sublist is 1
There was a problem hiding this comment.
But if you look at that javadoc, toIndex is exclusive:
* @param fromIndex low endpoint (inclusive) of the subList
* @param toIndex high endpoint (exclusive) of the subList
* @return a view of the specified range within this list
* @throws IndexOutOfBoundsException for an illegal endpoint index value
* (<tt>fromIndex < 0 || toIndex > size ||
* fromIndex > toIndex</tt>)
*/
There was a problem hiding this comment.
So, is it the case that the index out of bounds is coming from the from index then instead? Had just assumed it was on the high end when I made this PR. must have been that the list was empty, will fix, thanks
There was a problem hiding this comment.
Fxed to check both for toIndex errors(with the Math.min) and fromIndex (isEmpty check). First condition gets hit by the test I added, second condition will get hit by a number of other tests
|
Found one last hitch with scale during deploy. If the timing is right, you will end up with the pre-scale number of requests running after the deploy is finished. The deploy ends with the targetActiveInstances, but we currently don't enqueue another pending request on successful deploy. Going to extend the test to check for this case then figure out the best way to fix it |
|
LGTM |
@stevenschlansker should fix that edge case you ran into the other day when scaling + deploying at the same time