Would it make sense to do this check before sleeping?  Otherwise, this may have to wait for an extra interval:

1.  request to get group-state in lines 268-269
1.  the expected number of servers isn't up yet, but the desiredCapacity is off.
1. wait `interval seconds`
1. since the desiredCapacity is off, fail.