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

Improves output available for troubleshooting ansible #713

Merged
merged 1 commit into from
Nov 7, 2018

Conversation

mhrivnak
Copy link
Member

@mhrivnak mhrivnak commented Nov 6, 2018

  • When a specific task fails, the path and line number are logged.
  • When ansible fails to run any tasks, such as if a syntax error exists in a role, ansible's stdout gets logged.
  • log messages from the reconciler now include the job ID.
  • The message "dropping event that is not a JobEvent" is now logged at debug level instead of info, since it isn't normally helpful.

Example log output when a task fails:

INFO[0001] [playbook task]: Gathering Facts              component=logging_event_handler event_type=playbook_on_task_start gvk="cache.example.com/v1alpha1, Kind=Memcached" name=example-memcached namespace=default
INFO[0002] [playbook task]: dymurray.memcached_operator_role : foo  component=logging_event_handler event_type=playbook_on_task_start gvk="cache.example.com/v1alpha1, Kind=Memcached" name=example-memcached namespace=default
ERRO[0002] failed task: /home/mhrivnak/golang/src/delme/ansible/memcached-operator/roles/dymurray.memcached_operator_role/tasks/main.yml:2  component=reconciler job=3616419306046219210 name=example-memcached namespace=default
ERRO[0002] [failed]: [playbook task] 'foo' failed with task_args - msg=bar  component=logging_event_handler event_type=runner_on_failed gvk="cache.example.com/v1alpha1, Kind=Memcached" name=example-memcached namespace=default
ERRO[0002] error from ansible-runner: exit status 2      component=runner job=3616419306046219210 name=example-memcached namespace=default

Example log output when ansible can't run:

ERRO[0001] error from ansible-runner: exit status 4      component=runner job=5610496959638236402 name=example-memcached namespace=default
ERRO[0001] did not receive playbook_on_stats event       component=reconciler job=5610496959638236402 name=example-memcached namespace=default
ERRO[0001] ansible-playbook 2.6.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/mhrivnak/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mhrivnak/pythons/ansible-events/lib/python2.7/site-packages/ansible
  executable location = /home/mhrivnak/pythons/ansible-events/bin/ansible-playbook
  python version = 2.7.15 (default, Oct 15 2018, 15:24:06) [GCC 8.1.1 20180712 (Red Hat 8.1.1-5)]
Using /etc/ansible/ansible.cfg as config file

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/home/mhrivnak/golang/src/delme/ansible/memcached-operator/roles/dymurray.memcached_operator_role/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: foo
  ^ here

  component=reconciler job=5610496959638236402 name=example-memcached namespace=default

@mhrivnak mhrivnak added the language/ansible Issue is related to an Ansible operator project label Nov 6, 2018
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 6, 2018
* When a specific task fails, the path and line number are logged.
* When ansible fails to run any tasks, such as if a syntax error exists in a role, ansible's stdout gets logged.
* log messages from the reconciler now include the job ID.
* The message "dropping event that is not a JobEvent" is now logged at debug level instead of info, since it isn't normally helpful.
@mhrivnak
Copy link
Member Author

mhrivnak commented Nov 6, 2018

Passing around the ident is likely a precursor to passing around a context object. But we'll tackle that at a later time, since it may require more architectural design change.

Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I don't see any issues. As discussed offline we may want to in the future change this to use a context.

Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well

@mhrivnak mhrivnak merged commit fc9b6b1 into operator-framework:master Nov 7, 2018
@mhrivnak mhrivnak deleted the ansible-error branch November 7, 2018 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/ansible Issue is related to an Ansible operator project size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants