Support key signing and handle dry_run cleaner#184
Support key signing and handle dry_run cleaner#184Marenz merged 2 commits intofrequenz-floss:v0.x.xfrom
Conversation
Marenz
commented
Aug 20, 2025
- Support key signing
- Consider dry_run status in dispatch merging
llucax
left a comment
There was a problem hiding this comment.
Awesome to see the support for parallel dry-run actors! 🎉
Next time maybe split the deprecation of key in favor of auth_key in a separate commit, as it was sometimes confusing to have it mixed with the introduction of signing.
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for key signing and improves dry_run handling in the dispatch system. The changes introduce new authentication parameters and ensure that dispatches with different dry_run statuses are handled separately during merging operations.
- Add support for key signing with new
sign_secretparameter and deprecatekeyin favor ofauth_key - Modify merge strategies to consider
dry_runstatus when grouping dispatches - Update dependency version for frequenz-client-dispatch
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frequenz/dispatch/_dispatcher.py | Add new authentication parameters (auth_key, sign_secret) and deprecate key parameter |
| src/frequenz/dispatch/_merge_strategies.py | Include dry_run status in merge identity functions for both merge strategies |
| tests/test_managing_actor.py | Update test client to support new authentication parameters |
| tests/test_frequenz_dispatch.py | Add test to verify dry_run dispatches are not merged together |
| pyproject.toml | Update frequenz-client-dispatch dependency version |
| RELEASE_NOTES.md | Document new features and deprecation notice |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ) -> None: | ||
| assert server_url | ||
| assert key | ||
| assert key or auth_key |
There was a problem hiding this comment.
The assertion logic doesn't match the validation in the actual Dispatcher class. The Dispatcher raises ValueError when both are provided or neither are provided, but this test only checks that at least one is provided. Consider aligning the test validation with the production code logic.
| assert key or auth_key | |
| # Ensure exactly one of key or auth_key is provided, matching Dispatcher logic | |
| assert (key is not None) != (auth_key is not None) |
ea92532 to
2dd8031
Compare
llucax
left a comment
There was a problem hiding this comment.
Just a couple of nitpick comments.
| if key is not None and auth_key is not None: | ||
| raise ValueError( | ||
| "Both 'key' and 'auth_key' are provided, please use only 'auth_key'." | ||
| ) | ||
|
|
||
| if key is None and auth_key is None: | ||
| raise ValueError( | ||
| "Either 'key' or 'auth_key' must be provided to access the dispatch service." | ||
| ) |
There was a problem hiding this comment.
It just occurred to me, but you could also use overloads to ensure this is called correctly when type-checking:
@overload
def __init__(
self,
*,
microgrid_id: MicrogridId,
server_url: str,
key: str,
auth_key: None = None,
sign_secret: str | None = None,
call_timeout: timedelta = timedelta(seconds=60),
stream_timeout: timedelta = timedelta(minutes=5),
):
@overload
def __init__(
self,
*,
microgrid_id: MicrogridId,
server_url: str,
key: None = None,
auth_key: str,
sign_secret: str | None = None,
call_timeout: timedelta = timedelta(seconds=60),
stream_timeout: timedelta = timedelta(minutes=5),
):But might be overkill for this.
Signed-off-by: Mathias L. Baumann <[email protected]>
Dispatches with different `dry_run` values are now handled by separate actor instances. This change modifies the `MergeByType` and `MergeByTypeTarget` merge strategies to include the `dry_run` status in the identity function. Previously, two dispatches with the same type and target, but different `dry_run` statuses, would be merged into a single actor instance. This could lead to unexpected behavior, as dry-run dispatches are intended for testing and should not affect production actors. With this change, dispatches are only merged if they have the same type, target (for `MergeByTypeTarget`), and `dry_run` status. Signed-off-by: Mathias L. Baumann <[email protected]>