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

🐛 RabbitmqBroker: catch ConnectionError for __str__ #6473

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

mbercx
Copy link
Member

@mbercx mbercx commented Jun 11, 2024

The current implementation of the RabbitmqBroker.__str__() method always prints both the version and the URL of the RabbitMQ server. However, the get_rabbitmq_version() method fails with a ConnectionError in case the RabbitMQ broker is not able to connect to the server.

This issue would bubble up into the verdi status command, since this prints the string representation of the RabbitmqBroker in the message that reports the connection failure. At this point the ConnectionError is no longer caught, and hence the user is exposed to the full traceback.

Here we adapt the RabbitmqBroker.__str__() method to catch the ConnectionError and only return the URL in this case.

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.75%. Comparing base (ef60b66) to head (d3feec8).
Report is 112 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6473      +/-   ##
==========================================
+ Coverage   77.51%   77.75%   +0.25%     
==========================================
  Files         560      561       +1     
  Lines       41444    41771     +327     
==========================================
+ Hits        32120    32476     +356     
+ Misses       9324     9295      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mbercx mbercx added priority/critical-blocking must be resolved before next release labels Jun 12, 2024
src/aiida/brokers/rabbitmq/broker.py Outdated Show resolved Hide resolved
The current implementation of the `RabbitmqBroker.__str__()` method always prints both
the version and the URL of the RabbitMQ server. However, the `get_rabbitmq_version()`
method fails with a `ConnectionError` in case the RabbitMQ broker is not able to connect
to the server.

This issue would bubble up into the `verdi status` command, since this prints the string
representation of the `RabbitmqBroker` in the message that reports the connection
failure. At this point the `ConnectionError` is no longer caught, and hence the user
is exposed to the full traceback.

Here we adapt the `RabbitmqBroker.__str__()` method to catch the `ConnectionError` and
only return the URL in this case.
@mbercx mbercx force-pushed the fix/rabbitmq-str branch from 741fe7c to d3feec8 Compare June 18, 2024 05:16
@mbercx mbercx requested a review from sphuber June 18, 2024 05:16
@mbercx
Copy link
Member Author

mbercx commented Jun 18, 2024

@sphuber this one is ready for a second round of review!

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @mbercx

@sphuber sphuber merged commit cd0f9ac into aiidateam:main Jun 18, 2024
11 checks passed
@mbercx mbercx deleted the fix/rabbitmq-str branch June 18, 2024 13:33
mikibonacci pushed a commit to mikibonacci/aiida-core that referenced this pull request Sep 3, 2024
…6473)

The current implementation of the `RabbitmqBroker.__str__()` method always prints both
the version and the URL of the RabbitMQ server. However, the `get_rabbitmq_version()`
method fails with a `ConnectionError` in case the RabbitMQ broker is not able to connect
to the server.

This issue would bubble up into the `verdi status` command, since this prints the string
representation of the `RabbitmqBroker` in the message that reports the connection
failure. At this point the `ConnectionError` is no longer caught, and hence the user
is exposed to the full traceback.

Here we adapt the `RabbitmqBroker.__str__()` method to catch the `ConnectionError` and
return the URL with the message that the connection failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/critical-blocking must be resolved before next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants