Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) When mixed with the free strategy (or any custom strategy that does not behave in a lock-step manner), the linear methodology of _wait_on_handler_results may cause race conditions with regular task result processing if the strategy uses _process_pending_results directly. This patch addresses that by splitting the queues used for results and adding a flag to _process_pending_results to determine which queue to check. Fixes #69457 (cherry picked from commit a4072ad) Co-authored-by: James Cammarata <jimi@sngx.net>
- Loading branch information
Showing
10 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bugfixes: | ||
- Prevent a race condition when running handlers using a combination of the free strategy and include_role. | ||
minor_changes: | ||
- The results queue and counter for results are now split for standard / handler results. This allows the governing strategy to be truly independent from the handler strategy, which basically follows the linear methodology. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
shippable/posix/group4 | ||
handler_race | ||
skip/aix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
host001 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host002 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host003 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host004 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host005 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host006 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host007 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host008 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host009 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host010 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host011 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host012 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host013 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host014 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host015 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host016 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host017 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host018 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host019 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host020 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host021 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host022 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host023 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host024 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host025 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host026 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host027 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host028 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host029 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" | ||
host030 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/handler_race/roles/do_handlers/handlers/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
# handlers file for do_handlers | ||
- name: My Handler | ||
shell: sleep 5 |
9 changes: 9 additions & 0 deletions
9
test/integration/targets/handler_race/roles/do_handlers/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
# tasks file for do_handlers | ||
- name: Invoke handler | ||
shell: sleep 1 | ||
notify: | ||
- My Handler | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers |
8 changes: 8 additions & 0 deletions
8
test/integration/targets/handler_race/roles/more_sleep/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# tasks file for more_sleep | ||
- name: Random more sleep | ||
set_fact: | ||
more_sleep_time: "{{ 5 | random }}" | ||
|
||
- name: Moar sleep | ||
shell: sleep "{{ more_sleep_time }}" |
8 changes: 8 additions & 0 deletions
8
test/integration/targets/handler_race/roles/random_sleep/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# tasks file for random_sleep | ||
- name: Generate sleep time | ||
set_fact: | ||
sleep_time: "{{ 60 | random }}" | ||
|
||
- name: Do random sleep | ||
shell: sleep "{{ sleep_time }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
ansible-playbook test_handler_race.yml -i inventory -v "$@" | ||
|
10 changes: 10 additions & 0 deletions
10
test/integration/targets/handler_race/test_handler_race.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- hosts: all | ||
gather_facts: no | ||
strategy: free | ||
tasks: | ||
- include_role: | ||
name: random_sleep | ||
- include_role: | ||
name: do_handlers | ||
- include_role: | ||
name: more_sleep |