saltstack/salt — pull request #16127 by jacksontj (2014-09-24 23:17:48+00:00)
Title: Backport of #16078

This is a fix for the race condition that #15942 was attempting to resolve.

In the past this feature has basically checked returns, pinged minions if they were still running the job, then returning once the job was no longer run remotely. This has caused some issues with race conditions if the minion or master are busy (and the time between minion done, and master received gets large).

This changes the behavior of the "wait" mechanism. The intent of this feature is to wait for the job return from all minions the job went to. To accomplish this we fire the job, then check the returns. If the initial returns are what we wanted/expected we break. If it isn't we will ping all targets and see if its still running. If more minions return, we merge them into the list of minions we are waiting for. We will timeout the job once all minions have stopped running the job and TIMEOUT seconds have passed (since the slowest minion)

In addition this consolidates the 2 iter returners into a single function call-- since the only difference is the return structure. We should look into deprecating one or the other.