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

Problem with handlers notifying another handlers #80880

Closed
1 task done
dutrajulio opened this issue May 24, 2023 · 2 comments · Fixed by #80898
Closed
1 task done

Problem with handlers notifying another handlers #80880

dutrajulio opened this issue May 24, 2023 · 2 comments · Fixed by #80898
Labels
affects_2.15 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer

Comments

@dutrajulio
Copy link

dutrajulio commented May 24, 2023

Summary

The ansible-core 2.15 ignores handlers notified by another handlers when are more than one case.

With the ansible-core 2.14, all cases of handlers notified by another handlers are runned.

Issue Type

Bug Report

Component Name

notify

Ansible Version

ansible [core 2.15.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.3 (main, Apr  5 2023, 15:52:25) [GCC 12.2.1 20230201] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True

Configuration

CONFIG_FILE() = /etc/ansible/ansible.cfg
EDITOR(env: EDITOR) = vim
PAGER(env: PAGER) = less

OS / Environment

Archlinux

ansible 7.6.0-1
ansible-core 2.15.0-1
ansible-lint 6.15.0.r45.g2fca3fe-2
python-ansible-compat 4.0.2-1

Steps to Reproduce

---
- name: Testing
  hosts: localhost
  tasks:
    - name: Trigger handlers
      debug:
        msg: Task 1
      changed_when: true
      notify: Handler 1
  handlers:
    - name: Handler 1
      debug:
        msg: Handler 1
      changed_when: true
      notify: Handler 2
    - name: Handler 2
      debug:
        msg: Handler 2
      changed_when: true
      notify: Handler 3
    - name: Handler 3
      debug:
        msg: Handler 3

Expected Results

All handlers must be notified.

PLAY [Testing] ********************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************
ok: [localhost]

TASK [Trigger handlers] ********************************************************************************************************
changed: [localhost] => {
    "msg": "Task 1"
}

RUNNING HANDLER [Handler 1] ********************************************************************************************************
changed: [localhost] => {
    "msg": "Handler 1"
}

RUNNING HANDLER [Handler 2] ********************************************************************************************************
changed: [localhost] => {
    "msg": "Handler 2"
}

RUNNING HANDLER [Handler 3] ********************************************************************************************************
changed: [localhost] => {
    "msg": "Handler 3"
}

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

Actual Results

Only the two first handlers were notified.

PLAY [Testing] *************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************
ok: [localhost]

TASK [Trigger handlers] *************************************************************************************************
changed: [localhost] => {
    "msg": "Task 1"
}

RUNNING HANDLER [Handler 1] *************************************************************************************************
changed: [localhost] => {
    "msg": "Handler 1"
}

RUNNING HANDLER [Handler 2] *************************************************************************************************
changed: [localhost] => {
    "msg": "Handler 2"
}

PLAY RECAP *************************************************************************************************
localhost                  : ok=4    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented May 24, 2023

Files identified in the description:
None

If these files are incorrect, 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.15 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. labels May 24, 2023
@nitzmahone nitzmahone added needs_verified This issue needs to be verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels May 25, 2023
@bcoca bcoca added verified This issue has been verified/reproduced by maintainer and removed needs_verified This issue needs to be verified/reproduced by maintainer labels May 25, 2023
@bcoca
Copy link
Member

bcoca commented May 25, 2023

I can verify that the 3rd handler does not execute , 2.14.6 works fine.

@ansibot ansibot added the has_pr This issue has an associated PR. label May 26, 2023
jimi-c added a commit to jimi-c/ansible that referenced this issue May 26, 2023
Test case is based on reproducer given in ansible#80880, with some minor
adjustments and assertions.
mkrizek pushed a commit that referenced this issue Jun 14, 2023
This fixes the issue where handlers notifying other handlers are
not properly run because the notification is not registered unless
another flush_handlers occurs. Instead, if the current host state
is iterating handlers we immediately register the handler to be
run so the notification is not lost.

Fixes #80880
mkrizek pushed a commit to mkrizek/ansible that referenced this issue Jun 14, 2023
…e#80898)

This fixes the issue where handlers notifying other handlers are
not properly run because the notification is not registered unless
another flush_handlers occurs. Instead, if the current host state
is iterating handlers we immediately register the handler to be
run so the notification is not lost.

Fixes ansible#80880

(cherry picked from commit 660f172)
@ansible ansible locked and limited conversation to collaborators Jun 21, 2023
nitzmahone pushed a commit that referenced this issue Jul 5, 2023
#81059)

This fixes the issue where handlers notifying other handlers are
not properly run because the notification is not registered unless
another flush_handlers occurs. Instead, if the current host state
is iterating handlers we immediately register the handler to be
run so the notification is not lost.

Fixes #80880

(cherry picked from commit 660f172)

Co-authored-by: James Cammarata <jimi@sngx.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants