community.rabbitmq icon indicating copy to clipboard operation
community.rabbitmq copied to clipboard

Support headers in queue_declare function

Open V4UIDev opened this issue 1 year ago • 5 comments

SUMMARY

Add headers when running the declare queue function.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

RabbitMQ Publish basic_publish

ADDITIONAL INFORMATION

When running the following Ansible task:

    - name: Send reindex message to queue
      community.rabbitmq.rabbitmq_publish:
        url: "amqp://user:[email protected]:5672/%2F"
        queue: "example"
        body: '{ "type": "example" }'
        content_type: "application/json"
        durable: true
        headers: 
          x-max-priority: 15
        delegate_to: localhost

The task would fail adding the message to the queue, due to the headers not being passed in correctly. This pull request addresses that and adds the headers to the message.

Before:

fatal: [192.168.0.1 -> localhost]: FAILED! => changed=false 
  msg: 'Queue declare issue: (406, "PRECONDITION_FAILED - inequivalent arg ''x-max-priority'' for queue ''example'' in vhost ''/'': received none but current is the value ''15'' of type ''signedint''")'

After:

changed: [192.168.0.1-> localhost] => changed=true 
  result:
    content_type: application/json
    msg: Successfully published to queue example
    queue: example

It has also been tested without passing in headers, and the play still functions as before.

V4UIDev avatar Jul 19 '24 13:07 V4UIDev

@Andersson007 @csmart could I get a review of this please?

V4UIDev avatar Aug 27 '24 15:08 V4UIDev

@V4UIDev hello, thanks for the PR!

  • Could you please add a changelog fragment
  • Is it possible to add a simple integration test somewhere under https://github.com/ansible-collections/community.rabbitmq/tree/main/tests/integration/targets ?

Andersson007 avatar Aug 28 '24 08:08 Andersson007

@V4UIDev thanks for the contribution and fixing up this missing component! I think some tests would be great, if you have the time. That will help us to keep on top of this in the future. Thanks!

csmart avatar Aug 28 '24 13:08 csmart

@V4UIDev if you have any questions, please let us know

Andersson007 avatar Sep 03 '24 06:09 Andersson007

@csmart do you think if we can merge the PR w/o the requested integration tests as the author does not respond if i add the fragment in another PR? if you think it's dangerous, we could wait/close the PR, np

Andersson007 avatar Sep 13 '24 12:09 Andersson007

@Andersson007 @csmart Apologies for the delay. Changelog fragment and integration tests added, let me know if they need any further tweaking. Thanks!

V4UIDev avatar Oct 18 '24 09:10 V4UIDev

will be happy to review the PR again once the integration tests are green, thanks!

Andersson007 avatar Oct 23 '24 12:10 Andersson007

will be happy to review the PR again once the integration tests are green, thanks!

Yes, I think there is a rate limit that cloudsmith impose on rabbitmq so will put in a commit next month :)

V4UIDev avatar Oct 24 '24 09:10 V4UIDev

@V4UIDev @csmart are there maybe any other ways to securely install those packages? maybe something has changed on the packages provider site and now there are other URLs that are valid

Andersson007 avatar Oct 24 '24 12:10 Andersson007

closed-reopened to trigger CI, were fixed in https://github.com/ansible-collections/community.rabbitmq/pull/179, fyi

Andersson007 avatar Nov 04 '24 11:11 Andersson007

let's wait a bit and try again, looks strange, maybe GitHub issues..

Andersson007 avatar Nov 04 '24 12:11 Andersson007

it shows now:

fatal: couldn't find remote ref refs/pull/174/merge
##[warning]Git fetch failed with exit code 128, back off 8.918 seconds before retry.
git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin   +refs/heads/*:refs/remotes/origin/* +refs/pull/174/merge:refs/remotes/pull/174/merge
fatal: couldn't find remote ref refs/pull/174/merge
##[warning]Git fetch failed with exit code 128, back off 2.425 seconds before retry.
git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin   +refs/heads/*:refs/remotes/origin/* +refs/pull/174/merge:refs/remotes/pull/174/merge
fatal: couldn't find remote ref refs/pull/174/merge
##[error]Git fetch failed with exit code: 128

@V4UIDev there's something wrong with the PR i now see you use main. please re-create the PR using another branch. Maybe there's a quicker way but for the sake of simplicity you could do:

  1. copy your current local repo somewhere
  2. remove your commits you added in this PR
  3. git remote add upstream https://github.com/ansible-collections/community.rabbitmq/
  4. git pull upstream main
  5. git push origin main
  6. git checkout -b new_branch
  7. copy the files you changed back
  8. submit another PR

Andersson007 avatar Nov 04 '24 12:11 Andersson007