Commit Graph

256 Commits

Author SHA1 Message Date
Menghan Li fe1d8e7181
xds: add temporary logging to LRS (#3490) 2020-04-02 16:55:06 -07:00
Damien Neil 197c621dff
xds: use generated protos from github.com/cncf/udpa/go (#3449)
The upstream repo contains generated Go packages, so there's no need to
generate a separate version here.
2020-03-19 13:15:44 -07:00
Menghan Li 4e487c1661
xds: rename WatchEDS to WatchEndpoints in xds_client (#3447) 2020-03-12 13:42:44 -07:00
Menghan Li ecea6ed1fc
xds: better way to compare and update dropper in EDS (#3434) 2020-03-12 13:41:54 -07:00
Menghan Li 9a1081e29e
xds: handle removing drops (#3433) 2020-03-10 08:50:16 -07:00
Easwar Swaminathan d179e8f5cd
xds: Update an error log message. (#3429) 2020-03-06 08:31:55 -08:00
Menghan Li cfc5fec35a
eds: handle child balancer state asynchronously (#3418)
Before this change, in EDS balancer, child balancer's state update is handled synchronously, which includes priority handling. This would cause a deadlock if the child policy sends a state update inline when handling addresses (e.g. when roundrobin handles empty address list).

This change moves the child balancer state handling into a goroutine, to avoid the problem.
2020-03-04 17:53:51 -08:00
Easwar Swaminathan c0d37940ad
xds: Eliminate calls to reflect.DeepEqual from xds code. (#3414) 2020-03-02 15:49:25 -08:00
Menghan Li 73cf2d2ad6
xds: LRS send hostname in metadata (#3394)
- The first LRS req will send hostname in metadata
   - With key "PROXYLESS_CLIENT_HOSTNAME"
2020-02-28 09:41:56 -08:00
Menghan Li 7f5ddc8aee
xds: improve logging (#3386)
- More logs in xds bootstrap/resolver/cds/eds
  - Bootstrap file content/error
  - Request/response on ADS stream
  - Actions by client/resolver/balancer
  - Content of updates
- Logs prefixed with component name and id
  - `[xds-bootstrap]`
  - `[xds-client <address>]`
  - `[cds-lb <address>]`
  - `[eds-lb <address>]`
2020-02-26 17:50:07 -08:00
Menghan Li c02d9d1775
xds: LRS handle response contains multiple cluster names (#3393)
- The LRS client will find known clusters from the response, and send the loads
   - The LRS client support only one cluster now, will be extended to support multiple
2020-02-26 12:41:45 -08:00
Egon Elbre b1a5073a2c
Fix vet issues (#3396)
* internal/wrr: fix copying lock

* internal/transport: don't use unkeyed fields

* xds/internal/balancer/edsbalancer: don't use unkeyed fields

* profiling/cmd: don't discard cancel
2020-02-25 10:56:49 -08:00
Garrett Gutierrez 132187f04c
Modified tests to use tlogger. (#3343)
* Modified tests to use tlogger.

* Fail on errors, with error expectations.

* Added expects and MixedCapsed grpclb_config tests

* Moved tlogger to grpctest, moved leakcheck tester to grpctest.go

* Added ExpectErrorN()

* Removed redundant leak checks

* Fixed new test

* Made tlogger globals into tlogger methods

* ErrorsLeft -> EndTest

* Removed some redundant lines

* Fixed error in test and empty map in EndTest
2020-02-06 13:03:20 -08:00
Menghan Li e0e0cbc795
xds: move "_experimental" to suffix for all balancers (#3356) 2020-02-03 15:39:32 -08:00
Menghan Li 1f66bc9efb
xds: propogate bootstrap error to grpc.Dial (#3330) 2020-01-23 12:45:58 -08:00
Doug Fawley c35a580b0c
Revert "balancer: move Balancer and Picker to V2; delete legacy… (#3315)
This reverts commit 336cf8d761.
2020-01-13 13:12:55 -08:00
Doug Fawley 336cf8d761
balancer: move Balancer and Picker to V2; delete legacy API (#3301) 2020-01-10 13:44:48 -08:00
Menghan Li 1a3212aaf5
lint: add missing package level comments (#3302) 2020-01-08 11:31:36 -08:00
Menghan Li 287dc3e58a
eds: move edsBalancer to the package `edsbalancer` (#3294)
edsBalancer (the old xds balancer) was in `package balancer`, one level above the eds implementation. It's a thin wrapper of the eds impl (and fallback in the future).

This change moves the thin wrapper to `package edsbalancer`, and also renames some structs.
2020-01-03 11:08:28 -08:00
Menghan Li 1f28521e57
eds: delete fallback related code from the EDS balancer (#3287)
We will add fallback support back when the design is finalized. Before that, fallback makes the code quite hard to follow.
2020-01-02 15:32:38 -08:00
Easwar Swaminathan 8a65b8453b
xds: client test cleanup. (#3284) 2019-12-27 15:00:59 -08:00
Easwar Swaminathan fb8a097792
xds: Improve cdsbalancer_test.go (#3277)
* Use the fakexds.Client object instead of defining a new one
* Add CDS watch functionality to the fakexds.Client object
2019-12-19 13:47:34 -08:00
Easwar Swaminathan 660df6a06b
xds: Improve xds_client_test.go (#3270)
Simplified the tests by only testing what is required and faking out
whatever can be faked out.

Also added a fakexds.Server implementation. Will switch other users of
the existing fakeserver implementation after this PR is merged.
2019-12-18 14:17:35 -08:00
Easwar Swaminathan d01454da4a
xds: Improve balancere/xds_test.go. (#3256) 2019-12-17 11:42:43 -08:00
Easwar Swaminathan d5c817b906
xds: Improve xds_lrs_test.go (#3251) 2019-12-12 12:04:14 -08:00
Menghan Li 505c0d6440
xds: skip callback if xds client reports error (#3240)
Errors will be handled specifically, depending on whether it's a
connection error or other types of errors.

Without this fix, balancer's callback will be called with <nil> update,
causing nil panic later.
2019-12-10 14:03:21 -08:00
Easwar Swaminathan da3b1eb45e
xds: Implementation of the CDS LB policy. (#3224) 2019-12-05 09:52:43 -08:00
Menghan Li 4b2104f1fb
xds: change lrs server name field in xds balancer config to a string pointer (#3210)
LRS is disabled if this field is nil (is unset in json). The xds server
will be used if it's a pointer to an empty string.
2019-11-27 15:11:47 -08:00
Menghan Li 157dc9f3e4
xds: cleanup eds tests to use fakexds server (#3209)
And move LRS test server to fakexds package.
2019-11-26 15:53:20 -08:00
Menghan Li d8e3da36ac
xds: in EDS balancer, use xds_client from attibutes (#3205) 2019-11-25 14:50:28 -08:00
Menghan Li da649b3624
xds: use the shared xds client in eds balancer (#3197)
This PR removes the xds_client implementation from eds balancer, and replaces it with a xds_client wrapper. (The xds_client wrapper has very similar API as the old xds_client implementation, so the change in the eds balancer is minimal).

The eds balancer currently doesn't look for xds_client from attributes, and always creates a new xds_client. The attributes change will be done in a following up change.
2019-11-21 14:10:04 -08:00
Doug Fawley dc49de8acd
balancer: add V2Picker, ClientConn.UpdateState, SubConnState.ConnectionError (#3186)
Also implement V2 versions of base.*, xds, pickfirst, grpclb, and round robin balancers.
2019-11-21 10:27:29 -08:00
Easwar Swaminathan 5d4cc8affe
xds: Implementation of xds_resolver using LDS/RDS (#3183)
xds: Implementation of xds_resolver using LDS/RDS
2019-11-18 17:46:14 -08:00
Menghan Li 71ba135a58
xds: handle EDS in xds client (#3181) 2019-11-18 15:17:21 -08:00
Menghan Li 448c8c628c
xds: replace eds proto message with xdsclient defined struct in eds balancer (#3174)
The xds client will parse the EDS response, and give the parse result to eds balancer, so the balancer doesn't need to deal with proto directly.

Also moved `ClusterLoadAssignmentBuilder` to another pacakge to be shared by tests in different packages.
2019-11-14 10:11:01 -08:00
Easwar Swaminathan 0b3a5cc266
Move bootstrap functionality to a new package. (#3176) 2019-11-13 09:58:04 -08:00
Doug Fawley 2cb07fcd90
resolver: rename Option to Options, leaving type aliases for now (#3175) 2019-11-12 15:23:46 -08:00
Menghan Li 2548a2203d
internal: fix EDS test race in cmp/sort (#3154) 2019-11-06 19:38:51 -08:00
Joe Tsai 2d2f65684c cleanup: fix generic comparisons on protobuf messages (#3153)
Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.
2019-11-06 14:25:07 -08:00
Menghan Li dd568c0669
xds: support priority (#3066)
Each priority maps to a balancer group.

When a priority is in use, its balancer group is started, and it will close the balancer groups with lower priorities. When a priority is down (no connection ready), it will start the next priority balancer group.
2019-11-06 13:09:11 -08:00
Menghan Li b09352fc84
xds: add new fields to XDSConfig (#3100)
Fields are added in: https://github.com/grpc/grpc-proto/pull/64

Other changes:
 - Move XDSConfig from internal to balancer
   - Later we will add a separate config for CDS balancer
 - generate service_config.pb.go and test with json generated from proto message
2019-11-05 09:17:10 -08:00
Menghan Li bbd4b7ae28
eds: skip unhealthy endpoints (#3137)
Unknown and healthy are both considered healthy.

https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/core/health_check.proto#envoy-api-enum-core-healthstatus
2019-11-05 09:03:22 -08:00
Menghan Li 8eafb5b7d5
xds: remove cds from the current xds balancer (#3085)
cds will be done in a separate cds balancer.
2019-10-31 09:44:09 -07:00
Menghan Li ff5f0e93f5
xds: add script to regenerate orca (#3131) 2019-10-30 10:14:39 -07:00
Menghan Li a8f166a036
xds: use generated files from go-control-plane (#3083)
validate needs to be removed, otherwise build fails due to duplicate
proto type registered.
2019-10-29 11:14:20 -07:00
Menghan Li 041ead0785
xds: cache locality (sub-balancer) (#3067)
When a locality is removed from EDS response, it's corresponding
sub-balancer will be removed from balancer group.

With this change, the sub-balancer won't be removed immediately. It will
be kept in a cache (for 15 minutes by default). If the locality is
re-added within the timeout, the sub-balancer in cache will be picked
and re-used.
2019-10-21 15:20:28 -07:00
Menghan Li 0859afa33d
xds: set dial target in request resource_names (#3081) 2019-10-14 09:31:56 -07:00
Ben Wells 691f3b44ba cleanup: fix various misspellings (#3075) 2019-10-04 13:07:47 -07:00
Doug Fawley ed563a02ea
resolver: add State fields to support error handling (#2951) 2019-10-04 12:59:43 -07:00
Easwar Swaminathan 31911ed09e
client: add WithConnectParams to configure connection backoff and timeout (#2960)
* Implement missing pieces for connection backoff.

Spec can be found here:
https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md

Summary of changes:
* Added a new type (marked experimental), ConnectParams, which contains
  the knobs defined in the spec (except for minConnectTimeout).
* Added a new API (marked experimental), WithConnectParams() to return a
  DialOption to dial with the provided parameters.
* Added new fields to the implementation of the exponential backoff in
  internal/backoff which mirror the ones in ConnectParams.
* Marked existing APIs WithBackoffMaxDelay() and WithBackoffConfig() as
  deprecated.
* Added a default exponential backoff implementation, for easy use of
  internal callers.

Added a new backoff package which defines the backoff configuration
options, and is used by both the grpc package and the internal/backoff
package. This allows us to have all backoff related options in a
separate package.
2019-10-03 16:47:13 -07:00
Easwar Swaminathan 492ab452a2
xds: incorporate changes to bootstrap file format. (#3065)
* Incorporate changes to bootstrap file format.

The format of the bootstrap file will be as follows:
{
  "xds_server": {
    "server_uri": <string containing URI of xds server>,
    // List of channel creds; client will stop at the first type it
    // supports.
    "channel_creds": [
      {
        "type": <string containing channel cred type>,
        // The "config" field is optional; it may be missing if the
        // credential type does not require config parameters.
        "config": <JSON object containing config for the type>
      }
    ]
  },
  "node": <JSON form of Node proto>
}

- Also, the bootstrap file will be read everytime a new xDS client is created.
- Change NewConfig() to not return error. Instead it just returns with
  certain fields left unspecified if it encounters errors.
- Do not fail the bootstrap process if we see unknown fields in the
  bootstrap file.
2019-10-03 15:41:16 -07:00
Menghan Li 5bf44136bb
xds: make balancer group restartable (#2999)
This is a preparing change to support priority failover. It adds start() and close() to balancer group, so we can have a balancer group that's not in use, but has all the data and is ready to be started (think about a lower priority when the higher priority is in use).

A balancer group is split into two parts: static and dynamic:

static: the data from EDS, and gets updated even if balancer group is closed
balancer IDs and builders, addresses for each balancer
dynamic: the sub-balancers
These are only created when the balancer group is started. They are closed when the balancer group is closed.
And only when the balancer group is started, the sub-balancers will get address updates.
2019-10-02 10:04:32 -07:00
Easwar Swaminathan 7b8c5564b6
Add functionality to read xDS bootstrap file. (#3000)
As of this implementation, the bootstrap file will be provided in the
GRPC_XDS_BOOTSTRAP environment variable and will be read by the xDS
balancer. The file will be in JSON form with two top-level entities: a
Node proto and an ApiConfigSource proto.  The overall JSON format will
be:
{
  "node": <Node proto>,
  "xds_server": <ApiConfigSource proto>
}

In the ApiConfigSource proto, We will support only one grpc_services
entry. The api_type field must be GRPC.

As for creds, we will use default TLS creds (which will use CAs from
system default directories, and will not use any client certificates)
for transport and default compute engine creds for call credentials.
This will evolve into something more configurable in the future.
2019-09-12 14:51:55 -07:00
Easwar Swaminathan da768de056
Improve xds_test.go (#2991)
Rename TestXdsBalanceHandleResolvedAddrs as TestXdsFallbackResolvedAddrs
and add comments to explain what the test is doing. Also added some
other comments and made minor formatting changes.
2019-09-04 15:09:39 -07:00
Easwar Swaminathan dc1875474e
Implementation of the xds_experimental resolver. (#2967)
This resolver doesn't do much at this point, except returning an empty
address list and a hard-coded service config which picks the xds
balancer with a round_robin child policy.

Also moved the xdsConfig struct to the xds/internal package and exported
it as LBConfig, so that both the resolver and the balancer packages can
make use of this.
2019-08-21 11:24:53 -07:00
Easwar Swaminathan 36ddeccf18
Move code out of balancer/xds. (#2950)
We will have a root level xds/ directory which will eventually contain
all xDS implementation including balancer, resolver, client etc.

The new structure looks something like this:

grpc/
|
+--xds/
    |
    +--internal/
    |  |
    |  +--balancer/
    |     |
    |     +--edsbalancer/
    |     |
    |     +--lrs/
    |     |
    |     +--orca/
    |
    +--experimental/

Users need to import grpc/xds/experimental package to get all xds
functionality, and this will eventually be moved to grpc/xds.

Also, moved grpc/balancer/internal/wrr to grpc/internal/wrr.
2019-08-07 14:46:10 -07:00