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

support rabbitmq 3.8.x in version check #66855

Merged
merged 2 commits into from Feb 15, 2020
Merged

Conversation

bitchkat
Copy link
Contributor

SUMMARY

Support rabbitmq 3.8.x in the rabbitmq_policy version check.
Fixes #66731

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

rabbitmq_policy

ADDITIONAL INFORMATION

rabbitmqctl status drastically changed its status in 3.8.x. thus breaking the parsing that rabbitmq_policy does to parse the version. This change just adds a second parse for the 3.8 format if it doesn't find the 3.7 version. It may make sense to flip the order of the checks on the assumption that 3.8 will become the prevalent version.

- name: set up topic mirroring
  rabbitmq_policy:
    name: HA Mode
    pattern: mqtt-.*
  args:
    tags:
      ha-mode: nodes
      ha-params: "{{ rabbitmq_mirrors }}"
  run_once: true

when the policy already exists results in the following failure due to version check failing
ansible-playbook -i rabbitmq configure-rabbitmq-debug.yml -b --private-key master.key -u master -vvv
[...]
The full traceback is:
Traceback (most recent call last):
  File "/home/clouddevmaster/.ansible/tmp/ansible-tmp-1579794428.83-164555296831546/AnsiballZ_rabbitmq_policy.py", line 102, in <module>
    _ansiballz_main()
  File "/home/clouddevmaster/.ansible/tmp/ansible-tmp-1579794428.83-164555296831546/AnsiballZ_rabbitmq_policy.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/clouddevmaster/.ansible/tmp/ansible-tmp-1579794428.83-164555296831546/AnsiballZ_rabbitmq_policy.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.messaging.rabbitmq.rabbitmq_policy', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python2.7/runpy.py", line 188, in run_module
    fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_rabbitmq_policy_payload_OEqAxO/ansible_rabbitmq_policy_payload.zip/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py", line 241, in <module>
  File "/tmp/ansible_rabbitmq_policy_payload_OEqAxO/ansible_rabbitmq_policy_payload.zip/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py", line 230, in main
  File "/tmp/ansible_rabbitmq_policy_payload_OEqAxO/ansible_rabbitmq_policy_payload.zip/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py", line 154, in has_modifications
  File "/tmp/ansible_rabbitmq_policy_payload_OEqAxO/ansible_rabbitmq_policy_payload.zip/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py", line 154, in <genexpr>
  File "/tmp/ansible_rabbitmq_policy_payload_OEqAxO/ansible_rabbitmq_policy_payload.zip/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py", line 191, in _policy_check
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

After the change is applied, the rabbitmq_policy task succeeds as expected because it takes the correct branch in _list_polices

@ansibot
Copy link
Contributor

ansibot commented Jan 28, 2020

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. messaging Messaging category module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. rabbitmq RabbitMQ community support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. labels Jan 28, 2020
@zwindler
Copy link
Contributor

This PR has 2 very small pep8/pylint errors

3:30 ERROR: Found 2 pep8 issue(s) which need to be resolved:
03:30 ERROR: lib/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py:127:1: W293: blank line contains whitespace (100%)
03:30 ERROR: lib/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py:132:1: W293: blank line contains whitespace (100%)

Can you fix it?

@bitchkat
Copy link
Contributor Author

This PR has 2 very small pep8/pylint errors

3:30 ERROR: Found 2 pep8 issue(s) which need to be resolved:
03:30 ERROR: lib/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py:127:1: W293: blank line contains whitespace (100%)
03:30 ERROR: lib/ansible/modules/messaging/rabbitmq/rabbitmq_policy.py:132:1: W293: blank line contains whitespace (100%)

Can you fix it?

Done.

@zwindler
Copy link
Contributor

shipit

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 8, 2020
@gundalow gundalow merged commit 6b017db into ansible:devel Feb 15, 2020
@gundalow
Copy link
Contributor

@bitchkat @zwindler
Thank you
If you'd like to see this fixed in the next Ansible 2.9 release please raise a backport PR https://docs.ansible.com/ansible/latest/community/development_process.html#making-your-pr-merge-worthy

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Feb 17, 2020
noonedeadpunk pushed a commit to noonedeadpunk/ansible that referenced this pull request Mar 10, 2020
* support rabbitmq 3.8.x in version check

* Removed extraneous white space

(cherry picked from commit 6b017db)
@ansible ansible locked and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. messaging Messaging category module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. rabbitmq RabbitMQ community stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in rabbitmq_policy (ansible 2.9.4+) with RabbitMQ 3.8.0
5 participants