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

v2 async events are not triggered #14681

Closed
AlanCoding opened this issue Feb 26, 2016 · 24 comments
Closed

v2 async events are not triggered #14681

AlanCoding opened this issue Feb 26, 2016 · 24 comments
Assignees
Labels
affects_2.0 This issue/PR affects Ansible v2.0 affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. foreman Foreman community has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. verified This issue has been verified/reproduced by maintainer

Comments

@AlanCoding
Copy link
Member

AlanCoding commented Feb 26, 2016

Issue Type:
  • Bug Report
Ansible Version:
# ansible --version
ansible 2.0.0.2
Ansible Configuration:

We have a file with python callback functions, specified in ansible.cfg. The destination callback file contains code like the following:

class CallbackModule(object):
   ...
    def v2_runner_on_async_poll(self, result):
        sys.stderr.write('debug statement')
Component Name

ansible/lib/ansible/plugins/callback/__init__.py

Environment:

I am using Ansible on CentOS 7. The machines I'm managing with the playbook are Ubuntu14.04 and CentOS 7.

Summary:

The callback works correctly with Ansible 1.9.x. Ansible 2.0.0.x async polling still works, but it doesn't call any async-specific callback method, instead defaulting to calling v2_on_any on each poll.

Steps To Reproduce:

Run a playbook with an async command using an ansible-playbook command on a similar managed machine with a callback file setup containing v2_runner_on_async_poll.

Example playbook:

- hosts: all
  tasks:
    - name: 'Poll Example'
      async: 6
      poll: 1
      command: /bin/sleep 5
Expected Results:

I expect the debug statement to be printed a handful of times, once for each poll. In Ansible 1.9.2, with everything else otherwise the same, runner_on_async_poll is called several times. We would expect Ansible 2.0.0.2 to fallback to that function or use the v2_ counterpart.

In the current source for Ansible, I don't see any indication that send_callback is ever called with an async callback method as the method_name.

Actual Results:

In my test case outlined above, debug statement is never printed. Using Ansible 2.0.0.2, none of the async methods are called (including the _failed, _ok, and _poll varieties), and it defaults to calling v2_on_any.

EDIT DETAIL: I mistakenly wrote on_ok, but it was really on_any which was the fallback. Sorry about that.

@bcoca bcoca added this to the stable-2.0 milestone Feb 26, 2016
@bcoca
Copy link
Member

bcoca commented Feb 26, 2016

cc @jimi-c looked into it, probably just needs either an update in strat/init.py to check for async task results or in the executors to deal with the polling.

@AlanCoding
Copy link
Member Author

Continuing to look into the issue, v2_runner_on_ok gets triggered if I include that method. Note that before adding that, runner_on_ok was not triggered.

This suggest another potential issue because on_any was also not triggered. If I understand the intent of task_queue_manager.py, the on_any method should have been called any time that v2_on_any was looked for - just like the runner_on_ok method.

Writers of callback functions can still include the v2_ names and get along fine, but for compatibility this detail might be relevant.

EDIT: never mind, I was wrong about the runner_on_ok behavior. The statement about on_any may still apply, but needs more testing.

@reidblomquist
Copy link

+1 saw this same issue on 2.0.1.0

@bcoca bcoca modified the milestone: stable-2.0 Sep 6, 2016
@ansibot ansibot added the affects_2.0 This issue/PR affects Ansible v2.0 label Sep 8, 2016
@rhcarvalho
Copy link
Contributor

I'm writing a callback plugin, and while determining what methods I need to implement/overwrite, I came across the same observation that the async callback methods are never called.

While v2_on_any seems to work, it seems hard to call an action on any result, as one needs to enumerate all of the possible methods:

  • v2_runner_on_failed
  • v2_runner_on_ok
  • v2_runner_on_skipped
  • v2_runner_on_unreachable
  • v2_runner_on_no_hosts
  • v2_runner_on_async_poll (?)
  • v2_runner_on_async_ok
  • v2_runner_on_async_failed
  • v2_runner_on_file_diff (?)
  • did I miss any?

And unfortunately some of them seem to never be called.

@jimi-c jimi-c added affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 labels Dec 21, 2016
@ansibot

This comment has been minimized.

@ansibot ansibot added needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Apr 11, 2017
@AlanCoding
Copy link
Member Author

I think this may be resolved, although I can't say that the modules I've looked at would have picked up every possible method.

@ansibot ansibot removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Apr 11, 2017
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot
Copy link
Contributor

ansibot commented Nov 18, 2017

cc @akatch
click here for bot help

@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Nov 18, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@ansibot
Copy link
Contributor

ansibot commented Apr 10, 2018

cc @rrey
click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Apr 18, 2018

@ansibot
Copy link
Contributor

ansibot commented Nov 10, 2018

@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2019

@ansibot ansibot added the macos macOS community label Jan 25, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 2, 2019

@dagwieers
Copy link
Contributor

dagwieers commented Feb 2, 2019

-label macos

@dagwieers
Copy link
Contributor

bot_status

@ansibot
Copy link
Contributor

ansibot commented Feb 25, 2019

@ansibot
Copy link
Contributor

ansibot commented Feb 25, 2019

Components

lib/ansible/plugins/callback/init.py
support: core
maintainers:

lib/ansible/plugins/callback/actionable.py
support: community
maintainers:

lib/ansible/plugins/callback/cgroup_memory_recap.py
support: community
maintainers:

lib/ansible/plugins/callback/cgroup_perf_recap.py
support: community
maintainers:

lib/ansible/plugins/callback/context_demo.py
support: community
maintainers:

lib/ansible/plugins/callback/counter_enabled.py
support: community
maintainers:

