-
Notifications
You must be signed in to change notification settings - Fork 2
[#139] fix(gateway): aggregate configurations for aggregate SOVD entities #150
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
Conversation
Add configuration aggregation for Areas, Components, and Functions by collecting parameters from all child App nodes. Implements pattern used by data/operations endpoints. Parameter IDs use "app_id:param_name" format for disambiguation. Updates endpoint documentation and adds smoke test.
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 fixes configuration handling for aggregate SOVD entities (Areas, Components, Functions) by aggregating parameters from child Apps, aligns the advertised root endpoints with the actual implementation, and adds integration tests (including a smoke test) to validate endpoint coverage.
Changes:
- Introduces configuration aggregation in
ThreadSafeEntityCacheand updatesConfigHandlersto use an entity-agnostic aggregation API (withapp_id:param_nameIDs for disambiguation on aggregate entities). - Expands the root health endpoint’s advertised endpoint list and adds an integration smoke test that calls all advertised GET endpoints to ensure none return 5xx (except intentional 501).
- Updates integration tests for manifest-only discovery mode to expect live configuration data for Apps with running demo nodes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/ros2_medkit_gateway/test/test_integration.test.py |
Adjusts root endpoint expectation to use {data_id} and adds a smoke test that iterates over all advertised GET endpoints from /, performing path parameter substitution and asserting no 5xx responses. |
src/ros2_medkit_gateway/test/test_discovery_manifest.test.py |
Updates the manifest-mode app configuration test to expect a 200 response with items and x-medkit when the bound node is running, reflecting the new runtime configuration retrieval behavior. |
src/ros2_medkit_gateway/src/models/thread_safe_entity_cache.cpp |
Adds NodeConfigInfo-based configuration aggregation methods for Apps, Components, Areas, and Functions, returning the node FQNs and source IDs for parameter queries. |
src/ros2_medkit_gateway/include/ros2_medkit_gateway/models/thread_safe_entity_cache.hpp |
Declares the NodeConfigInfo and AggregatedConfigurations structs and exposes configuration aggregation APIs analogous to existing data/operations aggregation methods. |
src/ros2_medkit_gateway/src/http/handlers/health_handlers.cpp |
Expands the / root endpoint’s endpoints list to comprehensively document data, operations, configurations, and faults endpoints for Areas, Components, Apps, Functions, and global faults, matching the actual routes. |
src/ros2_medkit_gateway/src/http/handlers/config_handlers.cpp |
Refactors configuration handlers to work for any entity ID via get_entity_configurations, aggregate list results across multiple nodes with richer x-medkit metadata, support app_id:param_name identifiers on aggregate entities, and adjust error handling and multi-node reset semantics. |
- Add helper functions to eliminate code duplication: - parse_aggregated_param_id(): parses 'app_id:param_name' format - find_node_for_app(): O(n) lookup replacing duplicated loops - classify_parameter_error(): consistent error classification (404/403/503/400) - Fix error handling in aggregated entity GET without prefix: - Track errors across all nodes instead of silently ignoring failures - Return 404 only when all nodes report 'not found' - Return appropriate error (503/400) when nodes have other failures - Fix get_area_configurations: add missing app IDs to source_ids Addresses code review feedback on inconsistent error semantics.
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
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
src/ros2_medkit_gateway/src/models/thread_safe_entity_cache.cpp
Outdated
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
- Add ParameterErrorCode enum for programmatic error handling - Parallelize list_configurations with std::async for large hierarchies - Fix is_aggregated: true only when multiple nodes exist - Unify entity lookup to cache.find_entity() pattern - Add send_parameter_error() helper and MAX_AGGREGATED_PARAM_ID_LENGTH constant
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
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
| // Query nodes in parallel for better performance with large hierarchies | ||
| // Each async task queries one node and returns its result | ||
| struct NodeQueryResult { | ||
| NodeConfigInfo node_info; | ||
| ParameterResult result; | ||
| }; | ||
|
|
||
| std::vector<std::future<NodeQueryResult>> futures; | ||
| futures.reserve(agg_configs.nodes.size()); | ||
|
|
||
| // Launch parallel queries | ||
| for (const auto & node_info : agg_configs.nodes) { | ||
| futures.push_back(std::async(std::launch::async, [config_mgr, node_info]() { | ||
| NodeQueryResult query_result; | ||
| query_result.node_info = node_info; | ||
| query_result.result = config_mgr->list_parameters(node_info.node_fqn); | ||
| return query_result; | ||
| })); | ||
| } |
Copilot
AI
Jan 27, 2026
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.
handle_list_configurations launches one std::async per node in agg_configs.nodes with std::launch::async and no upper bound (lines 265–283). In large deployments with many child apps per area/function, this can create an unbounded number of threads and put unnecessary pressure on the thread pool compared to the batched, max_parallel approach used in NativeTopicSampler::sample_topics_parallel. Consider introducing a configurable concurrency limit (e.g., process nodes in batches similar to topic sampling) to keep resource usage predictable while still benefiting from parallelism.
Pull Request
Summary
Add configuration aggregation for Areas, Components, and Functions by collecting parameters from all child App nodes. Implements pattern used by data/operations endpoints. Parameter IDs use "app_id:param_name" format for disambiguation. Updates endpoint documentation and adds smoke test.
Issue
Link the related issue (required):
Type
Testing
How was this tested / how should reviewers verify it?
colcon test
Checklist