[SPARK-1978] In some cases, spark-yarn does not automatically restart the failed container

You are correct that it isn't updated until that is called and in this has it really doesn't matter to much since we are in while loop and then after this we will just go to the reporter thread to continue to loop.  I just find it odd to add in missing executors but then not call allocate immediately afterwards (we sleep and then we possibly break from the loop).   For that reason I would prefer these to be moved up.  Yes we have one extra unneeded call to them, but I think it flows better and will be more resilient to other code changes in the future.  
Also note that launchReporterThread runs the logic the same way so right now you are doing the failed check and and allocateMissing twice in a row on the first time it goes into the reporter thread.

If you really have objections to that then we could make one call of allocateResources() outside of the while loop and then do the checkFailed, allocateMissing, and then allocateResources in side the while loop.