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

Ansible error handling rescue block does not have any indication that the block's failure is being handled by rescue. #39227

Closed
sekharvajjula opened this issue Apr 24, 2018 · 6 comments
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@sekharvajjula
Copy link
Contributor

sekharvajjula commented Apr 24, 2018

ISSUE TYPE
  • Bug Report
COMPONENT NAME

playbook/block.py

ANSIBLE VERSION
ansible 2.5.1
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

Ansible error handling rescue block does not give any indication in the output log, that the block's failure is being handled in rescue. Rather the output logs show that one task has failed, but still it is continuing the execution with next task. Just by looking at the logs it does not give any information that rescue tasks are under execution unless we add debug task indicating the same (or) by browsing through the playbooks. This make life difficult in debugging playbooks with multiple roles in identify real failure.

If we take the example of retry tasks failures have clear prefix "FAILED - RETRYING: ", if we take the "ignore_errors" case there is a clear print statement "...ignoring" before proceeding to the next task. It would make debugging easy if we have similar sort of indication for block-rescue tasks as well.

STEPS TO REPRODUCE

Run the below playbook with ansible-playbook command.

---
- name: Testing block-rescue
  hosts: localhost
  tasks:
    - block:
        - name: read /tmp/test.data
          slurp:
            src: /tmp/test.data
          register: tmp_rabbit_cookie

      rescue:
        - name: create /tmp/test.data
          copy:
            content: "Testing data"
            dest: /tmp/test.data
EXPECTED RESULTS
ACTUAL RESULTS

[root@controller-1 playbooks]# ansible-playbook test.yaml
[WARNING]: provided hosts list is empty, only localhost is available

PLAY [Testing block-rescue] ************************************************************************************************************************************

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

TASK [read /tmp/test.data] *************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "file not found: /tmp/test.data"}

TASK [create /tmp/test.data] ***********************************************************************************************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************************************************************************
localhost : ok=3 changed=1 unreachable=0 failed=1

[root@controller-1 playbooks]# echo $?
0


@ansibot
Copy link
Contributor

ansibot commented Apr 24, 2018

Files identified in the description:
None

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.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 24, 2018
@ansibot
Copy link
Contributor

ansibot commented Apr 24, 2018

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

@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Apr 24, 2018
@sekharvajjula
Copy link
Contributor Author

Any updates on this ticket?

@sbernhard
Copy link

I agree. Looks like that BLOCK .. RESCUE is not working completely. Had the same issue with the junit callback which marks such BLOCK .. RESCUE as a failed test - which it shouldn't be in my eyes.

@DownRangeDevOps
Copy link

This makes the block: ... rescue: syntax useless when running playbooks from Jenkins. The Jenkins job will still fail because it recognizes that failed tasks is > 0.

@samdoran
Copy link
Contributor

Added in #48418 is the number of rescued tasks in the play summary.

@ansible ansible locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

6 participants