Skip to content

Conversation

@joyqvq
Copy link
Collaborator

@joyqvq joyqvq commented Jan 8, 2026

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.

}

/// Middleware to add aggregator's own version and git version to headers.
async fn add_response_headers(mut response: Response) -> Response {
Copy link
Collaborator

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)))
Copy link
Collaborator

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!())
Copy link
Collaborator

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)?;
Copy link
Collaborator

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)
Copy link
Collaborator

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?)

Copy link
Collaborator

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

@joyqvq joyqvq force-pushed the joy/move-aggregator branch 2 times, most recently from 6bf4a3e to 998ed57 Compare January 9, 2026 06:37
Base automatically changed from joy/move-aggregator to main January 9, 2026 06:42
@joyqvq joyqvq force-pushed the joy/impl-fetch-key branch 2 times, most recently from 6e54905 to 7e57d6e Compare January 9, 2026 06:47
@joyqvq joyqvq changed the base branch from main to joy/handle-aggregator-in-ks January 9, 2026 06:47
@joyqvq joyqvq force-pushed the joy/handle-aggregator-in-ks branch from f8cd8f9 to 9fb649c Compare January 9, 2026 06:47
@joyqvq joyqvq force-pushed the joy/impl-fetch-key branch from 7e57d6e to 23900f6 Compare January 9, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants