ansible-collections / community.rabbitmq

Manage RabbitMQ with Ansible
http://galaxy.ansible.com/community/rabbitmq
Other
30 stars 46 forks source link

Fixing publishing to exchanges #140

Closed Im0 closed 1 year ago

Im0 commented 1 year ago
SUMMARY

Fixes #138

Updating to fix publishing to exchanges. Updating documentation examples. Queue and exchange options are now mutually exclusive.

ISSUE TYPE
COMPONENT NAME

module_utils/rabbitmq.py modules/rabbitmq_publish.py

ADDITIONAL INFORMATION

Notes are in #138 - This PR fixes up some of the logic when posting to an exchange. Previously if an exchange was specified but no queue, the module would also post the message to a random queue.

Im0 commented 1 year ago

Running ansible-test integration --docker at home works 100%. Currently trying to understand why this pipeline is failing.

Currently failing on: rabbitmq_publish : RabbitMQ basic publish test with...

2022-10-20T02:44:53.8610439Z 02:35 The full traceback is:
2022-10-20T02:44:53.8611781Z 02:35   File "/tmp/ansible_rabbitmq_publish_payload_o04npdq8/ansible_rabbitmq_publish_payload.zip/ansible_collections/community/rabbitmq/plugins/module_utils/rabbitmq.py", line 143, in connect_to_rabbitmq
2022-10-20T02:44:53.8613011Z 02:35     self.connection = pika.BlockingConnection(parameters)
2022-10-20T02:44:53.8613699Z 02:35                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-10-20T02:44:53.8614251Z 02:35   File "/usr/local/lib/python3.11/dist-packages/pika/adapters/blocking_connection.py", line 360, in __init__
2022-10-20T02:44:53.8614836Z 02:35     self._impl = self._create_connection(parameters, _impl_class)
2022-10-20T02:44:53.8615295Z 02:35                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2022-10-20T02:44:53.8615900Z 02:35   File "/usr/local/lib/python3.11/dist-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
2022-10-20T02:44:53.8616598Z 02:35     raise self._reap_last_connection_workflow_error(error)
2022-10-20T02:44:53.8617069Z 02:35 fatal: [testhost -> localhost]: FAILED! => {
2022-10-20T02:44:53.8617467Z 02:35     "changed": false,
2022-10-20T02:44:53.8617840Z 02:35     "invocation": {
2022-10-20T02:44:53.8618211Z 02:35         "module_args": {
2022-10-20T02:44:53.8618605Z 02:35             "auto_delete": false,
2022-10-20T02:44:53.8619065Z 02:35             "body": "Hello world from ansible module rabbitmq_publish",
2022-10-20T02:44:53.8619493Z 02:35             "cafile": null,
2022-10-20T02:44:53.8619882Z 02:35             "certfile": null,
2022-10-20T02:44:53.8620282Z 02:35             "content_type": "text/plain",
2022-10-20T02:44:53.8620686Z 02:35             "durable": false,
2022-10-20T02:44:53.8621065Z 02:35             "exchange": null,
2022-10-20T02:44:53.8621459Z 02:35             "exclusive": false,
2022-10-20T02:44:53.8621833Z 02:35             "headers": {},
2022-10-20T02:44:53.8622207Z 02:35             "host": null,
2022-10-20T02:44:53.8622577Z 02:35             "keyfile": null,
2022-10-20T02:44:53.8622962Z 02:35             "password": null,
2022-10-20T02:44:53.8623331Z 02:35             "port": null,
2022-10-20T02:44:53.8623696Z 02:35             "proto": null,
2022-10-20T02:44:53.8624232Z 02:35             "queue": "publish_test",
2022-10-20T02:44:53.8624847Z 02:35             "routing_key": null,
2022-10-20T02:44:53.8625242Z 02:35             "src": null,
2022-10-20T02:44:53.8626204Z 02:35             "url": "amqp://guest:***@localhost:5672/%2F",
2022-10-20T02:44:53.8626798Z 02:35             "username": null,
2022-10-20T02:44:53.8627181Z 02:35             "vhost": null
2022-10-20T02:44:53.8627815Z 02:35         }
2022-10-20T02:44:53.8628154Z 02:35     },
2022-10-20T02:44:53.8628527Z 02:35     "msg": "Connection issue: "
2022-10-20T02:44:53.8628872Z 02:35 }
Im0 commented 1 year ago

Trying to replicate build failure locally. Below worked fine:

ansible-test integration rabbitmq_publish --docker base
ansible-test integration rabbitmq_publish --docker ubuntu2004 --python 3.8

Looks like the failure is in docker devel, which, I assume is the development branch of ansible.

Im0 commented 1 year ago

Docker devel now appears to be failing with the error below. I feel that this issue is unrelated to my changes.

https://dev.azure.com/ansible/community.rabbitmq/_build/results?buildId=57618&view=results

01:34 failed to register layer: ApplyLayer exit status 1 stdout:  stderr: write /usr/bin/zstd: no space left on device
01:34 WARNING: Failed to pull docker image "quay.io/ansible/ubuntu2004-test-container:4.8.0". Waiting a few seconds before trying again.
01:38 ERROR: Host <ansible_test._internal.host_profiles.DockerProfile object at 0x7f9e7f636a90> job failed: Failed to pull docker image "quay.io/ansible/ubuntu2004-test-container:4.8.0".
Im0 commented 1 year ago

Still having trouble replicating the issue in Docker devel Ubuntu 20.04. In a normal container created with ansible-test shell --docker --python 3.9 first of all tried installing ansible devel with pip as this appeared to be what the CI pipeline did?

retry pip3.9 install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check

Running ansible-test: ... PLAY RECAP ***** testhost : ok=56 changed=27 unreachable=0 failed=0 skipped=1 rescued=0 ignored=5

# ansible-test integration rabbitmq_publish --allow-destructive

Tried running ansible-test devel branch within a new container using GIT:

# ansible-test shell --docker --python 3.9
root@f819c30973c0:~/ansible_collections/community/rabbitmq$
    cd /root
   git clone https://github.com/ansible/ansible.git
   mkdir clone
   cd clone
   git clone https://github.com/ansible/ansible.git
   cd ~
   cd ansible_collections/community/rabbitmq/
   pip3.9 install --upgrade jinja2
   python3.9 /clone/ansible/bin/ansible-test integration rabbitmq_publish --allow-destructive

The ansible-test environment from within the container:

root@f819c30973c0:~/ansible_collections/community/rabbitmq$ python3.9 /clone/ansible/bin/ansible-test env
ansible:
  version: 2.15.0.dev0
docker:
  executable: None
git: None
interpreters:
  2.7: /usr/bin/python2.7
  3.5: /usr/bin/python3.5
  3.6: /usr/bin/python3.6
  3.7: /usr/bin/python3.7
  3.8: /usr/bin/python3.8
  3.9: /usr/bin/python3.9
location:
  cwd: /root/ansible_collections/community/rabbitmq
  pwd: /root/ansible_collections/community/rabbitmq
platform:
  datetime: 2022-10-24T03:20:14Z
  platform: Linux-5.4.0-88-generic-x86_64-with-glibc2.27
python:
  executable: /usr/bin/python3.9
  version: 3.9.1

The testing worked...

PLAY RECAP *********************************************************************
testhost                   : ok=56   changed=27   unreachable=0    failed=0    skipped=1    rescued=0    ignored=5

Struggling to replicate the connectivity issues present in the devel ci pipeline results.

Im0 commented 1 year ago

These CI failures are being fixed in #139 and given the other tests passed for this PR and this PR helps #139 I will merge this in.

Im0 commented 1 year ago

Latest CI run has sanity issues corrected in #139 . The only issue I'm unsure about is the devel branch 20.04 issue which raises:

04:42 The full traceback is:
04:42   File "/tmp/ansible_rabbitmq_publish_payload_g0myw77x/ansible_rabbitmq_publish_payload.zip/ansible_collections/community/rabbitmq/plugins/module_utils/rabbitmq.py", line 143, in connect_to_rabbitmq
04:42     self.connection = pika.BlockingConnection(parameters)
04:42                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
04:42   File "/usr/local/lib/python3.11/dist-packages/pika/adapters/blocking_connection.py", line 360, in __init__
04:42     self._impl = self._create_connection(parameters, _impl_class)
04:42                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
04:42   File "/usr/local/lib/python3.11/dist-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
04:42     raise self._reap_last_connection_workflow_error(error)

And struggling to replicate in home environment.