Skip to content

SDSTOR-24888: Add inject_auth_metadata helper to GrpcSyncClient - #332

Merged
d2chau merged 4 commits into
eBay:dev/v14.xfrom
d2chau:fix/grpc-sync-client-auth-injection
Sep 8, 2026
Merged

d2chau merged 4 commits into
eBay:dev/v14.xfrom
d2chau:fix/grpc-sync-client-auth-injection

Conversation

@d2chau

@d2chau d2chau commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GrpcSyncClient had no way for subclasses to inject auth metadata into
    sync RPC contexts, even when a GrpcTokenClient was present on the base class
  • Added protected inject_auth_metadata(grpc::ClientContext&) const that reads
    from the inherited m_token_client; no-ops silently when token client is null
  • GrpcAsyncClient already had an equivalent inline auth injection; this closes
    the gap for sync clients

Motivation

OmClient (block_mgr) uses GrpcSyncClient for BM→OM registration and
heartbeat RPCs. OM in cluster 117 has grpc_auth_enable = 1 / auth_mode = 1.
BMs were being rejected by OM because every sync call arrived with no
Authorization header — m_token_client was populated but get_token() was
never called. This single-method addition fixes that without any API break.

dachau and others added 4 commits September 3, 2026 15:35
GrpcSyncClient held m_token_client (inherited from GrpcBaseClient) but
provided no mechanism to inject it into a ClientContext. Subclasses had
to access the protected member directly, duplicating the null-check and
AddMetadata call.

Add a protected inject_auth_metadata() that mirrors the auth injection
already present in GrpcAsyncClient::AsyncStub::prepare_and_send_unary
and GenericAsyncStub::prepare_and_send_unary_generic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add two tests to the existing auth_test fixture:

- sync_client_injects_auth_header: constructs EchoAndPingClient with a
  token client and calls inject_auth_metadata from inside call_echo
  (mirroring OmClient::init_ctx usage); verifies the auth-gated server
  accepts the call.

- sync_client_no_token_is_noop: constructs EchoAndPingClient without a
  token client; verifies inject_auth_metadata is a no-op and the server
  rejects with UNAUTHENTICATED.

Also adds call_echo() to EchoAndPingClient to demonstrate the intended
subclass usage pattern of inject_auth_metadata.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use ASSERT_TRUE with error_message for clearer failure diagnostics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@sbinmalek sbinmalek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Changes looks good. Added a nit comment. Approving the PR

}

TEST_F(AuthEnableTest, sync_client_injects_auth_header) {
EchoAndPingClient sync_client{grpc_server_addr, m_token_client, "", ""};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sync_client correctly constructed? I see different args for both newly added tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's actually exactly what should be tested. For example.

  • Line 341 deliberately omits the token client — the test verifies auth works when the caller injects the header manually (via context.AddMetadata)
  • Line 354 passes m_token_client — the test verifies that inject_auth_metadata in call_echo() handles injection automatically
  • The different signatures reflect the two distinct code paths being tested

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation matches existing async behavior and includes coverage for authenticated and tokenless clients.

Pull request overview

Adds authentication metadata support for synchronous gRPC client subclasses.

Changes:

  • Adds protected inject_auth_metadata.
  • Tests authenticated and tokenless sync calls.
  • Bumps package version to 14.8.2.
File summaries
File Description
include/sisl/grpc/rpc_client.hpp Adds sync auth metadata helper.
src/grpc/tests/unit/auth_test.cpp Tests helper behavior.
conanfile.py Bumps package version.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@d2chau
d2chau merged commit 01a1711 into eBay:dev/v14.x Sep 8, 2026
5 checks passed
@d2chau
d2chau deleted the fix/grpc-sync-client-auth-injection branch September 8, 2026 21:41
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