lib/ansible/plugins/callback/debug.py
support: core
maintainers:

lib/ansible/plugins/callback/default.py
support: core
maintainers:

lib/ansible/plugins/callback/dense.py
support: community
maintainers:

lib/ansible/plugins/callback/foreman.py
support: community
maintainers:

lib/ansible/plugins/callback/full_skip.py
support: community
maintainers:

lib/ansible/plugins/callback/grafana_annotations.py
support: community
maintainers: rrey

lib/ansible/plugins/callback/hipchat.py
support: community
maintainers:

lib/ansible/plugins/callback/jabber.py
support: community
maintainers:

lib/ansible/plugins/callback/json.py
support: community
maintainers:

lib/ansible/plugins/callback/junit.py
support: core
maintainers:

lib/ansible/plugins/callback/log_plays.py
support: community
maintainers:

lib/ansible/plugins/callback/logdna.py
support: community
maintainers:

lib/ansible/plugins/callback/logentries.py
support: community
maintainers:

lib/ansible/plugins/callback/logstash.py
support: community
maintainers:

lib/ansible/plugins/callback/mail.py
support: community
maintainers:

lib/ansible/plugins/callback/minimal.py
support: core
maintainers:

lib/ansible/plugins/callback/nrdp.py
support: community
maintainers:

lib/ansible/plugins/callback/null.py
support: community
maintainers:

lib/ansible/plugins/callback/oneline.py
support: core
maintainers:

lib/ansible/plugins/callback/osx_say.py
support: community
maintainers: akasurde dagwieers kyleabenson

lib/ansible/plugins/callback/profile_roles.py
support: core
maintainers:

lib/ansible/plugins/callback/profile_tasks.py
support: core
maintainers:

lib/ansible/plugins/callback/selective.py
support: community
maintainers:

lib/ansible/plugins/callback/skippy.py
support: community
maintainers:

lib/ansible/plugins/callback/slack.py
support: community
maintainers:

lib/ansible/plugins/callback/splunk.py
support: community
maintainers:

lib/ansible/plugins/callback/stderr.py
support: community
maintainers: ysn2233

lib/ansible/plugins/callback/sumologic.py
support: community
maintainers: ryancurrah

lib/ansible/plugins/callback/syslog_json.py
support: community
maintainers:

lib/ansible/plugins/callback/timer.py
support: community
maintainers:

lib/ansible/plugins/callback/tree.py
support: core
maintainers:

lib/ansible/plugins/callback/unixy.py
support: community
maintainers: akatch

lib/ansible/plugins/callback/yaml.py
support: community
maintainers:

test/integration/targets/environment/aliases
support: community
maintainers:

Metadata

waiting_on: maintainer
needs_info: False

click here for bot help

@dagwieers
Copy link
Contributor

!component -lib/ansible/plugins/callback/osx_say.py
!component -lib/ansible/plugins/callback/grafana_annotations.py
!component -lib/ansible/plugins/callback/unixy.py
!component -lib/ansible/plugins/callback/stderr.py
!component -lib/ansible/plugins/callback/sumologic.py

@dagwieers dagwieers removed the macos macOS community label Feb 25, 2019
@ansibot
Copy link
Contributor

ansibot commented Jun 1, 2019

@ansibot
Copy link
Contributor

ansibot commented Jul 11, 2019

@ansibot ansibot added the foreman Foreman community label Jul 11, 2019
@ekohl
Copy link
Contributor

ekohl commented Jul 11, 2019

This isn't really foreman specific
!component -lib/ansible/plugins/callback/foreman.py

@sivel sivel added verified This issue has been verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation labels Aug 9, 2019
@sivel
Copy link
Member

sivel commented Aug 9, 2019

if self._task.async_val > 0:
if self._task.poll > 0 and not result.get('skipped') and not result.get('failed'):
result = self._poll_async_result(result=result, templar=templar, task_vars=vars_copy)
# FIXME callback 'v2_runner_on_async_poll' here

@geerlingguy
Copy link
Contributor

geerlingguy commented Aug 21, 2019

I opened #61015 which is related, when you run background tasks with polling using ad-hoc commands you get no output after the 1.9.x releases (starting with 2.0.0.0). So a command like:

ansible all -b -P 10 -B 3600 -m shell -a "while true; do echo test; sleep 5; done"

Gives no output in Ansible 2.0.0.0+

Whereas in 1.9.x it would give:

192.168.60.5 | success >> {
    "ansible_job_id": "363390903939.6230", 
    "changed": false, 
    "finished": 0, 
    "results_file": "/root/.ansible_async/363390903939.6230", 
    "started": 1
}

<job 363390903939.6230> polling on 192.168.60.5, 3590s remaining

Every 10 seconds (outside the context of a playbook).

This was discovered when working through an issue in my book with async ad-hoc task examples: geerlingguy/ansible-for-devops#91

@geerlingguy
Copy link
Contributor

-label foreman
+label affects_2.8

@ansibot ansibot added the needs_triage Needs a first human triage before being processed. label May 17, 2020
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label May 18, 2020
@sivel sivel self-assigned this Aug 13, 2020
@ansibot ansibot added the has_pr This issue has an associated PR. label Aug 13, 2020
@sivel
Copy link
Member

sivel commented Aug 18, 2020

Closing per #70501

@sivel sivel closed this as completed Aug 18, 2020
@ansible ansible locked and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.0 This issue/PR affects Ansible v2.0 affects_2.1 This issue/PR affects Ansible v2.1 affects_2.2 This issue/PR affects Ansible v2.2 affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. foreman Foreman community has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

No branches or pull requests