feat(router): add mtls support to grpc subgraphs#2861
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR adds gRPC-specific client TLS configuration and schema, refactors the TLS builder to accept global and per-subgraph inputs, threads default/per-subgraph gRPC TLS through the graph server into the gRPC connector, updates the gRPC provider and test env for TLS, and adds integration tests for TLS/mTLS scenarios. ChangesgRPC Client TLS Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Router image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
router/pkg/grpcconnector/grpcremote/grpc_remote.go (1)
71-86:⚠️ Potential issue | 🟠 Major | ⚡ Quick winProtect
Startwith the provider mutex.
Startreads/writesg.ccwithout synchronization while other lifecycle methods usemu, which can race under concurrent start/get/stop paths.Proposed fix
func (g *RemoteGRPCProvider) Start(ctx context.Context) error { + g.mu.Lock() + defer g.mu.Unlock() + if g.cc == nil { var transportCreds grpc.DialOption if g.tlsConfig != nil { transportCreds = grpc.WithTransportCredentials(credentials.NewTLS(g.tlsConfig)) } else { transportCreds = grpc.WithTransportCredentials(insecure.NewCredentials()) } clientConn, err := grpc.NewClient(g.endpoint, transportCreds) if err != nil { return fmt.Errorf("failed to create client connection: %w", err) } g.cc = clientConn } return nil }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@router/pkg/grpcconnector/grpcremote/grpc_remote.go` around lines 71 - 86, Start currently reads/writes g.cc without acquiring the provider mutex (mu), causing races with other lifecycle methods; modify RemoteGRPCProvider.Start to acquire the same mutex used by other methods (mu) at the start of the function, check g.cc while holding the lock, initialize g.cc if nil, and release the lock (use defer Unlock immediately after Lock) so Start is synchronized with Stop/GetClient and avoids data races on g.cc.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@router/core/tls.go`:
- Around line 71-73: The warning message logged when
sgCfg.InsecureSkipCaVerification is true is misleading (it says the subgraph
"inherits" from global config); update the logger.Warn call in tls.go (the
branch checking sgCfg.InsecureSkipCaVerification) to state that the subgraph TLS
config has InsecureSkipCaVerification enabled (or that the subgraph is
configured to skip CA verification), removing the word "inherits" and any
implication of global config so the message accurately reflects
sgCfg.InsecureSkipCaVerification and `logger.Warn` usage for the subgraph named
by `name`.
---
Outside diff comments:
In `@router/pkg/grpcconnector/grpcremote/grpc_remote.go`:
- Around line 71-86: Start currently reads/writes g.cc without acquiring the
provider mutex (mu), causing races with other lifecycle methods; modify
RemoteGRPCProvider.Start to acquire the same mutex used by other methods (mu) at
the start of the function, check g.cc while holding the lock, initialize g.cc if
nil, and release the lock (use defer Unlock immediately after Lock) so Start is
synchronized with Stop/GetClient and avoids data races on g.cc.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4e212fb2-4a36-4f65-bab3-b669318a1727
📒 Files selected for processing (14)
router-tests/security/subgraph_grpc_mtls_test.gorouter-tests/testenv/testenv.gorouter/core/graph_server.gorouter/core/router.gorouter/core/router_config.gorouter/core/supervisor_instance.gorouter/core/tls.gorouter/core/tls_test.gorouter/pkg/config/config.gorouter/pkg/config/config.schema.jsonrouter/pkg/config/fixtures/full.yamlrouter/pkg/config/testdata/config_defaults.jsonrouter/pkg/config/testdata/config_full.jsonrouter/pkg/grpcconnector/grpcremote/grpc_remote.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2861 +/- ##
==========================================
+ Coverage 64.47% 66.30% +1.83%
==========================================
Files 319 258 -61
Lines 45359 27105 -18254
Branches 4927 0 -4927
==========================================
- Hits 29245 17972 -11273
+ Misses 16089 7720 -8369
- Partials 25 1413 +1388
🚀 New features to boost your workflow:
|
They are only needed when building a grpc connector and are obsolete after that. Hence they don't need to be a type field.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@router/core/graph_server.go`:
- Around line 357-358: The graph mux reuse logic currently ignores TLS changes
because defaultClientTLS and perSubgraphTLS are only considered on rebuild;
update the reuse decision so muxes/connectors are not reused when those TLS
settings differ by including defaultClientTLS and perSubgraphTLS in the mux
identity/comparison (or cache key) used by the base/feature-flag reuse branches,
and force a rebuild/recreate of the mux/connector whenever those TLS values
change; locate the reuse checks that decide to keep an existing mux (the
base/feature-flag reuse branches) and add equality checks or incorporate the TLS
structs so stale gRPC credentials are not retained.
- Around line 1411-1420: After successfully calling setupConnector
(setupConnector), ensure partially-initialized resources are cleaned up if
subsequent buildGraphMux fails: either keep the connector/local resources
(caches, metric stores, pubsub providers) in local variables and only assign
them to the server state (s.*) after buildGraphMux completes successfully, or
add a short-lived defer immediately after setupConnector that calls
graphServer.Shutdown (or the connector-specific cleanup routine) and cancels
that defer if buildGraphMux succeeds; update the error-return paths after
buildGraphMux to invoke the cleanup so no providers or connectors remain running
on failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 526ede46-37b7-48f3-bd51-4acaaabcd3af
📒 Files selected for processing (2)
router/core/graph_server.gorouter/pkg/grpcconnector/grpcremote/grpc_remote.go
🚧 Files skipped from review as they are similar to previous changes (1)
- router/pkg/grpcconnector/grpcremote/grpc_remote.go
WIP
Summary by CodeRabbit
New Features
Tests
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.