Files
ansible/test
David Shrewsbury 75d8321745 Fix IndexError in free strategy when hosts become unreachable (#87037) (#87089)
* Fix IndexError in free strategy when hosts become unreachable

Fixes an IndexError crash in the free strategy plugin when hosts
become unreachable during playbook execution.

The bug occurred when:
- last_host index persists across outer loop iterations
- hosts_left is regenerated each iteration via get_hosts_left()
- Some hosts become unreachable between iterations
- hosts_left shrinks but last_host retains its previous value
- Accessing hosts_left[last_host] raises IndexError

The fix adds a bounds check after regenerating hosts_left to reset
last_host to 0 if it's out of bounds. This preserves the round-robin
fairness algorithm while preventing the IndexError.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* integration test

* review comment fixes

* ci_complete

(cherry picked from commit 08a71d148e)
2026-06-10 13:49:43 -05:00
..
2026-02-28 18:25:26 +10:00