Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlers ignore serial/strategy #65067

Closed
twouters opened this issue Nov 19, 2019 · 5 comments · Fixed by #77955
Closed

Handlers ignore serial/strategy #65067

twouters opened this issue Nov 19, 2019 · 5 comments · Fixed by #77955
Labels
affects_2.9 This issue/PR affects Ansible v2.9 affects_2.14 bug This issue/PR relates to a bug. collection:newswangerd.c1 collection Related to Ansible Collections work has_pr This issue has an associated PR. python3 support:community This issue/PR relates to code supported by the Ansible community.

Comments

@twouters
Copy link
Contributor

SUMMARY

Handlers run one by one, on host at a time.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

strategy / serial

ANSIBLE VERSION
ansible 2.9.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/twouters/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.0 (default, Oct 23 2019, 18:51:26) [GCC 9.2.0]
CONFIGURATION
➜  /tmp ansible-config dump --only-changed
➜  /tmp 
OS / ENVIRONMENT

Archlinux

STEPS TO REPRODUCE

The following play shows that handlers "sleep random 4" and "sleep random 5" run one after the other (fine) on one host, but the other hosts wait for them to finish.

- hosts: all
  serial: 5
  strategy: free
  gather_facts: false
  tasks:
    - name: sleep random 1
      command: "sleep {{ 5 | random }}"
      notify: sleep random 4
    - name: sleep random 2
      command: "sleep {{ 5 | random }}"
    - name: sleep random 3
      command: "sleep {{ 5 | random }}"
      notify: sleep random 5
  handlers:
    - name: sleep random 4
      command: "sleep 10"
    - name: sleep random 5
      command: "sleep 10"
EXPECTED RESULTS

Running the handlers should run batched on all hosts and take about 20 seconds, not 60.

ACTUAL RESULTS

It takes >60 seconds to finish all handlers

➜  /tmp ansible-playbook -i localhost,127.0.1.1,127.0.1.2 --connection=local test.yml

PLAY [all] *****************************************************************************************************
Tuesday 19 November 2019  16:20:21 +0100 (0:00:00.018)       0:00:00.018 ****** 
Tuesday 19 November 2019  16:20:21 +0100 (0:00:00.003)       0:00:00.022 ****** 
Tuesday 19 November 2019  16:20:21 +0100 (0:00:00.003)       0:00:00.025 ****** 

TASK [sleep random 1] ******************************************************************************************
changed: [127.0.1.1]
Tuesday 19 November 2019  16:20:21 +0100 (0:00:00.233)       0:00:00.258 ****** 
changed: [127.0.1.2]
Tuesday 19 November 2019  16:20:22 +0100 (0:00:01.025)       0:00:01.284 ****** 

TASK [sleep random 2] ******************************************************************************************
changed: [127.0.1.1]
Tuesday 19 November 2019  16:20:23 +0100 (0:00:01.133)       0:00:02.417 ****** 
changed: [127.0.1.2]
Tuesday 19 November 2019  16:20:24 +0100 (0:00:01.042)       0:00:03.460 ****** 

TASK [sleep random 1] ******************************************************************************************
changed: [localhost]
Tuesday 19 November 2019  16:20:25 +0100 (0:00:00.824)       0:00:04.285 ****** 

TASK [sleep random 2] ******************************************************************************************
changed: [localhost]
Tuesday 19 November 2019  16:20:25 +0100 (0:00:00.139)       0:00:04.424 ****** 

TASK [sleep random 3] ******************************************************************************************
changed: [127.0.1.1]
Tuesday 19 November 2019  16:20:26 +0100 (0:00:01.187)       0:00:05.611 ****** 
changed: [localhost]
changed: [127.0.1.2]

RUNNING HANDLER [sleep random 4] *******************************************************************************
changed: [127.0.1.1]
Tuesday 19 November 2019  16:20:37 +0100 (0:00:10.163)       0:00:15.775 ****** 

RUNNING HANDLER [sleep random 5] *******************************************************************************
changed: [127.0.1.1]
Tuesday 19 November 2019  16:20:47 +0100 (0:00:10.150)       0:00:25.925 ****** 

RUNNING HANDLER [sleep random 4] *******************************************************************************
changed: [127.0.1.2]
Tuesday 19 November 2019  16:20:57 +0100 (0:00:10.128)       0:00:36.054 ****** 

RUNNING HANDLER [sleep random 5] *******************************************************************************
changed: [127.0.1.2]
Tuesday 19 November 2019  16:21:08 +0100 (0:00:11.130)       0:00:47.185 ****** 

RUNNING HANDLER [sleep random 4] *******************************************************************************
changed: [localhost]
Tuesday 19 November 2019  16:21:18 +0100 (0:00:10.130)       0:00:57.315 ****** 

RUNNING HANDLER [sleep random 5] *******************************************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************************
127.0.1.1                  : ok=5    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
127.0.1.2                  : ok=5    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
localhost                  : ok=5    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Tuesday 19 November 2019  16:21:28 +0100 (0:00:10.169)       0:01:07.485 ****** 
=============================================================================== 
sleep random 5 ----------------------------------------------------------------------------------------- 10.17s
sleep random 4 ----------------------------------------------------------------------------------------- 10.13s
sleep random 3 ------------------------------------------------------------------------------------------ 1.19s
sleep random 1 ------------------------------------------------------------------------------------------ 0.23s
sleep random 2 ------------------------------------------------------------------------------------------ 0.14s
Playbook run took 0 days, 0 hours, 1 minutes, 7 seconds
@ansibot
Copy link
Contributor

ansibot commented Nov 19, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 19, 2019
@twouters
Copy link
Contributor Author

sort of the same result on 2.7.7 so it doesn't look like a regression in 2.9 I guess it just doesn't behave how I expected.

ansible 2.7.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Apr  3 2019, 05:39:12) [GCC 8.3.0]

@samdoran
Copy link
Contributor

samdoran commented Dec 3, 2019

"Fixing" this would mean changing handler execution in the free strategy to behave like the linear strategy. I'm not sure that is what we want. Maybe @jimi-c can comment more?

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Dec 3, 2019
@ansibot ansibot added collection Related to Ansible Collections work collection:ibm.qradar collection:splunk.enterprise_security needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 29, 2020
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed collection:ibm.qradar collection:splunk.enterprise_security needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community. labels Aug 16, 2020
@ansibot

This comment has been minimized.

@mkrizek
Copy link
Contributor

mkrizek commented May 24, 2021

!needs_collection_redirect

@mkrizek mkrizek reopened this May 24, 2021
@ansibot ansibot added collection:newswangerd.c1 support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 24, 2021
@ansibot ansibot added the has_pr This issue has an associated PR. label May 12, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Jun 2, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Jul 12, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Jul 20, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Jul 28, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 1, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 4, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 9, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 10, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 11, 2022
mkrizek added a commit to mkrizek/ansible that referenced this issue Aug 15, 2022
mkrizek added a commit that referenced this issue Aug 16, 2022
@ansible ansible locked and limited conversation to collaborators Aug 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 affects_2.14 bug This issue/PR relates to a bug. collection:newswangerd.c1 collection Related to Ansible Collections work has_pr This issue has an associated PR. python3 support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
5 participants