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

✨Adding rabbitmq based RPC for IPC between services #3909

Merged
merged 36 commits into from
Mar 9, 2023

Conversation

GitHK
Copy link
Contributor

@GitHK GitHK commented Feb 22, 2023

What do these changes do?

Adds RPC to the backend stack to be used between different services inside the backend.

Use cases:

  • director-v2 to agent: ask to remove pending volumes and waits for the operation to be complete
  • autoscaling -> agent: ask if agent still needs to cleanup before putting the node to drain
  • director-v2 -> dy-sidecar (possibly): replaces http long running tasks polling with RPC polling

Why this implementation and not others?

  • Very good decoupling via RabbitMQ.
  • The aio_pika RPC helper has a very solid implementation. It was just thinly wrapped to deal with one edge case. For more details see tests.

Bonus fixes:

  • ♻️ replacing some dict with {} notation
  • 🐛 upon channel shutdown non longer raise an error because the channel is closed

Thus is required to fix issues

Related issue/s

How to test

Checklist

  • Documentation reflects the changes
  • Unit tests for the changes exist
  • Runs in the swarm

@GitHK GitHK self-assigned this Feb 22, 2023
@GitHK GitHK added changelog:✨new-feature a:services-library issues on packages/service-libs labels Feb 22, 2023
@GitHK GitHK added this to the Mithril milestone Feb 22, 2023
@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #3909 (5a79662) into master (3de921f) will increase coverage by 0.5%.
The diff coverage is 96.2%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3909     +/-   ##
========================================
+ Coverage    85.0%   85.5%   +0.5%     
========================================
  Files         934     781    -153     
  Lines       40180   34537   -5643     
  Branches      839     447    -392     
========================================
- Hits        34175   29552   -4623     
+ Misses       5784    4853    -931     
+ Partials      221     132     -89     
Flag Coverage Δ
integrationtests 66.5% <ø> (+<0.1%) ⬆️
unittests 82.3% <96.2%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/service-library/src/servicelib/rabbitmq.py 93.1% <92.8%> (-1.6%) ⬇️
.../service-library/src/servicelib/rabbitmq_errors.py 100.0% <100.0%> (ø)
...s/service-library/src/servicelib/rabbitmq_utils.py 89.1% <100.0%> (+89.1%) ⬆️
.../server/src/simcore_service_webserver/users_api.py 95.1% <0.0%> (-1.4%) ⬇️
...e/src/simcore_postgres_database/models/services.py
...rvice-integration/src/service_integration/_meta.py
...tion/src/service_integration/osparc_image_specs.py
...gration/src/service_integration/commands/config.py
...e/src/simcore_postgres_database/utils_migration.py
... and 153 more

@GitHK GitHK changed the title ✨Adding an RPC client/server working via rabbitmq ✨Adding an RPC pattern for inter service communication working via rabbitmq Feb 23, 2023
@GitHK GitHK changed the title ✨Adding an RPC pattern for inter service communication working via rabbitmq ✨Adding an RPC for inter service communication working via rabbitmq Feb 23, 2023
@GitHK GitHK changed the title ✨Adding an RPC for inter service communication working via rabbitmq ✨Adding an RPC for inner service communication working via rabbitmq Feb 23, 2023
@GitHK GitHK changed the title ✨Adding an RPC for inner service communication working via rabbitmq ✨Adding RPC (rabbitmq based) for IPC between services Feb 23, 2023
@GitHK GitHK changed the title ✨Adding RPC (rabbitmq based) for IPC between services ✨Adding rabbitmq based RPC for IPC between services Feb 23, 2023
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

Ok here are a few comments:

  • why do we need yet another rabbitmq module ? can't we have an extension on the current one? (i.e. rabbitmq.py and now rabbitmq_robust_rpc.py?)
  • in rabbitmq.py I made use of connection pooling, which is gone from your implementation. Also you had to re-implement all the setup/close mechanism that already exists there.
  • we will likely want to register a whole interface. is there any such mechanism?

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

I added some comments.
I have some questions about this new approach but perhaps we can speak offline.
Thx.

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

Very interesting! thanks for this. Please check my comments.
Did you try using that syntax?

await rpc.proxy.multiply(x=2, y=3) == 6

packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq_errors.py Outdated Show resolved Hide resolved
packages/service-library/src/servicelib/rabbitmq_utils.py Outdated Show resolved Hide resolved
@GitHK GitHK requested a review from sanderegg March 8, 2023 14:53
@codeclimate
Copy link

codeclimate bot commented Mar 9, 2023

Code Climate has analyzed commit 5a79662 and detected 0 issues on this pull request.

View more on Code Climate.

@sonarcloud
Copy link

sonarcloud bot commented Mar 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.1% 0.1% Duplication

@GitHK GitHK merged commit 9977262 into ITISFoundation:master Mar 9, 2023
@GitHK GitHK deleted the pr-osparc-aiopika-solidrpc branch March 9, 2023 12:28
@pcrespov pcrespov mentioned this pull request Mar 23, 2023
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:services-library issues on packages/service-libs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants