-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[2/4][aggregator] implement fetch key #422
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
base: joy/handle-aggregator-in-ks
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| /// Middleware to add aggregator's own version and git version to headers. | ||
| async fn add_response_headers(mut response: Response) -> Response { |
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.
we already have this function somewhere, no?
| Err(e) => { | ||
| let msg = format!("Aggregating responses failed: {e}"); | ||
| error!("{}", msg); | ||
| Err(ErrorResponse::from(InternalError::Failure(msg))) |
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.
it's implicit, no?
| let response = client | ||
| .post(format!("{}/v1/fetch_key", member.url)) | ||
| .header("Client-Sdk-Type", "aggregator") | ||
| .header("Client-Sdk-Version", package_version!()) |
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.
let's make all these constants and use them here and in the key server instead of duplicating (possible errors)
| .unwrap_or("unknown") | ||
| ); | ||
|
|
||
| validate_key_server_version(version).map_err(ErrorResponse::from)?; |
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.
from is not called here implicitly?
| )) | ||
| .and_then(|v| { | ||
| v.to_str() | ||
| .map_err(|_| InternalError::InvalidKeyServerVersion) |
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.
why not use Failure instead of InvalidKeyServerVersion? this error means that the aggregator cannot perform its job, and the actual reason here does not matter (e.g., is there a difference to the caller between a server that didn't reply vs a server that replied with old version?)
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.
we should log and monitor those errors differently ofc
6bf4a3e to
998ed57
Compare
6e54905 to
7e57d6e
Compare
f8cd8f9 to
9fb649c
Compare
7e57d6e to
23900f6
Compare
Description
impl fetch key for aggregator: calls to member urls to get keys for all ids. if one of the keys from server is invalid, discard all keys from this server. if threshold is reached (count only all keys are returned from the server), aggregator and return to client.
version handling: aggregator maintains min_sdk_version. checks client request against it. then calls to each key server with aggregator version. key server checks against min_aggregator_version and return its key server version. aggregator checks key-server-version is at least aggregator's own version. then return client key-server-version set to aggregator version
error handling: aggregator record majority error relayed from key servers and return, everything else as internal error
Test plan
tests here focus on version and error. e2e test for aggregation is in the next pr.