Commit Graph

198 Commits

Author SHA1 Message Date
Jihun Cho 2acca6ea3b
all: fix lint warnings (#6658) 2020-01-30 10:00:39 -08:00
ZHANG Dapeng f04c4921d9
xds: add EdsLoadBalancerProvider to shortcut CDS to EDS flow skipping fallback
The `EdsLoadBalancerProvider` provides `LookasideLb` (Will rename `LookasideLb` to `EdsLoadBalancer` in future, but kept the name now to show better diff) with no-op callbacks for fallback.

- `CdsLoadBalancer` will load `EdsLoadBalancerProvider/LookasideLb` directly skipping fallback.

- The EDS-only flow is unchanged, still loading `XdsLoadBalancerProvider/XdsLoadBalancer2`, keeping current fallback behavior and producing horrible error message when both the primary and fallback policy fail.
2020-01-30 09:49:22 -08:00
Chengyuan Zhang 4ad3acb8f2
xds: print xDS responses nicely with protobuf JsonFormat (#6654)
This change implements a mechanism for printing xDS responses, which contains com.google.protobuf.Any type fields in proto messages, in human-readable format.
2020-01-29 09:58:47 -08:00
ZHANG Dapeng 2eccdb8337
Revert "xds: better error handling to avoid RPC hangup"
This reverts commit a223263134.
2020-01-28 15:36:32 -08:00
ZHANG Dapeng 64e827d996
grpclb,xds: fix parseLoadBalancingConfigPolicy error message format 2020-01-28 13:08:05 -08:00
Chengyuan Zhang 4ad3acc1d4
xds: remove special logic for unsubscribing last CDS resource (#6647) 2020-01-28 10:37:10 -08:00
ZHANG Dapeng 1ed538f253
all: log picker when updating balancing state
Let `ManagedChannelImpl` log picker update when updating balancing state.
2020-01-28 09:55:04 -08:00
ZHANG Dapeng 14e63fea61
xds: use resolvedAddresses.getLoadBalancingPolicyConfig() to get LB config 2020-01-27 15:47:25 -08:00
Chengyuan Zhang e9882ec78d
xds: fix bug of xDS resolver parsing service config incorrectly (#6640)
The ResolutionResult returned by resolver should have its ServiceConfig set with a parsed service config, ins
2020-01-24 16:12:24 -08:00
ZHANG Dapeng 27f12a90f3
xds: refactor LookasideLb for EDS-only usecase and integrate load stats report
- Replace XdsComms2 with XdsClientImpl
- Enable/Disable load report stats with `XdsClient` APIs.

Testing strategy:
- Use real XdsClientImp for EDS-only because the balancer creates the XdsClient by itself. The state of the XdsClientImpl will be the actual state as real.
- Use mock XdsClient for non EDS-only case because the XdsClient in resolved addresses attributes is supposed to be a stateful XdsClient with some pre-existing CDS state, so creating a brand new real XdsClientImp in test can not simulate the same state. In this case only verify interaction with XdsClient APIs.
- Use a `LocalityStoreFactory` to verify interaction with `LocalityStore` APIs. However, this can not cover any interaction with the `Helper` and `LoadStatsStore` inputs of `LocalityStoreFactory.newLocalityStore(Helper, LoadBalancerRegistry, LoadStatsStore)`, so some basic non-exhaustive tests are added to cover the gap.

The testing strategy is imperfect but is a trade-off considering load stats report is very hard to test here and LocalityStore/real balancing behavior is too much to be exhaustively tested in `LookasideLb`.
2020-01-22 17:05:18 -08:00
ZHANG Dapeng a223263134
xds: better error handling to avoid RPC hangup
This change will fail application RPC immediately if XdsClient encounters any error instead of retrying or getting to fallback silently.

There could be optimization if the channel is currently READY while XdsClient stream just closed due to connection error, in which case we could still be using the current available subchannels while retrying, but this requires the LB knows the semantics of error status from the XdsClient. This optimization is not worth the effort for now.
2020-01-22 15:38:38 -08:00
Chengyuan Zhang ee661d45eb
xds: notify all watchers when RPC stream is closed by server (#6629) 2020-01-22 14:27:06 -08:00
Eric Anderson 9cf45e960b xds: Truth Lint fixes 2020-01-22 11:26:00 -08:00
ZHANG Dapeng 1f1ccf2641
xds: enable keepalive for XDS channel
XDS clients will use a keepalive time of 5 minutes.
2020-01-21 17:03:37 -08:00
Chengyuan Zhang 57bc1910e4
xds: incorporate initial fetch timeout as resource not found for xDS protocol (#6570)
Use timeout to conclude resource not exist in xDS protocol.

RDS and EDS protocols are quasi-incremental, each response may not include all the requested resources that present on server side. The way to conclude a requested resource not exist is to use a timeout. In Envoy, this timeout is defined as initial fetch timeout, which is set up at the time client starts subscribing to some resource and disarmed at the time client receives update for that resource. In gRPC's implementation, we set this timeout to be constant 15 seconds, instead of getting its value from ConfigSource proto message.

Initial fetch timeout was initially considered to be not required for LDS and CDS. But gRPC is trying to avoid the temporary inconsistency in the case of racing request/response.

After resource fetch timers are fired, some resources are known to be absent for sure. XdsClient manages its knowledge for resources that are known to be present or absent with caches.
2020-01-17 14:50:20 -08:00
sanjaypujare 1b5d61f18f
xds: mark Sds-Ssl threadfactory daemon to allow apps to exit (#6608) 2020-01-15 11:10:19 -08:00
sanjaypujare 04cf90a9ab
xds: support for updating upstreamTlsContext and SslContextProvider, also release object in SdsProtocolNegotiators (#6599) 2020-01-14 13:59:28 -08:00
sanjaypujare 04924d07b3
xds: implement alpnProtocols based on list from xDS (#6594) 2020-01-10 17:02:06 -08:00
sanjaypujare bee375f205
xds: suppress hostname check but keep trust check in the delegated X509TrustManagerImpl (#6589) 2020-01-09 16:40:43 -08:00
sanjaypujare 6517ac8a61
xds: add support for static and combined validation context and enhanced loggging (#6586) 2020-01-08 16:41:16 -08:00
ZHANG Dapeng d03a746d02
xds: rename experimental_cds policy name to cds_experimental
Incorporating comment https://github.com/grpc/grpc-java/pull/6504#discussion_r363463413. Currently there is no cross-language resolver sending CDS config so there is no impact of the change.
2020-01-08 15:38:53 -08:00
Kun Zhang d227520388 xds: fix lint warnings in test code (#6559) 2019-12-27 11:14:51 -08:00
Jihun Cho 90969b3471
core: make service config error handling optional implementation (#6564) 2019-12-26 15:07:20 -08:00
ZHANG Dapeng 6b04fc18f3
xds: rename XdsClientRef to XdsClientPool 2019-12-18 13:44:35 -08:00
sanjaypujare ead36d152a
xds: use UpstreamTlsContext from attrs (#6533) 2019-12-18 09:40:23 -08:00
Chengyuan Zhang 06d529669a
xds: do not log onError status if RPC stream was shutted down by client (#6541) 2019-12-18 09:01:29 -08:00
Chengyuan Zhang 1d35508000
xds: integrate usage of XdsClient in XdsNameResolver (#6504)
Enables the full flow of xDS protocol in gRPC. An XdsClient instance is created in XdsNameResolver when trying to resolve the address for URI with "xds-experimental" scheme. XdsClient sends LDS/RDS request under the hood to discover service's cluster information for the target URI. The XdsNameResolver then returns a service config containing cluster information to the channel. A reference of the XdsClient instance is also passed to the channel within the ResolutionResult.
2019-12-18 00:46:05 -08:00
ZHANG Dapeng 4733b0b123
xds: fix logging message format bug again 2019-12-17 17:16:33 -08:00
Chengyuan Zhang 52d0c994e2
xds: temporarily allow policy.disable_overprovisioning flag to be not set in EDS responses (#6539) 2019-12-17 16:25:59 -08:00
Chengyuan Zhang 4cebea333a
xds: fix bug of not ignoring responses received after shutdown (#6535)
XdsClientImpl should ignore responses received after shutdown is called.
2019-12-17 16:25:30 -08:00
ZHANG Dapeng 7aaef4f9b6
xds: fix log format bug 2019-12-17 13:37:15 -08:00
Chengyuan Zhang 074cb73702
xds: eliminate unnecessary caching mechanism for RDS (#6510)
A gRPC channel will only ever be interested in a single Listener. So each RDS request will request for at most one resource. By design, server is required to always send back client's newly requested resources, so client will always receive the RDS resource (if exists) after the request was sent. Therefore, client does not need to cache anything.
2019-12-16 17:39:55 -08:00
Chengyuan Zhang d007af18e6
xds: fix bug of concluding retry state without checking retry task status (#6519) 2019-12-16 10:43:24 -08:00
Chengyuan Zhang 5c239437a2
xds: add logging for requests sent by XdsClient (#6516) 2019-12-12 17:27:57 -08:00
ZHANG Dapeng 75b9fee2d1
xds: fix NPE in fallback mode in CDS flow
In CDS flow, fallback is not supported. The fallback_policy in XdsConfig is null, causing NPE. This PR fixes that bug.
2019-12-12 14:35:50 -08:00
Ran 7f2266bcad
xds: make XdsChannelFactory default instance a constant. (#6513) 2019-12-11 16:55:29 -08:00
sanjaypujare 76af2c97ea
xds: set UpstreamTlsContext in Attributes (#6500) 2019-12-10 15:41:04 -08:00
ZHANG Dapeng d5eb61c968
xds: drop support for balancer_name in XdsConfig
The balancer_name field in XdsConfig is deprecated and from now on we ignore it and don't support it.
2019-12-10 13:59:10 -08:00
Chengyuan Zhang f70f73f16c
xds: integrate LRS into XdsClient (#6490)
This change integrates invocation of client side load reporting into XdsClient's implementation:

- Changed LRS client implementation based on LRS design changes. In the new design, first LRS request contains a single ClusterStats message with cluster_name set to the cluster (AKA, CDS cluster) that this LRS client is reporting loads for (no stats data in first request). Then server responses back the name of cluster service (AKA, EDS service) to report loads for.

- Implemented newly proposed LRS client API for adding/removing sources of load stats data.

- Implemented XdsClient APIs for initiating/stopping load reporting.
2019-12-09 23:47:31 -08:00
Chengyuan Zhang 942c1c6b5f
xds: fix bug of verifying xDS requests with ordered resource names
Use matcher that takes care of resource name ordering for comparing requests.
2019-12-09 16:39:26 -08:00
Eric Gribkoff e66ab4e63b
xds: update deprecated charset import (#6502) 2019-12-09 16:23:27 -08:00
Chengyuan Zhang 2de5b4e254
xds: move methods for building test xDS proto messages into a utility class (#6501)
Move helper methods for building xDS protobuf messages into a utility class for code sharing. Tests for gRPC components that use `XdsClient` instance may want to use these methods as well.
2019-12-09 12:59:00 -08:00
ZHANG Dapeng 718f0369cb
core: refactor GracefulSwitchLoadBalancer to switch based on LoadBalancer.Factory
`GracefulSwitchLoadBalancer` was doing switch based on `LoadBalancerProvider.getPolicyName()`. This turned out to be very awkward when I have to synthesize a policy name for the provider, and what I actually care about is the identity of the lb provider not necessarily the policy name.

Now `GracefulSwitchLoadBalancer` is doing switch based on identity of `LoadBalancer.Factory`, which is simpler.
2019-12-09 11:57:16 -08:00
Chengyuan Zhang d3d977d096
xds: extract channel creation out of XdsClient's implementation (#6494)
Introduce a `XdsChannelFactory` for gRPC components that instantiate `XdsClient` instances.
2019-12-08 19:10:12 -08:00
ZHANG Dapeng 30688a1eff
xds: remove xds balancer_name from resolved service config
`XdsNameResolver` will eventually send out a CDS config instead EDS config, but balancer_name should never be sent out from `XdsNameResolver` anyway.

This PR is mainly to unblock current staging test.
2019-12-06 14:36:31 -08:00
sanjaypujare 3145ef0b7c
xds: implementation of file based plugin credential (#6485) 2019-12-06 10:27:51 -08:00
Chengyuan Zhang d168632f82
xds: support multiple xDS servers in bootstrap file (#6493)
Support bootstrap file containing multiple xDS servers, with each has its own server URI and channel credential options. Multiple xDS servers are provided in case of one not reachable. For now, we would only use the first one.

This change also formats JSON strings in bootstrap related tests and add several tests for parsing bootstrap JSON as completeness.

Implementation of XdsClient is changed to take in a list of xDS servers. But still, we only use the first one.
2019-12-05 16:45:28 -08:00
ZHANG Dapeng b739239e8d
xds: apply error handling for FallbackLb.handleResolvedAddresses
Apply the same error handling for `FallbackLb.handleResolvedAddresses()` as `LookasideLb` and `CdsLoadBalancer`.
2019-12-05 13:51:01 -08:00
ZHANG Dapeng 9c2501f146
xds: add CdsLoadBalancer
- Contains `ClusterWatcher` implementation. On cluster update, `ClusterWatcherImpl` spawns an EDS child balancer if not created, then based on the ClusterUpdate data, it sends an edsConfig to the EDS child balancer.
- `CdsLoadBalancer` reads `XdsClientRef` and `CdsConfig` from `resolvedAddresses`. Base on `resolvedAddresses`, it register a `ClusterWatcherImpl` to `XdsClient`.
- For a different cluster resource name in CdsConfig when `handleResolvedAddresses()`, `CdsLoadBalancer` will gracefully switch to the new cluster.
2019-12-05 11:04:54 -08:00
ZHANG Dapeng b833aae615
xds: fix build
Fix build failure of 96da68bab3
https://travis-ci.org/grpc/grpc-java/builds/620854037?utm_source=github_status&utm_medium=notification
2019-12-04 16:00:06 -08:00