-
Notifications
You must be signed in to change notification settings - Fork 28
🐛 Inject API base url by active product 🗃️ ⚠️ #7641
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
🐛 Inject API base url by active product 🗃️ ⚠️ #7641
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7641 +/- ##
==========================================
- Coverage 87.72% 87.32% -0.41%
==========================================
Files 1788 1695 -93
Lines 68979 65891 -3088
Branches 1134 958 -176
==========================================
- Hits 60511 57537 -2974
+ Misses 8156 8085 -71
+ Partials 312 269 -43
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR injects the API base URL for a product by actively retrieving and processing the base URL from configuration and the database. The key changes include:
- Introducing a new error (ProductBaseUrlNotFoundError) to handle missing base URLs.
- Adding a helper function (_make_api_server_base_url) and an async service (get_product_api_base_url) to parse and ensure the API URL is correctly prefixed.
- Extending the repository, model, RPC interface, and database migration to support the new base_url field.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
services/web/server/src/simcore_service_webserver/products/errors.py | Added new error class for missing product base URL |
services/web/server/src/simcore_service_webserver/products/_service.py | Added helper for processing base URL and an async RPC method for retrieving the API base URL |
services/web/server/src/simcore_service_webserver/products/_repository.py | Introduced a new repository method for retrieving the base URL from the database |
services/web/server/src/simcore_service_webserver/products/_models.py | Updated the Product model to include a new base_url field and updated JSON schema defaults accordingly |
services/web/server/src/simcore_service_webserver/products/_controller/rpc.py | Added an RPC endpoint for retrieving the product API base URL |
services/director-v2/src/simcore_service_director_v2/modules/osparc_variables/substitutions.py | Replaced static URL settings with dynamic lookup via the new API base URL RPC |
packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/webserver/products.py | Created a new RPC interface function to query the product API base URL |
packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py | Updated fake product data to include a base_url field |
packages/postgres-database/src/simcore_postgres_database/models/products.py | Modified the products database model to add a new base_url column |
packages/postgres-database/src/simcore_postgres_database/migration/versions/972981ff823a_add_base_url_column_to_products.py | Added a migration to create the base_url column in the products table |
Comments suppressed due to low confidence (1)
services/web/server/src/simcore_service_webserver/products/_service.py:151
- [nitpick] Consider adding an explicit type annotation for the parameter 'product_name' (e.g. product_name: ProductName) for consistency with the rest of the codebase and improved type clarity.
async def get_product_api_base_url(app: web.Application, *, product_name) -> str:
…ancarloromeo/osparc-simcore into inject-api-base-url-by-active-product
packages/postgres-database/src/simcore_postgres_database/models/products.py
Show resolved
Hide resolved
packages/postgres-database/src/simcore_postgres_database/models/products.py
Outdated
Show resolved
Hide resolved
services/web/server/src/simcore_service_webserver/products/_controller/rpc.py
Show resolved
Hide resolved
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.
Thanks 👍 few comments
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.
Thanks 👍 But I meant the RPC function directly (the one used by other services). Check how other functions in that rpc module are tested osparc-simcore/packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/*
- for example, search for this test: test_rpc_client_mark_project_as_job
.
services/web/server/tests/unit/with_dbs/04/products/test_products_service.py
Show resolved
Hide resolved
|
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.
can we discuss this concept?
Can we not pass that information over?
the webserver can now the scheme and url and hostname from the request that comes in I believe. I'd like to discuss this.
can't these be passed via an argument in one call?
After an offline discussion with @sanderegg, we will try a simpler solution for that. |
Will continue #7619 |
What do these changes do?
This PR injects the API base URL by active product, getting it from its configuration currently stored in the DB.
Before, the
DIRECTOR_V2_PUBLIC_API_BASE_URL
env var was used. This is wrong in case of multiple products served by the same deployment. This caused a wrongOSPARC_API_BASE_URL
injected to the dynamic services.Related issue/s
How to test
Dev-ops
@matusdrobuliak66 Whenever a new product is registered, we should specify the
base_url
in the new column.