Commit Graph

755 Commits

Author SHA1 Message Date
ZHANG Dapeng 9f644a0861
xds: migrate Bootstrapper data classes to use AutoValue (#8594)
As many new fields will be added to `BootstrapInfo` for xds federation support, refactor `Bootstrapper.java` to use `AutoValue`. All the other files are just mechanical changes due to the refactoring.
2021-10-14 11:55:29 -07:00
yifeizhuang 8e5c18819c
enable rbac by default (#8604) 2021-10-14 11:14:48 -07:00
yifeizhuang a2e2f56565
xds: override bootstrap for xds server (#8575)
added xdsServerBuilder method `overrideBootstrapForTest()`. Fix issue https://github.com/grpc/grpc-java/issues/7819
2021-10-07 16:17:08 -07:00
yifeizhuang e939bf6fb8
rbac: fix status code PERMISSION_DENIED (#8578)
RBAC should fail with PERMISSION_DENIED, fix https://github.com/grpc/grpc-java/issues/8576
2021-10-06 11:02:42 -07:00
Eric Anderson dc4a41498e xds: Register RBAC with pretty-printer
Ideally we should plumb this through Filter, but FilterRegistry will
need to be plumbed to XdsClient and it started becoming non-trivial
compared to the "just add two lines." Expediency is helpful as the XDS
logs are pretty hard to read without the pretty-printing.
2021-09-29 11:28:25 -07:00
Liam Miller-Cushon 9209c1eaf5
Migrate off deprecated mockito method (#8562)
See: https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/ArgumentMatchers.html#anyListOf-java.lang.Class-
2021-09-28 14:18:53 -07:00
Eric Anderson 60475de204 xds: Log about fallback credentials, not supplier
The sslContextProviderSupplier is used by the xds creds themselves when
the control plane has security configured. But the fallback credentials
don't use such a supplier and may not even be using TLS.

Language tweak following #8554.
2021-09-24 14:11:33 -07:00
yifeizhuang 0245a72926
xds: error descriptions improvements(#8554) 2021-09-24 10:36:00 -07:00
yifeizhuang ce311bdfd8
tsan: fix SdsProtocolNegotiatorsTest tsan failure due to thread unsafeness (#8374) 2021-09-23 16:25:38 -07:00
yifeizhuang f33daf0d9e
xds: implement equals hashcode in rbac matcher tree (#8546) 2021-09-21 16:29:07 -07:00
yifeizhuang e4a13778e0
xds: disable rbac by default (#8537) 2021-09-20 13:46:36 -07:00
yifeizhuang 38a554c23a
xds: implement RBAC gRFC misc cases (#8518) 2021-09-16 16:12:52 -07:00
yifeizhuang fcf13952bb
xds, rbac: build per route serverInterceptor for httpConfig (#8524) 2021-09-16 12:35:09 -07:00
Eric Anderson 9d9d8ec66b
xds: Fix test compilation for confused javac
The internal build fails with "reference to assertThat is ambiguous". It
isn't clear why the internal build fails while the external one is okay,
but it is clear that the wildcard T return of readOutbound() is probably
confusing things as javac is considering assertThat(BigDecimal) as a
possible match.

The T return type is a hidden, convenience cast. We force the type
passed to assertThat() to be Object to avoid any ambiguity.
2021-09-16 12:09:15 -07:00
sanjaypujare 49842d2af1
xds: add hashCode and equals back to SslContextProviderSupplier (#8528) 2021-09-15 15:46:22 -07:00
Eric Anderson 43b507160f xds: Drain old server connections on Listener updates
This is necessary to make sure all connections are using the new
configuration.
2021-09-15 10:08:28 -07:00
ZHANG Dapeng 9ff54059d8
xds: populate envoy RetryPolicy with no retryOn to resolver (#8511)
Envoy RetryPolicy with empty retryOn should not be ignored as no retry config when selecting Route config. Therefore, if xDS update for a route contains a RetryPolicy that has no RetryOn value that we support, but the virtual host config does, xds client should choose the Envoy RetryPolicy from the route (even with no RetryOn), rather than choosing the one from virtual host, and try to convert it into grpc RetryPolicy, and end up with no retry.
2021-09-13 08:31:00 -07:00
ZHANG Dapeng 7a65c74283
xds: apply valid resources while NACKing update (#8506)
Implementing [gRFC A46](https://github.com/grpc/proposal/pull/260)
2021-09-11 21:57:47 -07:00
yifeizhuang 7ad7876e99
fix header matcher for null value (#8503) 2021-09-09 12:15:27 -07:00
yifeizhuang a6df9de7bb
xds: add terminal http filter verification, remove lame route filter, add hcm as terminal network filter verification (#8342)
* xds: add terminal filter verification, remove lame route filter

* move last filter check inline

* add server validate terminal filter
2021-09-09 09:55:27 -07:00
yifeizhuang be7aa50441
xds: referenciate server routing config (#8491)
* routing config ref

* atomic ref virtual host list

* Revert "routing config ref"

This reverts commit cbcad5744f.

* test: noop config non-static, better validation
2021-09-08 18:32:26 -07:00
sanjaypujare 22603810b9
xds: use the new cert-provider instances if present (#8494) 2021-09-08 16:06:21 -07:00
sanjaypujare f71eedff40
xds: remove hashCode() and equals() for SslContextProviderSupplier (#8496) 2021-09-08 15:38:26 -07:00
sanjaypujare 5dc6e0ca54
xds: update Envoy protos to a later revision for the new CertificateProvider definitions (#8490) 2021-09-07 14:27:49 -07:00
ZHANG Dapeng 5475cf12bb
xds: fix parsing retryOn values (#8477)
- Envoy ignores white spaces in `retryOn` field
https://github.com/envoyproxy/envoy/blob/v1.19.1/source/common/router/retry_state_impl.cc#L166

  We should do the same.

- Envoy ignores unsupported values https://github.com/envoyproxy/envoy/blob/v1.19.1/source/common/router/config_impl.cc#L89-L90
  and we should do the same.
2021-09-03 12:47:38 -07:00
sanjaypujare 4828698bec
xds: enable PSM security by default (#8478) 2021-09-03 12:38:26 -07:00
ZHANG Dapeng 07747c59a2
xds: Fix WeakReference bug in SharedCallCounterMap (#8466)
Fixes #8397.
#8397 is caused by mistakenly clearing up a map entry right after the entry is recreated after gc. Reproduced in regression test.
2021-09-02 10:25:15 -07:00
sanjaypujare b0b250024f
xds: fix implementation to comply with gRFC for security (#8468) 2021-09-01 10:49:33 -07:00
Sergii Tkachenko 4fa612ae3d
xds: fix java style 2021-08-31 16:45:37 -07:00
yifeizhuang b3ef588520
Fix Java Style (#8458) 2021-08-27 16:35:23 -07:00
yifeizhuang 0f6380b470
xds: server side xDS routing and config application (#8318)
Added routing config discovery for HCM in LdsUpdate in XdsServerWrapper. This can be LDS inline or through RDS. Deal with inflight SslContextProviderSupplier resource handling. Discovered routing config is updated to FilterChainSelectorRef.
Added routing config data field in FilterChainSelector. Filter chain matching would resulting in setting a new attribute key for server routing config. Filter chain matching logics mostly not changed.
Installed ConfigApplyingInterceptor in XdsServerWrapper's delegateBuilder. It fetches server routing config attribute set above. It does routing match and creates server interceptors for the http filters as a result.
2021-08-27 13:30:47 -07:00
Alexander Polcyn f1b699bbf1 Update default XDS server name in C2P resolver 2021-08-26 13:57:19 -07:00
yifeizhuang 48219d902a
fix import warning (#8441) 2021-08-24 16:33:12 -07:00
ZHANG Dapeng 6776fa7c8b
xds: enable ring hash by default (#8442) 2021-08-24 13:09:33 -07:00
ZHANG Dapeng cae2339366
xds: fix RingHash LB null pointer issue (#8438) 2021-08-24 11:27:02 -07:00
Eric Anderson e32e177d5a xds: Avoid logging and throwing errors
The FINE logging was just repeating the exceptions. But really, it is
trivial to avoid exceptions in this case and that is beneficial because
it will avoid an expensive error handling path in something that is
trivial to trigger remotely.

The WARNING may be a bit much if connections don't match the filter
chains often in production, but it seems most likely a misconfiguration
and not something that would be seen often.
2021-08-18 10:06:28 -07:00
ZHANG Dapeng c8db48e2b1
xds: enable xDS retry by default (#8403) 2021-08-12 10:01:32 -07:00
yifeizhuang 1eb1d157a7
xds: allow injecting bootstrapOverride in xdsNameResolverProvider (#8358) 2021-08-11 10:12:20 -07:00
yifeizhuang bb06739cd7
xds: refactor xdsServer wrapper, modify filter chain matching handler for server routing config (#8333)
This is split from #8318, refactoring changes include:
1. FilterChainMatchingHandler
1.1. Previously filter chain match is built-in in XdsServerCredential for xdsServer. (But it does not have to be XdsServerCredential.) The protocol negotiator associated with the XdsServerCredential does the filter chain match computation. Now filter chain match is through a FilterChainMatchingHandler and it always run. As a result, it sets attributes of sslContextProviderSupplier from xds config in protocol negotiation event.
1.2. The previous protocol negotiator associated with the XdsServerCredential is modified to just lookup the config in the attribute set above and decide to use xds config credential or fallback credential.
1.3. Previously credential is a must in XdsBuilder. Now credential becomes optional to allow routing config to be fetched. Xds TCP listener update will always be used to run filter chain match.
Later, we will add routing config in filter chain match and apply http filter configs by installing ConfigApplyingInterceptor.
2. Removed xdsClientWrapperForServerXds, unnecessarily complicated. 
3. Changed event attribute key. Previously filter chain matching happens in the xdsClientWrapperForServerXds, the xds client wrapper is passed to negotiation handler via attributes to allow protocol negotiator to trigger the filter chain matching computation.
Now the attributes becomes an atomic config selector reference that xdsServerWrapper will inject by watching xds resources updates via xds client.
4. Previously there are multiple server states enum in xdsServerWrapper, this is removed because it is unnecessarily complicated. But there are still isServing status to avoid re-start delegate upon listener update.
5. Previously xdsServerWrapper ignores any xds updates once initial started, now we allow dynamic update to happen even if server is up. This is done via updating config selector atomic reference upon listener update.
6. Previously xdsServerWrapper synchronizes on the server object, this is modified to syncContext to be more manageable.
2021-08-09 09:32:36 -07:00
sanjaypujare 0d80c33bce
xds: log error and fail start() if server-listener-resource-name-template not set or not using xds_v3 (#8375) 2021-08-03 13:01:09 -07:00
ZHANG Dapeng 860e97d12a
all: API refactoring in preparation to support retry stats (#8355)
Rebased PR #8343 into the first commit of this PR, then (the 2nd commit) reverted the part for metric recording of retry attempts. The PR as a whole is mechanical refactoring. No behavior change (except that some of the old code path when tracer is created is moved into the new method `streamCreated()`).

The API change is documented in go/grpc-stats-api-change-for-retry-java
2021-07-31 18:33:02 -07:00
Ran 1e858921e1
xds: stop checking if protos are null (#8347) 2021-07-27 13:37:26 -07:00
Sergii Tkachenko bf6db5a77c
xds: sync envoy proto to commit 62ca8bd2b5960ed1c6ce2be97d3120cee719ecab (#8346)
* xds: sync envoy proto to commit 62ca8bd2b5960ed1c6ce2be97d3120cee719ecab
* Suppress warnings for newly deprecated xDS proto fields

Sync to the latest update to pick up https://github.com/envoyproxy/envoy/pull/16942 for forward compatibility with upcoming xDS Rate Limiting features.
Internal Envoy import CL for `62ca8bd2b5960ed1c6ce2be97d3120cee719ecab`: cl/381356375

Suppressed warnings for newly deprecated xDS proto fields:
1) `PerXdsConfig xds_config` to be replaced with `GenericXdsConfig generic_xds_configs`, but this work yet to be planned
2) `HttpConnectionManager`'s `uint32  setXffNumTrustedHops` to be replaced with `TypedExtensionConfig OriginalIpDetectionExtensions`: https://github.com/envoyproxy/envoy/pull/14855
2021-07-26 20:01:42 -04:00
sanjaypujare ced7bc62a3
xds: accept an empty defaultValidationContext to support TD sending an LDSupdate like that (#8345) 2021-07-26 16:58:08 -07:00
ZHANG Dapeng 438f8d9e78
interop-testing: extend XdsTestServer features to support retry test
Extend XdsTestServer features as specified in go/xds-retry-interop-test

See also xds retry interop test case implementation grpc/grpc#26746, grpc/grpc#26791

Previously, rpc-behavior values in the request headers are handled in tow different places, one in interceptor and the other in service implementation via Context. I moved all the rpc-behavior handling in interceptor, Context is not needed any more.
2021-07-26 12:04:58 -07:00
sanjaypujare 38cba5c8dd
xds: add all validations related to security as described in A29 gRFC (#8331) 2021-07-25 22:51:50 -07:00
ZHANG Dapeng f3642422b4
xds: support xds retry policy (#8304) 2021-07-22 12:04:06 -07:00
yifeizhuang 4c1272febd
api: use <scheme,provider> map in nameResoverRegistry (#8323)
An improvement that makes name resolver provider scheme matching more explicit in name resolver registry.
2021-07-21 10:03:55 -07:00
ZHANG Dapeng 9ed444ea2a
xds: add hint of fault injection to injected failures (#8326) 2021-07-14 19:37:25 -07:00
sanjaypujare 629748da61
xds: fix the race condition in SslContextProviderSupplier's updateSslContext and close (#8294) 2021-07-09 10:48:18 -07:00
sanjaypujare 3965315039
xds: implement filter-chain uniqueness check as per grfc A36 (#8295) 2021-07-08 17:22:43 -07:00
Eric Anderson 0cabf5672a compiler: Add GrpcGenerated annotation to generated class
This can be used by annotation processors to avoid processing the
gRPC-generated code. The normal Generated annotation only has SOURCE
retention, so isn't available to annotation processors.

I don't include the service name within the annotation as that assumes
we'll never have need for any other type of generated class. If there's
a request for exposing service name via an annotation in the future, we
can make an RpcService annotation or the like.

Fixes #8158
2021-07-02 22:11:40 -07:00
Eric Anderson f93cfe5add xds: Delete unused ScheduledExecutorService management code
In 02ff64fa2 the SharedResourceHolder.get() was removed and it became
dead code.
2021-06-29 11:33:19 -05:00
Eric Anderson 4814d975a5
xds: Avoid NPE for no filter chain match on server-side 2021-06-29 09:32:37 -07:00
yifeizhuang 3aa871b7de
xds: remove cell based rbac engine (#8277) 2021-06-25 11:20:11 -07:00
sanjaypujare b118a590c8
xds: remove unused SDS code (#8282) 2021-06-23 20:58:22 -07:00
sanjaypujare e4ab8287d0
xds: get rid of legacy SDS and file watching code (#8276) 2021-06-23 11:13:19 -07:00
Chengyuan Zhang 9a8bc10f51
xds: unify client and server handling HttpConnectionManager (#8228)
Enables parsing HttpConnectionManager filter for the server side TCP listener, with the same codepath for handling it on the client side. Major changes include:

- Remodeled LdsUpdate with HttpConnectionManager. Now LdsUpdate is an oneof of HttpConnectionManager (for client side) or Listener (for server side). Each of Listener's FiliterChain contains an HttpConnectionManager (required).
Refactored code for validating and parsing the TCP Listener (for server side), put it into ClientXdsClient. The common part of validating/parsing HttpConnectionManager is reused/shared for client side.
- Included the name of FilterChain in the parsed form. As specified by the API, each FilterChain has a unique name. If the name is not provided by the control plane, a UUID is used. FilterChain names can be used for bookkeeping a set of FilterChain easily (e.g., used as map key).
- Added methods isSupportedOnClients() and isSupportedOnServers() to the Filter interface. Parsing the top-level HttpFilter requires knowing if the HttpFilter implementation is supported for the target usage (client-side or server-side). Note, parsing override HttpFilter configs does not need to know whether the config is used for an HttpFilter that is only supported for the client-side or server side.
- Added a new kind of Route: Route with non-forwarding action. Updated the XdsNameResolver being able to handle Route with non-forwarding action: if such a Route is matched to an RPC, that RPC is failed. Note, it is possible that XdsNameResolver receives xDS updates with all Routes with non-forwarding action. That is, the service config will not reference any cluster. Such case can be handled by cluster_manager LB policy's LB config parser: the parser returns the error to Channel and the Channel will handle it as error service config.
2021-06-18 11:57:36 -07:00
yifeizhuang 84eb285742
xds: add override rbacfilter type url RbacPerProto (#8262) 2021-06-15 16:50:50 -07:00
yifeizhuang c8ba601529
xds: add rbac http filter (#8251) 2021-06-14 12:54:07 -07:00
Eric Anderson 5642e01243
Replace failOnVersionConflict() with custom requireUpperBoundDeps
failOnVersionConflict has never been good for us. It is equivalent to
Maven dependencyConvergence which we discourage our users to use because
it is too tempermental and _creates_ version skew issues over time.
However, we had no real alternative for determining if our deps would be
misinterpeted by Maven.

failOnVersionConflict has been a constant drain and makes it really hard
to do seemingly-trivial upgrades. As evidenced by protobuf/build.gradle
in this change, it also caused _us_ to introduce a version downgrade.

This introduces our own custom requireUpperBoundDeps implementation so
that we can get back to simple dependency upgrades _and_ increase our
confidence in a consistent dependency tree.
2021-06-11 14:01:18 -07:00
Chengyuan Zhang 91948b2606
xds: fix lint (#8248) 2021-06-09 14:57:26 -07:00
Chengyuan Zhang d41094944c
xds: equally weight endpoints within locality if endpoint-level weight unspecified (#8245)
Use a multiplier of 1 for endpoints with endpoint-level load balancing weight unspecified when computing weights for mixing-locality load balancing. Therefore, if a locality has endpoints without endpoint-level load balancing weight, they are weighted equally within the locality.
2021-06-09 12:04:17 -07:00
yifeizhuang b7f3fddc76
xds, rbac: implement rbac engine (#8168) 2021-06-08 14:45:11 -07:00
Chengyuan Zhang fa4b980e07
xds: use defaults for unspecified ring_hash_lb_config values (#8237)
Sets ring_hash LB config to its default values (min_ring_size = 1024 and max_ring_size = 8M) if not given by the control plane. This applies to both parsing RingHashLbConfig from xDS proto and parsing RingHashConfig from the JSON config (currently not used). If the values are given by the control plane, they are validated such that min_ring_size is not less than max_ring_size and do not exceed the 8M limit.
2021-06-07 14:26:50 -07:00
Chengyuan Zhang e51a17574f
xds: append a random number to C2P generated node id (#8239)
Adding a random number to the xDS stream node id helps debugging for distinguishing between different clients.
2021-06-07 11:01:04 -07:00
sanjaypujare 4209c8d8cc
xds: close SslContexrProviderSupplier when the CDS LoadBalancer is shut down to prevent leakage (#8240) 2021-06-07 10:53:57 -07:00
sanjaypujare d8d378454f
xds: remove XdsChannelBuilder and related code that uses old/unsupported interfaces (#8231) 2021-06-03 10:07:05 -07:00
sanjaypujare 087d7bc7d5
xds: move the unsupported filterChainMatch matchers to the ranking stage for correct outcomes (#8219) 2021-06-02 10:10:58 -07:00
sanjaypujare 54b4e93927
xds: replace PriorityHeap with simpler logic that keeps track of top matches (#8225) 2021-06-02 10:09:42 -07:00
Chengyuan Zhang a589c2c68f
xds: fix order of processing resolution errors with original cluster ordering (#8224)
When aggregating the endpoint resolution errors of the list of clusters in ClusterResolverLoadBalancer, clusters should be processed in its original order as received in the LB config. The last cluster's error is used as the overall error status.
2021-06-01 11:22:24 -07:00
Chengyuan Zhang 8129c4e673
xds: import v3 RBAC http filter proto (#8215) 2021-05-27 09:43:56 -07:00
sanjaypujare bfcba82dd5
xds: remove MeshCaCertificateProvider and DynamicReloadingCertificate{Provider (#8214) 2021-05-26 19:35:51 -07:00
sanjaypujare 328071bbce
xds: replace DownstreamTlsContext by SslContextProviderSupplier in the Listener (#8205) 2021-05-26 14:42:47 -07:00
ZHANG Dapeng 6aeeba805f
xds: enhance delay injection error message on DEADLINE_EXCEEDED (#8185)
When an RPC is injected with a delay and then fails with DEADLINE_EXCEEDED (partially) due to the delay, it could confuse users if the error message does not mention the existence of the delay injection, because end users normally are not the same people who configured fault injection policy in control plane.
2021-05-26 14:35:45 -07:00
Chengyuan Zhang bbc5f61abb
xds: use load assignment endpoint address in Cluster as the DNS hostname for LOGICAL_DNS (#8151)
Fixes the source of hostname used for DNS resolution in the cluster_resolver LB policy for LOGICAL_DNS clusters. The change includes:

- parse the single endpoint address from the embedded Cluster resource in CDS responses as the DNS hostname for LOGICAL_DNS cluster and include it in CdsUpdate being notified to the CDS LB policy.
- propagate the DNS hostname to the cluster_resolver LB policy via its LB config (DiscoveryMechanism for LOGICAL_DNS cluster).
- cluster_resolver LB policy takes the DNS hostname from the DiscoveryMechanism for LOGICAL_DNS cluster and use it as the name for DNS resolution.
2021-05-26 12:02:18 -07:00
yifeizhuang 2239dd717c
tsan, xds: fix data race (#8206) 2021-05-25 13:35:09 -07:00
sanjaypujare 5b1c3fa12c
xds: shutDown the scheduledExecutorService when the provider is shutdown (#8198) 2021-05-24 12:45:01 -07:00
sanjaypujare 869b395ec0
xds: ignore unknown SAN name type instead of throwing exception (#8183) 2021-05-19 11:48:11 -07:00
Chengyuan Zhang 86465b3399
xds: cluster_resolver LB policy should wait until all clusters being resolved before propagating endpoints to child LB policy (#8176)
Do not propagate partial endpoint discovery results to the child LB policy of cluster_resolver LB policy. This could avoid premature RPC failures when connections to resolved endpoints fail while there are other unresolved endpoints. Also, endpoints should be attempted in the order of clusters they belong to: endpoints from a lower-priority cluster should not be used before endpoints from a higher-priority cluster are attempted. Most importantly, it should not fallback to use DNS-resolved endpoints before all EDS-resolved endpoints failed.
2021-05-18 13:14:37 -07:00
Chengyuan Zhang 413deb7f0c
xds: implement PriorityChildConfig toString() (#8173) 2021-05-12 16:01:40 -07:00
Chengyuan Zhang 2335eb5b63
xds: eliminate test verification for nondeterministic behaviors (#8172)
When the ring_hash LB policy enters TRANSIENT_FAILURE, it tries to connect one of the IDLE subchannels. Which subchannel to be connected to is non-deterministic, it just choose the first one from the subchannels map.

The existing test creates 4 subchannels, brings down 2 of them to let ring_hash LB policy enter TRANSIENT_FAILURE. But which one fo the remaining two subchannels to be kicked off connection is nondeterministic. This introduces trouble for verifying the behavior. This change simplifies the test, to only create 3 subchannels so that there is only one single subchannel remaining in IDLE after bringing the other two down. We are able to easily verify the behavior of ring_hash LB policy requesting connection for that one subchannel.
2021-05-12 14:17:21 -07:00
sanjaypujare e59604b7ce
xds: add null reference checks in SslContextProviderSupplier (#8169) 2021-05-12 10:27:44 -07:00
Eric Anderson e08b9db208
Use @DoNotCall for static methods in Builders that throw
Since static methods are pseudo-inherited by Builder implementations but
are trivially accidentally used, we re-define static methods in each
builder to make them behave more like the caller would expect. However,
not all the methods actually work; some just throw because the caller
was certainly not getting what they would expect.

Annotating with `@DoNotCall` can expose the problems at compile time
instead of runtime. While `@Deprecated` would also be an option, it is a
bit harder to figure out the ramifications and whether we want to go
that route.

This change was suggested by a lint tool for XdsServerBuilder and it
seems appropriate so I applied it to the other similar cases I could
find.
2021-05-12 10:12:52 -07:00
Chengyuan Zhang f4fe466fb0
xds: lazily and only parse headers with matchers matching the key (#8163)
In normal cases, we only have a few header matchers but the number of headers can be completely up to the application. Indexing headers eagerly parses all headers, even for those with no matcher matching the key. We should only parse header values for those with key matching the header matcher (aka, only call Metadata.get() with key that has some matcher looking for).
2021-05-11 14:20:02 -07:00
Chengyuan Zhang dbc5786c30
xds: ring_hash self recover from TRANSIENT_FAILURE by attempting to connect one subchannel (#8144)
Kicks off connection for one of IDLE subchannels (if exist) when the ring_hash LB policy is reporting TRANSIENT_FAILURE to its upstream.

While the ring_hash policy is reporting TRANSIENT_FAILURE, it will not be getting any pick requests from the priority policy. However, because the ring_hash policy does not attempt to reconnect to subchannels unless it is getting pick requests, it will need special handling to ensure that it will eventually recover from TRANSIENT_FAILURE state once the problem is resolved. Specifically, it will make sure that it is attempting to connect (after applicable backoff period) to at least one subchannel at any given time.
2021-05-11 01:58:57 -07:00
sanjaypujare 0c2d8edc4c
xds: refactor TlsContextManager related code to remove dependency on Bootstrapper (#8150) 2021-05-10 13:13:26 -07:00
Chengyuan Zhang 7b09056aa4
xds: use a standalone Context for xDS control plane RPCs (#8153)
Control plane RPCs are independent of application RPCs, they can stand for completely different lifetime. So the context for making application RPCs should not be propagated to control plane RPCs. This change makes control plane RPCs use the ROOT Context.
2021-05-07 18:00:47 -07:00
sanjaypujare c9e327d42f
xds: extend SslContextProviderSupplier to DowmstreamTlsContext for server side (#8146) 2021-05-04 22:19:15 -07:00
yifeizhuang 27b1641653
xds: import envoy (#8145) 2021-05-04 16:20:44 -07:00
Chengyuan Zhang fcaf9a9583
xds: ignore balancing state update from downstream after LB shutdown (#8134)
LoadBalancers should not propagate balancing state updates after itself being shutdown.

For LB policies that maintain a group of child LB policies with each having its independent lifetime, balancing state update propagations from each child LB policy can go out of the lifetime of its parent easily, especially for cases that balancing state update is put to the back of the queue and not propagated up inline.

For LBs that are simple pass-through in the middle of the LB tree structure, it isn't a big issue as its lifecycle would be the same as its child. Transitively, It would behave correctly as long as its downstream is doing in the right way.

This change is a sanity cleanup for LB policies that maintain multiple child LB policies to preserve the invariant that further balancing state updates from their child policies will not get propagated.
2021-05-04 15:56:56 -07:00
Chengyuan Zhang ee000f0dc1
xds: throw away subchannel references after ring_hash is shutdown (#8140)
Similar to 368c43aec4. 

Clean up subchannels after the RingHashLoadBalancer itself is shutdown to prevent further balancing state updates being propagated to the upstream.

Note this should not be considered as a fix for any problem anybody is noticing. Upstreams of RingHashLoadBalancer should not rely on this, it should still have its own logic for maintaining the lifecycle of downstream LB and ignore invalid upcalls when necessary.
2021-05-04 13:35:37 -07:00
Eric Anderson 16eb5a47ec Stabilize ChannelCredentials
Some of the experimental API annotations were changed to other issues or
became `@Internal` to match their related APIs.

Fixes #7479
2021-05-03 16:22:43 -07:00
Eric Anderson d42f3b8fcb Stabilize ServerCredentials
Some of the experimental API annotations were changed to other issues or
became @Internal to match their related APIs.

Fixes #7621
2021-05-03 16:10:24 -07:00
Chengyuan Zhang 4a339e41ba
xds: fix URI creation used to instantiate DNS name resolver (#8129)
When creating the URI using Channel authority for instantiating a DNS resolver in the cluster_resolver LB policy, a "dns" scheme needs to be manually attached and the Channel authority would be used as the URI path (same as creating Channel with target). Otherwise, the Channel authority will just be used as the scheme and causing name resolver not found.

The change also handles name resolver lookup more defensively. Although it should not happen, if there does have bug causing DNS resolver not being able to be loaded, the cluster_resolver LB policy propagates the INTERNAL error to upstream.
2021-04-30 18:10:40 -07:00
sanjaypujare 02ff64fa21
xds: use singleton XdsClient for server side (#8130) 2021-04-30 09:52:56 -07:00
Chengyuan Zhang 5d99bb07b8
xds: pretty print ClusterConfig message (#8128)
Adds ClusterConfig message descriptor to message printer.
2021-04-29 18:04:03 -07:00
Chengyuan Zhang 42d7fba1b8
xds: implement toString() for pickers to visualize selectable hosts (#8123)
Implements toString() for the wrapping SubchannelPickers so that we are able to see how hosts are selected when sending out RPCs.
2021-04-28 15:16:30 -07:00
yifeizhuang 6755cfed34
tsan, xds: fix XdsClientWrapperForServerSds data races (#8107) 2021-04-26 14:37:11 -07:00
yifeizhuang 8468b5c42f
tsan, xds: fix data races in ServerWrapperForXds (#8114) 2021-04-26 11:58:32 -07:00
Chengyuan Zhang b4fe07d22d
xds: support ring_hash as the endpoint-level LB policy (#7991)
Update LB policy config generation to support ring hash policy as the endpoint-level LB policy.

- Changed the CDS LB policy to accept RING_HASH as the endpoint LB policy from CDS updates. This configuration is directly passed to its child policy (aka, ClusterResolverLoadBalancer) in its config.

- Changed ClusterResolverLoadBalancer to generate different LB configs for its downstream LB policies, depending on the endpoint-level LB policies.
  - If the endpoint-level LB policy is ROUND_ROBIN, the downstream LB policy hierarchy is: PriorityLB -> ClusterImplLB -> WeightedTargetLB -> RoundRobinLB
  - If the endpoin-level LB policy is RNIG_HASH, the downstream LB policy hierarchy is: PriorityLB -> ClusterImplLB -> RingHashLB.
2021-04-16 12:46:55 -07:00
Chengyuan Zhang 9614738a7d
core, grpclb, xds: let leaf LB policies explicitly refresh name resolution when subchannel connection is broken (#8048)
Currently each subchannel implicitly refreshes the name resolution when its state changes to IDLE or TRANSIENT_FAILURE. That is, this feature is built into subchannel's internal implementation. Although it eliminates the burden of having LB implementations refreshing the resolver when connections to backends are broken, this is gives LB policies no chance to disable or override this refresh (e.g., in some complex load balancing hierarchy like xDS, LB policies may embed a resolver inside for resolving backends so the refreshing resolution operation should be hooked to the resolver embedded in the LB policy instead of the one in Channel).

In order to make this transition smoothly, we add a check to SubchannelImpl that checks if the LoadBalancer has explicitly called Helper.refreshNameResolution for broken subchannels created by it. If not, it logs a warning and do the refresh.

A temporary LoadBalancer.Helper API ignoreRefreshNameResolution() is added to avoid false-positive warnings for xDS that intentionally does not want a refresh. Once the migration is done, this should be deleted.
2021-04-16 10:49:06 -07:00
Chengyuan Zhang d4fa0ecc07
xds: reduce the size of ring for testing pick distributions (#8079)
In the ring hash LB policy, building the ring is computationally heavy. Although using a larger ring can make the RPC distribution closer to the actual weights of hosts, it takes long time to finish the test.

Internally, each test class is expected to finish within 1 minute, while each of the test cases for testing pick distribution takes about 30 sec. By reducing the ring size by a factor of 10, the time spent for those test cases reduce to 1-2 seconds. Now we need larger tolerance for the distribution (three hosts with weights 1:10:100):

- With a ring size of 100000, the 10000 RPCs distribution is close to 91 : 866 : 9043
- With a ring size of 10000, the 10000 RPCs distribution is close to 104 : 808 : 9088

Roughly, this is still acceptable.
2021-04-12 14:55:31 -07:00
Chengyuan Zhang 95adf96848
xds: implement ring_hash load balancing policy (#7943)
Implementation for the ring hash LB policy. A LoadBalancer that provides consistent hashing based load balancing to upstream hosts, with the "Ketama" hashing that maps hosts onto a circle (the "ring") by hashing its addresses. Each request is routed to a host by hashing some property of the request and finding the nearest corresponding host clockwise around the ring. Each host is placed on the ring some number of times proportional to its weight. With the ring partitioned appropriately, the addition or removal of one host from a set of N hosts will affect only 1/N requests.
2021-04-08 17:58:45 -07:00
Sergii Tkachenko 6ad3f5d9e4 xds: Fix error prone UnnecessaryJavacSuppressWarnings in a test 2021-04-07 21:59:31 -04:00
sanjaypujare 1a3b02b44b
xds: cache bootstrapInfo in the SslContextProviderFactory to prevent rereading (#8051) 2021-04-05 16:26:29 -07:00
sanjaypujare d9956a53df
xds: Fix validation of HCM filter and Router httpFilter (#8039)
* add 1 more check that works with TD now
2021-04-02 09:48:13 -07:00
sanjaypujare ac6461dfe5
xds: expose bootstrap through XdsClient interface (#8041) 2021-04-01 18:45:46 -07:00
sanjaypujare 4896a0fee8
xds: move the state check logic to delegate and eliminate boilerplate code (#8018) 2021-03-25 16:52:15 -07:00
Sergii Tkachenko 828b03da27 xds: add CsdsService 2021-03-25 16:20:30 -04:00
Sergii Tkachenko b417b70db1 xds: add csds.proto (v3) with dependencies, generated code 2021-03-25 16:20:30 -04:00
Chengyuan Zhang ad2b26436c
xds: update (local) configurations atomically for each LDS/RDS resource update (#8011)
Fixes inconsistent state of XdsNameResolver with most recently received xDS configurations. The full suite of configurations should always be updated whenever receiving new resource updates, including updates that revoke currently in-use resources. Reference counts for currently in-use clusters should also be cleaned up properly. Otherwise, re-receiving (after being revoked) the same resource can be treated as if the configuration never changed.
2021-03-24 17:06:03 -07:00
ZHANG Dapeng ccedd85418
xds: enforce non-null overrideConfigs field for http filters 2021-03-24 17:05:17 -07:00
ZHANG Dapeng 3ccc6792d5
xds: enable circuit breaking, timeout, fault injection by default 2021-03-24 14:50:59 -07:00
sanjaypujare b7afbc30d1
xds: remove syncContext and just use the executorService (#8006) 2021-03-24 12:41:58 -07:00
sanjaypujare c4dec7517f
xds: add/enhance Javadoc comments for XdsServerBuilder. (#8007) 2021-03-23 10:53:21 -07:00
Sergii Tkachenko 8ff0b23c2e
xds: ADS parsing: collect parsing errors on NACK; cache resources on ACK 2021-03-22 20:34:03 -04:00
apolcyn ccd43b64e3
xds: enable v3 API in bootstrap generated by cloud-to-prod resolver (#7995) 2021-03-19 15:26:15 -07:00
apolcyn ab216a1720
interop-testing, xds: Allow using TestServiceClient for making Traffic Director RPCs (#7994)
Updates TestServiceClient to support creating channel without target port (mostly useful for xDS that uses the channel target as the resource name).

Adds an env var for overriding the TD URI used in cloud-to-prod test.
2021-03-19 12:44:52 -07:00
yifeizhuang 043c9d6407
xds: weightedTargetLB collect all failure child pickers to log more error details (#7989) 2021-03-18 17:39:48 -07:00
Chengyuan Zhang f0512db060
xds: delete redundant hash function configuration (#7950)
Initially we were about to support both xx_hash and murmur_hash. But later we decided to support xx_hash only. So for any hashing we are using in xDS, it's going to be xx_hash. Therefore, we do not need to define and carry this configuration around.
2021-03-18 11:48:25 -07:00
sanjaypujare a460f784c6
xds: fix filterChainMatch for multiple matchers, 0-length prefixLength and empty prefixRange list (#7985) 2021-03-18 10:22:35 -07:00
sanjaypujare cd3b0c4412
xds: clean up to remove the cert-instance-override related code (#7986) 2021-03-18 10:22:04 -07:00
Penn (Dapeng) Zhang e8d935e5c9 xds: pretty print http filters 2021-03-18 10:13:36 -07:00
Penn (Dapeng) Zhang 9950d30881 xds: import envoy router.proto 2021-03-18 10:13:36 -07:00
ZHANG Dapeng 3ebb3e1924
xds: HttpFilter support 2021-03-17 16:37:13 -07:00
sanjaypujare 69587c5239
xds: use the correct resource id template as per xDS server gRFC (#7978) 2021-03-17 08:22:59 -07:00
sanjaypujare 224247cf02
xds: implement xDS server validations (#7972) 2021-03-16 15:24:04 -07:00
yifeizhuang 71c4ef730e
xds:fix cdsLoadBalancer2 childLb shutdown (#7971) 2021-03-16 12:37:05 -07:00
sanjaypujare be6192e82a
xds: replace ServerXdsClient with ClientXdsClient (#7969) 2021-03-16 11:23:41 -07:00
ZHANG Dapeng 3f7aa8c592
xds: fix Node.toBuilder() bug 2021-03-12 14:06:00 -08:00
Chengyuan Zhang 8e1c9b6948
xds: change system property for reading bootstrap config (#7961)
Changes from "io.grpc.xds.bootstrapValue" to "io.grpc.xds.bootstrapConfig".
2021-03-12 13:54:58 -08:00
sanjaypujare afe883119d
xds: add server side Listener processing to ClientXdsClient (#7955)
* xds: add server side Listener processing to ClientXdsClient

* address review comments

* minor fixes for review comments
2021-03-11 16:23:50 -08:00
yifeizhuang 528ef63c58
core: Move negotiationLogger from channel attributes to GrpcHttp2ConnectionHandler (#7933) 2021-03-10 16:43:56 -08:00
Sergii Tkachenko c8d3cf23e6
xds: Simplify ClientXdsClientTestBase by reusing test resources 2021-03-08 09:14:22 -08:00
Chengyuan Zhang 4b52639aa1
xds: implement per-RPC hash generation (#7922)
Generates a hash value for each RPC based on the HashPolicies configured for the Route that the RPC is routed to.
2021-03-05 10:51:42 -08:00
Sergii Tkachenko cf99e8a7b2
xds: add helper to unpack compatible com.google.protobuf.Any messages 2021-03-03 14:46:44 -08:00
sanjaypujare 46a136d62b
xds: implement listener deletion/re-add and server serving/not-serving logic (#7919) 2021-03-02 10:47:50 -08:00
Chengyuan Zhang a3ca6321ba
xds: fix typo in handling malformed cluster config (#7930) 2021-03-01 16:58:23 -08:00
ZHANG Dapeng 14432dfe67
xds: import udpa/type/v1/typed_struct.proto 2021-02-26 12:22:04 -08:00
Chengyuan Zhang 7a92de619b
xds: add env var protection for google-c2p resolver (#7918) 2021-02-25 17:55:05 -08:00
Chengyuan Zhang 2bfa0037ad
xds: implement cloud-to-prod resolver (#7900)
Implemented CloudToProdNameResolver, which will be used for DirectPath with URI scheme "google-c2p". The resolver is only a wrapper that delegates name resolution either to DNS or xDS resolver depending on the environment. If it is delegating to the xDS resolver, it will send HTTP requests (to a local HTTP server) to fetch metadata that is used to generate a bootstrap config. The self-generated bootstrap will be used for xDS.
2021-02-23 12:27:47 -08:00
sanjaypujare bfc67bfcf4
xds: remove the env var GRPC_XDS_EXPERIMENTAL_NEW_SERVER_API (#7914) 2021-02-23 11:15:22 -08:00
Chengyuan Zhang 22d1af0c89
xds: implement simple safe and allocation-free xx_hash (#7912)
Implement a simple allocation-free xx_hash utility class without using sun.misc.Unsafe. The hash function mainly targets on xDS use case, which is mostly small strings (endpoint address, headers, etc) and primitive types.

In gRPC's use case, string characters need to be treated as ASCIIs to make the produced hash values match other implementations (Envoy, gRPC-Go, C-core, etc) would produce.

The hashing implementation and tests are borrowed from OpenHFT's XxHash implementation (https://github.com/OpenHFT/Zero-Allocation-Hashing/blob/master/src/main/java/net/openhft/hashing/XxHash.java, see commit 658079a50903c32c54f2ab5c86243244b3ac60ed), which is under Apache 2.0 license. For more details, see https://github.com/OpenHFT/Zero-Allocation-Hashing.

The code is made to be in third_party directory with LISENCE and NOTICE files.
2021-02-22 11:07:25 -08:00
sanjaypujare 6a581f282b
xds: implement the new filterChainMatch algorithm (#7910) 2021-02-19 15:29:27 -08:00
ZHANG Dapeng 132a40a1cf
xds: implement fault injection interceptor in XdsNameResolver 2021-02-18 14:35:45 -08:00
Sergii Tkachenko e5e9c7a714 xds: sync envoy proto to commit ac9a2637336decdcc52c24add5e8fc39edebb962 2021-02-18 16:11:04 -05:00
ZHANG Dapeng 29864f4fad
xds: gate HttpFilter parsing by env flag 2021-02-17 18:55:43 -08:00
yifeizhuang 97b705614b
xds: add proto leakage check at gradle build (#7899) 2021-02-16 16:19:06 -08:00
sanjaypujare 8030c3a11d
xds: Implement XdsServingStatusListener as per the new xDS server gRFC (#7876) 2021-02-12 09:22:26 -08:00