feat(tonic-xds): gRFC A29 data-plane TLS connector wiring#2640
Conversation
gu0keno0
left a comment
There was a problem hiding this comment.
I'll continue to look at the other files.
| #[allow(dead_code)] // Consumed when CertProviderRegistry is wired in (PR2/A29). | ||
| // Consumed by `CertProviderRegistry::from_bootstrap` only under TLS | ||
| // features; parsed regardless so non-TLS builds accept the same JSON. | ||
| #[cfg_attr(not(feature = "_tls-any"), allow(dead_code))] |
There was a problem hiding this comment.
Is this still deadcode after the integration?
| #[derive(Debug, Clone, Deserialize)] | ||
| // In non-TLS builds `cert_provider` is gated out, so nothing reads these | ||
| // fields after serde populates them. | ||
| #[cfg_attr(not(feature = "_tls-any"), allow(dead_code))] |
| /// `tls_certificate_provider_instance` field and the deprecated | ||
| /// `tls_certificate_certificate_provider_instance` for backward compat. |
There was a problem hiding this comment.
what do they contain when both are emitted?
There was a problem hiding this comment.
Oh, does this mean istio just emit the same provider in the two different forms?
| /// so each connection picks up the latest snapshot. Existing endpoint | ||
| /// channels keep their `EndpointChannel` instance (and any in-flight TLS | ||
| /// session) — only freshly-discovered endpoints see the swapped value. | ||
| pub(crate) type ConnectorSwap<S> = Arc<ArcSwap<Arc<dyn Connector<Service = S> + Send + Sync>>>; |
There was a problem hiding this comment.
Currently loadbalancer just take a Connector object, would it be possible to create a wrapper connector that provide atomic method to swap the inner one? Then we can reuse the same wrapper in LoadBalancer.
There was a problem hiding this comment.
Or the other way is like you commented there, make LoadBalancer call loadfull everytime, I just feel a wrapper might be simpler for callers. Yet it's up to you. If you want to do one way versus the other, maybe change it for LoadBalancer as well.
Motivation
Ref: #2444
Closes out gRFC A29 (xDS-Based TLS Security) in
tonic-xds. The cert provider foundation merged in #2593 and #2616 left the connector integration deferred — its pre-reqEndpoint::tls_config_with_verifierlanded in #2612.With that hook available, this PR wires up the per-cluster TLS connector.
Solution
Five commits, each independently reviewable:
file_watcherbackground refresh.Connectoron CDS update. Existing endpoint channels keep their connector; new connections pick up the latest. Invalid CDS updates are logged and the previous-good connector is kept.TlsConnector— for clusters withSome(security), the connector holds the A29 verifier plus an optional identity provider (mTLS).connect()fetches identity per call, assembles aClientTlsConfig, and builds the endpoint.Tests
Sync
refresh_oncetests infile_watcher, synthetic-cert chain tests for SAN matching,build_connectordispatch tests, and a counter-based test asserting identity is fetched perconnect(). Existingchannel.rsintegration tests exercise the cluster-aware discovery path end-to-end on the plaintext.Interop validation
End-to-end mTLS against Istio (Kind +
grpc-agenttemplate + SPIFFE creds)in YutaoMa/tonic-xds-istio-interop@tonic-pr-2640:
Confirmed successful run with logs
request ok request_num=1 … Nshown below. The harness uncovered thetwo parser-interop bugs fixed in
66d77c5a.