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

[WIP] Module except hook #28536

Open
wants to merge 14 commits into
base: devel
Choose a base branch
from
Open

Conversation

alikins
Copy link
Contributor

@alikins alikins commented Aug 22, 2017

WIP of using sys.except_hook for catching otherwise uncaught exceptions in AnsibleModule

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/module_utils/basic.py

ANSIBLE VERSION
ansible 2.4.0 (module_except_hook 2adec83d9c) last updated 2017/08/22 17:54:47 (GMT -400)
  config file = /home/adrian/src/ansible/ansible_epic_fail.cfg
  configured module search path = [u'/home/adrian/ansible-modules']
  ansible python module location = /home/adrian/src/ansible/lib/ansible
  executable location = /home/adrian/src/ansible/bin/ansible
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

ADDITIONAL INFORMATION

@alikins
Copy link
Contributor Author

@alikins alikins commented Aug 22, 2017

(curious how CI goes as well...)

@ansibot ansibot added WIP affects_2.4 c:module_utils/basic c:plugins/action core_review feature_pull_request module needs_triage support:core and removed core_review labels Aug 22, 2017
@bcoca bcoca removed the needs_triage label Aug 23, 2017
@ansibot ansibot added core_review and removed core_review labels Aug 23, 2017
alikins added 14 commits Aug 24, 2017
AnsibleModuleExit and it's subclasses, if raise and caught by the
except hook, display the output.
Previously, the only way to get a task to show an
exception was if the tasks stderr started with the
string 'Traceback'

If a task result includes 'exception', it supercedes
the stderr output. module_stderr will still be populated.

Also, module_stdout, module_stderr, and rc would only
be populated with the task stdout was invalid JSON.
So now those are populated always, and it's up to the
callback to ignore them. That should make callbacks
more useful.
(ie, make rc/module_stdout/exception etc sometimes
in the return data)
kind of mixing levels here, since a plain module error
should never go to stderr but be in the return json.
(and/or results['module_stdout'] /stderr)

tracebacks on module stderr should end up in the actions
results['stderr'] (as well as 'module_stderr' ? debating if
those should be different)

WIP, dont try to sys.exit based on exception_data 'rc'

fix a py3 incompat issue I missed in merge (a jsonify() usage
in the code to parse cmd args are json )

add back traceback on stderr for now

leave parse_returned_data as is in devel, more or less

don't try to pull out extra info on failed
@ansibot ansibot added core_review and removed core_review labels Aug 24, 2017
@ansibot ansibot added module_utils/basic plugins/action plugins/connection/local stale_ci test test_pull_requests labels Sep 1, 2017
@gundalow gundalow added test and removed test labels Oct 17, 2017
@ansibot
Copy link
Contributor

@ansibot ansibot commented Nov 18, 2017

@ansibot ansibot added support:community windows labels Nov 18, 2017
@ansibot ansibot added the needs_rebase label Dec 4, 2017
@ansibot ansibot added feature and removed feature_pull_request labels Mar 2, 2018
@dagwieers dagwieers added test and removed test test_pull_requests labels Jun 22, 2018
@ansibot
Copy link
Contributor

@ansibot ansibot commented Oct 25, 2018

cc @ptux
click here for bot help

@ansibot
Copy link
Contributor

@ansibot ansibot commented Nov 22, 2018

@ansibot ansibot added the packaging label Feb 17, 2019
@dagwieers dagwieers removed the windows label Feb 27, 2019
@ansibot ansibot added the files label Mar 7, 2019
@ansibot ansibot added collection collection:community.general labels Apr 29, 2020
@ansibot ansibot added pre_azp and removed stale_ci labels Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.4 c:module_utils/basic c:plugins/action c:plugins/connection/local collection feature files module_utils/basic module needs_rebase packaging plugins/action plugins/connection/local pre_azp support:community support:core test WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants