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

can you change this to have similar logic - allocate outside loop, then inside loop add missing and then allocate.