Can you move these 2 lines up above the allocateResources() call.  That way max failed check happens first, then we would add in any missing executors, and then call allocate.