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

async_status does not notice if task timed out #25637

Closed
Antaxify opened this issue Jun 13, 2017 · 7 comments
Closed

async_status does not notice if task timed out #25637

Antaxify opened this issue Jun 13, 2017 · 7 comments
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. c:executor/playbook_executor module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category

Comments

@Antaxify
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

async

ANSIBLE VERSION

ansible 2.3.0.0

CONFIGURATION

default ansible.cfg file

OS / ENVIRONMENT

N/A

SUMMARY

When a task is executed with 'poll: 0' (fire and forget) and the time specified in 'async' expires, the async cache remains and a following 'async_status' task reports that the task is still running, although the process was killed.

STEPS TO REPRODUCE
---

- hosts: localhost
  tasks:
    - command: sleep 100
      async: 10
      poll: 0
      register: myJob

    - command: sleep 20

    - name: wait until playbooks are finished
      async_status:
        jid: "{{ myJob.ansible_job_id }}"
      register: myJob_result

    - debug: var=myJob_result
EXPECTED RESULTS

The async_status task should report that the job is not running (like it would be if the job was cleaned up by 'async_status' with 'mode: cleanup'). 'Failed' should not be 0.

ACTUAL RESULTS
PLAY [localhost] ***********************************************************************************************************************************************************************************************************************************************************************************************************************************************

TASK [command] *************************************************************************************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost] => {"ansible_job_id": "964367425822.17508", "changed": true, "finished": 0, "results_file": "/home/stephan/.ansible_async/964367425822.17508", "started": 1}

TASK [command] *************************************************************************************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost] => {"changed": true, "cmd": ["sleep", "20"], "delta": "0:00:20.005145", "end": "2017-06-13 08:26:51.140481", "rc": 0, "start": "2017-06-13 08:26:31.135336", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

TASK [wait until playbooks are finished] ***********************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {"ansible_job_id": "964367425822.17508", "changed": false, "finished": 0, "started": 1}

TASK [debug] ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "changed": false, 
    "myJob_result": {
        "ansible_job_id": "964367425822.17508", 
        "changed": false, 
        "finished": 0, 
        "started": 1
    }
}

PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=4    changed=2    unreachable=0    failed=0  
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report c:executor/playbook_executor needs_triage Needs a first human triage before being processed. labels Jun 13, 2017
@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Jun 13, 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 21, 2017

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 module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) 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 Nov 21, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) support:community This issue/PR relates to code supported by the Ansible community. and removed needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) 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. labels Apr 10, 2018
@ansibot ansibot added the utilities Utilities category label Feb 17, 2019
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) support:community This issue/PR relates to code supported by the Ansible community. labels Mar 13, 2019
@AlekSi
Copy link

AlekSi commented Aug 6, 2019

I can confirm it is still an issue with Ansible 2.8.2.

@jhg03a
Copy link

jhg03a commented Nov 27, 2019

I also can still confirm it's an issue with 2.9.1 as well:
Sample Playbook:

---
- hosts: localhost
  gather_facts: no
  connection: local

  tasks:
    - name: background task
      shell:
        cmd: "sleep 30"
        executable: "{{ lookup('pipe','which bash') }}"
      register: async_res
      async:  20
      poll: 0

    - name: Wait for the background task to finish
      async_status:
        jid: "{{ async_res.ansible_job_id }}"
      register: async_test_job
      until: async_test_job.finished
      retries: 5
      delay: 5

What I'd love to see is the ability to see either the async job finished attribute also include timeout, or a separate attribute so we can do until: async_test_job.finished or async_test_job.timed_out

@jhg03a
Copy link

jhg03a commented Nov 27, 2019

I believe this issue is duplicated with #32181

@ansibot
Copy link
Contributor

ansibot commented May 17, 2020

Files identified in the description:

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

@s-hertel
Copy link
Contributor

Fixed by #74199

@jhg03a
Copy link

jhg03a commented Apr 30, 2021

For those finding this issue, the solution is now to look for a msg field value of Timeout exceeded instead of a dedicated boolean field.

@ansible ansible locked and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. c:executor/playbook_executor module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. utilities Utilities category
Projects
None yet
Development

No branches or pull requests

6 participants