-
Notifications
You must be signed in to change notification settings - Fork 203
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
Make message broker server settings configurable #4341
Make message broker server settings configurable #4341
Conversation
@ltalirz and @chrisjsewell after further testing and fine tuning with LLNL, I have updated and cleaned my implementation of making RabbitMQ configuration fully customizable. As you can see, I have three remaining checkboxes with questions that need to be answered and I would like your input.
If I understood correctly, LLNL did not even need them, and what is currently exposed through
|
Re 1. As for Re 2. Re 3. |
Codecov Report
@@ Coverage Diff @@
## develop #4341 +/- ##
===========================================
+ Coverage 79.29% 79.32% +0.03%
===========================================
Files 468 468
Lines 34620 34713 +93
===========================================
+ Hits 27449 27533 +84
- Misses 7171 7180 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
If I understand correctly, the launch of the RabbitMQ server won't be affected by this PR, right? If yes, then What concerns the AiiDA profile setup (I think it is the part affected the most), it is rather a question for you. If the default values will be used for the RabbitMQ connection setup when aiida-core/.docker/opt/configure-aiida.sh Lines 28 to 35 in 0f0dda4
The fact that tests are passing suggests that profile and localhost computer setup went without problems. |
Thanks for looking into this @yakutovicha
I think it should continue to work. However, what might be needed in the future is a way to configure a RabbitMQ server with non-default settings. But then again, thinking about it, one shouldn't use the
Yes, I intentionally provided defaults, such that with |
Thanks for the comment. In that case, I will leave the implementation as is, such that the code does understand these additional parameters, but for now they will have to be added manually in the config and the profile setup CLI just doesn't include the option to set it. |
8c1e9f9
to
1364435
Compare
Yes, the RabbitMQ server remains inside the container. In case non-default settings should be added, we can implement that with some system variables or with configuration files. I think it shouldn't be a problem. |
1364435
to
f457035
Compare
Hey yeh sorry, went down a bit of a rabbit-hole setting this up (pun intended) But tested with a docker-compose network (the proper way to use docker 😉), and all works well: Dockerfile-localFROM phusion/baseimage:0.11
CMD ["/sbin/my_init"]
RUN /sbin/install_clean \
python3 \
python3-dev \
python3-pip \
python3-distutils \
python3-setuptools \
python3-venv \
git \
build-essential \
gcc
RUN pip3 install setuptools wheel
COPY requirements/requirements-py-3.6.txt .
RUN pip3 install -r requirements-py-3.6.txt
COPY . aiida-core
RUN cd aiida-core; pip3 install --no-deps .
ENV TZ Europe/Zurich
# RUN verdi quicksetup -n --config aiida-core/docker-quicksetup.yml
# RUN verdi daemon start
# RUN verdi status docker-quicksetup.ymlprofile: tester
email: myemail@host.com
first_name: chris
last_name: sewell
institution: EPFL
db_engine: postgresql_psycopg2
db_backend: django
db_host: database
db_port: 5432
su_db_username: pguser
su_db_password: password
su_db_name: template1
db_name: aiida_db
db_username: aiida
db_password: password
broker_protocol: amqp
broker_username: guest
broker_password: guest
broker_host: messaging
broker_port: 5672 docker-compose.ymlversion: '3.4'
services:
database:
image: postgres:12.3
container_name: aiida-database
environment:
POSTGRES_USER: pguser
POSTGRES_PASSWORD: password
volumes:
- "aiida-postgres-db:/var/lib/postgresql/data"
messaging:
image: rabbitmq:3.8.3-management
container_name: aiida-rmq
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
volumes:
- "aiida-rmq-data:/var/lib/rabbitmq/"
core:
image: aiidalocal/test1
build:
context: .
dockerfile: ./Dockerfile-local
container_name: aiida-core
depends_on:
- database
- messaging
volumes:
aiida-postgres-db:
name: aiida-postgres-db
aiida-rmq-data:
name: aiida-rmq-data docker-compose up --build -d
docker exec -it aiida-core /bin/bash
docker-compose down -v |
I guess, without adding something like pytest-docker to the test suite, it's difficult to include "proper" testing of this. |
Up till now, the URL to connect to the RabbitMQ server was hardcoded. This means it could only connect to the localhost over the standard port and with the default credentials. Certain users, will require to deploy RabbitMQ on a different machine than the AiiDA instance so the server details should be configurable. Since this will no longer guarantee that the RabbitMQ server is running on localhost, it should also be possible to use SSL by changing the protocol from `amqp` to `amqps` and provide specific user credentials. The `aiida.manage.external.rmq.get_rmq_url` is responsible for formatting the correct URI. The method takes the values that form the scheme, netloc and path as arguments, whereas optional query parameters can be specified through the keyword arguments. The supported arguments are: * protocol * username * password * host * port * virtual_host In addition, the following keyword arguments can be specified: * heartbeat # heartbeat timeout in seconds * cafile # string containing path to ca certificate file * capath # string containing path to ca certificates * cadata # base64 encoded ca certificate data * keyfile # string containing path to key file * certfile # string containing path to certificate file * no_verify_ssl # boolean disables certificates validation should be "0" or "1" Note that the hearbeat, unless explicitly specified, will be set to 600 seconds as a default.
Add property getter and setters to the `Profile` class for the configuration parameters of the message broker, that is currently furnished by RabbitMQ. These parameters determine the URI that needs to be used to connect to the message broker.
Most installations will just need the defaults, which have been set to the default localhost configuration of RabbitMQ, but this now offers the option to administrators to also use a RabbitMQ server that does not run on the same machine as the AiiDA instance itself, or requires actual user authentication.
The migration simply adds the new broker related fields to each profile using the default value, unless the profile already defines it. The migration version is upped, but the last backwards compatible version is kept the same. This is because if the configuration is used with version 3 of the config file, the new keys are simply removed as the config file is parsed. When the code is updated again, the new keys are added again using the defaults.
The `verdi status` command now reports the proper URL that is used to connect to the RabbitMQ message broker. In case the connection fails, the exception message is printed. Passing the `--print-traceback` option will force the command to print the entire stack trace as well.
With the new feature of the RabbitMQ URI being fully customizable, the setup guide needed a new section on how to configure those settings for a given profile through `verdi setup`.
f457035
to
be2f20c
Compare
Thanks a lot for giving this a test @chrisjsewell . In that case, I think it is fine to merge this. Could you please approve? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep had a read down and all looks good to me 👍
Uhm, I might be losing it, but it seems you requested changes instead of approving it 😅 |
nope definitely you 🙄 |
Fixes #1074
Fixes #2685
Replaces #4118
This PR makes the configuration of the message broker (currently RabbitMQ) configurable.
So far I have implemented:
Communicator
URL from broker configuration of current profile instead of hardcodedProfile
class to contain message broker informationverdi quick/setup
to configure the message brokerThe implementation of #4118 was tested by me locally and by LLNL and works for those two use cases.
Things that remain to be done: