Commit Graph

504 Commits

Author SHA1 Message Date
Doug Fawley 2a312458e6
client: don't force passthrough as default resolver (#4890) 2021-10-20 14:01:46 -07:00
Easwar Swaminathan aaff9e7ab9
grpc: better RFC 3986 compliant target parsing (#4817) 2021-10-14 14:54:02 -07:00
Easwar Swaminathan 5bfc05fb0c
grpc: clarify the use of transport.ErrConnClosing from createTransport() (#4757) 2021-09-13 11:50:52 -07:00
Doug Fawley d25e31e741
client: fix case where GOAWAY would leak connections and memory (#4755) 2021-09-10 14:12:13 -07:00
Easwar Swaminathan 7f560ef4c5
grpc: close underlying transport when subConn is closed when in connecting state (#4751) 2021-09-10 14:08:26 -07:00
Doug Fawley 8ab16ef276
balancer: add ExitIdle optional interface (#4673) 2021-08-18 15:04:35 -07:00
Doug Fawley 997ce619eb
clientconn: do not automatically reconnect addrConns; go idle instead (#4613) 2021-08-10 13:22:34 -07:00
Doug Fawley dd589923e1
clientconn: stop automatically connecting to idle subchannels returned by picker (#4579) 2021-07-02 16:21:46 -07:00
Menghan Li 45549242f7
internal: fix deadlock during switch_balancer and NewSubConn() (#4536) 2021-06-11 13:14:09 -07:00
Doug Fawley b1f7648a9f
client: ensure LB policy is closed before closing resolver (#4478) 2021-05-21 15:15:58 -07:00
Doug Fawley c15291b0f5
client: initialize safe config selector when creating ClientConn (#4398) 2021-05-07 15:24:10 -07:00
Menghan Li 7276af6dd7
client: fix leaked addrConn struct when addresses are updated (#4347) 2021-04-22 10:45:24 -07:00
apolcyn c229922995
client: propagate connection error causes to RPC statuses (#4311) 2021-04-13 13:06:05 -07:00
Edmond 39a500abb9
support unix-abstract schema (#4079) 2020-12-22 08:56:49 -08:00
Doug Fawley 750abe8f95
resolver: allow config selector to return an RPC error (#4082) 2020-12-08 13:32:37 -08:00
Doug Fawley b88744b832
xds: add ConfigSelector to support RouteAction timeouts (#3991) 2020-11-17 13:22:28 -08:00
Garrett Gutierrez 90f1b3ee83
client: use "localhost:port" as authority if target is ":port" (#4017) 2020-11-12 13:52:55 -08:00
Menghan Li d6f8e6fbaf
grpclb: send custom user-agent (#4011) 2020-11-09 14:08:58 -08:00
Garrett Gutierrez 4be647f7f6
internal/resolver/unix: Implemented unix resolver. (#3890) 2020-10-16 11:52:54 -07:00
George Kechagias 7464f756ae
channelz: remove redundant case from AddTraceEvent and remove caps from severities (#3925)
Rename UNKNOWN and INFO severities removing caps to match that of Warning and Error severities.
Remove redundant case from AddTraceEvent switch-case.
2020-10-07 08:50:23 -07:00
Gaurav Gahlot d9063e7af3
standardized experimental warnings (#3917) 2020-10-02 09:11:08 -07:00
Garrett Gutierrez a5a36bd3f0
client: set auth header to localhost for unix target (#3730) 2020-07-21 14:07:03 -07:00
Sophos a86c873a73
cleanup: fix mention of healthcheck to health (#3731) 2020-07-09 13:09:50 -07:00
Aliaksandr Mianzhynski 4258d12073
service config: add default method config support (#3684) 2020-07-06 17:56:02 -07:00
Garrett Gutierrez 506b773066
Implemented component logging (#3617) 2020-06-26 12:04:47 -07:00
Doug Fawley 4eb418e5b2
balancer: move Balancer and Picker to V2; delete legacy API (#3431) 2020-04-28 14:52:49 -07:00
Easwar Swaminathan 4c4cafbab7
internal/transport: Get rid of TargetInfo struct. (#3527) 2020-04-14 14:43:14 -07:00
sethp-nr b02de00073
client: option to surface connection errors to callers (#3430)
This commit allows blocking clients to receive a more informative error
message than "context deadline exceeded", which is especially helpful in
tracking down persistent client misconfiguration (such as an invalid TLS
certificate, an invalid server that's refusing connections, etc.)
2020-04-09 13:45:13 -07:00
Patrick Bogen e965f2a60b
client: add a WithNoProxy dialoption (#3411) 2020-03-26 15:29:40 -07:00
panguncle 9e4ff32c82
client: fix getResolver to use scheme param (#3437) 2020-03-12 13:41:38 -07:00
Garrett Gutierrez fff75ae40f
channelz: log on channelz trace events and trace on channelz relevant logs. (#3329)
channelz: log on channelz trace events and trace on channelz relevant logs. (#3329)
2020-02-14 10:11:26 -08:00
Doug Fawley 92dd426e0c
balancer/base: keep bad SubConns in TransientFailure until Ready (#3366) 2020-02-12 15:41:45 -08:00
Easwar Swaminathan e38032e927
internal: Move parseTarget function into internal package and export it. (#3368)
This will be used by RLS LB policy to validate targets specified in the
service config.
2020-02-11 17:51:29 -08:00
Doug Fawley 7afcfdd66b
client: add interface for ClientConn to be accepted by generated code (#3334) 2020-01-24 14:49:31 -08:00
Doug Fawley cd74fa23ea
internal: remove withResolverBuilder and use WithResolvers instead (#3321) 2020-01-15 08:54:42 -08:00
Doug Fawley 0083f6eefc
client: add WithResolvers options for specifying client-local resolvers (#3320) 2020-01-14 12:44:21 -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
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
Doug Fawley 2cb07fcd90
resolver: rename Option to Options, leaving type aliases for now (#3175) 2019-11-12 15:23:46 -08:00
Doug Fawley 51ac07fb67
vet: revise staticcheck strategy (#3152) 2019-11-08 14:46:57 -08:00
Doug Fawley c0909e91a5
resolver: move dns and passthrough to internal (#3116)
Nobody should directly need to reference these packages.

This is technically a breaking change. However:

- Package dns was exporting a NewBuilder method. This should never have been necessary to use, but if so, it can be replaced by importing the "grpc" package and then using resolver.Get("dns").

- Package passthrough was not exporting any symbols and there was never a need to even blank-import it.

After as much searching as possible, it appears nobody in the open source community is referencing either of these packages.
2019-10-22 13:01:54 -07:00
Easwar Swaminathan 7c8e60372e
Add more details in ClientConn GoDoc. (#3096)
The newly added lines are mostly stolen from existing Java and C-core
documentation.
2019-10-15 09:18:24 -07:00
Joe Betz 2e7984e2c0 clientconn: override authority with address's ServerName, if set (#3073) 2019-10-08 13:59:02 -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
yuxiaobo96 861d8e7992 internal: fix typos in comments (#3046) 2019-09-30 15:30:07 -07:00
Doug Fawley e351044388
clientconn: fix potential deadlock caused by ResetConnectBackoff (#3051) 2019-09-27 10:51:22 -07:00
Doug Fawley 977142214c
client: fix race between transport draining and new RPCs (#2919)
Before these fixes, it was possible to see errors on new RPCs after a
connection began draining, and before establishing a new connection.  There is
an inherent race between choosing a SubConn and attempting to creating a stream
on it.  We should be able to avoid application-visible RPC errors due to this
with transparent retry.  However, several bugs were preventing this from
working correctly:

1. Non-wait-for-ready RPCs were skipping transparent retry, though the retry
design calls for retrying them.

2. The transport closed itself (and would consequently error new RPCs) before
notifying the SubConn that it was draining.

3. The SubConn wasn't synchronously updating itself once it was notified about
the closing or draining state.

4. The SubConn would go into the TRANSIENT_FAILURE state instantaneously,
causing RPCs to fail instead of queue.
2019-07-22 16:07:55 -07:00
Doug Fawley 24b2fb8959
client: remove option to send RPCs before HTTP/2 handshake is completed (#2904) 2019-07-12 13:37:27 -07:00
Menghan Li 5caf962939
client: addrConn NewStream and health check cleanup (#2848) 2019-06-26 11:15:17 -07:00
Doug Fawley a1d4c283c6
client: update state earlier to prevent resetTransport calls from killing good transports (#2862) 2019-06-10 16:58:43 -07:00
Menghan Li 82fdf27702
addrConn: not reset backoff if update address in TransientFailure (#2740) 2019-05-30 13:13:47 -07:00
Doug Fawley d40a995895
balancer/resolver: add loadBalancingConfig and pre-parsing support (#2732) 2019-05-30 09:12:58 -07:00
Doug Fawley b7325a3150
Update go.mod for golang/x/tools and staticcheck (#2832) 2019-05-24 11:13:46 -07:00
wjywbs ab909771a0 Fix using grpc.WithBalancerName("grpclb") explicitly (#2778) (#2802) 2019-05-10 15:42:49 -07:00
lyuxuan 4748a040c8
balancer: provide parsed target through BuildOptions (#2803) 2019-05-09 13:27:41 -07:00
Weiran Fang 776edd3ba1 interceptor: new APIs for chaining client interceptors. (#2696) 2019-04-15 11:13:34 -07:00
David Drysdale d37bd82db6 Fix DialContext when using a timeout (#2737)
Fixes #2736
2019-04-04 09:58:15 -07:00
lyuxuan ea5e6da287
service config: default service config (#2686) 2019-04-03 10:50:28 -07:00
lyuxuan 955eb8a3c8
channelz: cleanup channel registration if Dial fails (#2733) 2019-04-02 15:42:35 -07:00
Doug Fawley 3910b873d3
bar: add ability to update resolver state atomically and pass directly to the balancer (#2693) 2019-03-22 10:48:55 -07:00
Jean de Klerk d021e89b3f
internal: fix Dial_OneBackoffPerRetryGroup (#2689)
* internal: fix Dial_OneBackoffPerRetryGroup

Instead of mutating global variables, switches getMinConnectDeadline to a
dial option.

Fixes #2687.

* rename getMinConnectTimeoutFunc to minConnectTimeout, ditto dial opt
2019-03-20 13:58:29 -06:00
Menghan Li fba6715d1c
addrConn: resetTransport loop cleanup (#2676)
Refactor retry loop after #2673
2019-03-19 10:28:26 -07:00
Doug Fawley 3c84def893
balancer: remove Header from PickOptions; it is also available through context (#2674) 2019-03-15 09:00:55 -07:00
Menghan Li 3958fc86cc
addrConn: resetTransport cleanup (#2673) 2019-03-14 13:14:19 -07:00
Menghan Li 5abb35752c
client: reset backoff to 0 after a connection is established (#2669)
#2663
#2636
2019-03-08 10:16:19 -08:00
Jean de Klerk 5878d965b2
transport: remove RequireHandshakeHybrid support (#2529)
This removes RequireHandshakeHybrid support and changes the default behavior
to RequireHandshakeOn. Dial calls will now block and wait for a successful
handshake before proceeding. Users relying on the old hybrid behavior (cmux
users) should consult https://github.com/soheilhy/cmux/issues/64.

Also, several tests have been updated to take this into consideration by
sending settings frames.
2019-02-27 11:04:46 -07:00
Menghan Li 1dbad57dad
internal: delete an info log (#2640)
This log doesn't print much useful information, and causes flooding, especially when ClientConn is closed (one Shutdown log for each subconn).
2019-02-13 14:40:29 -08:00
Jean de Klerk a402911c6f
internal: resetTransport connect deadline is across addresses (#2540)
internal: resetTransport connect deadline is across addresses

Currently, the connect deadline is recalculated per-address. This PR amends
that behavior such that all addresses for a single connection attempt share
the same deadline.

Fixes #2462
2019-02-11 17:12:42 -07:00
shaun e9c1ac35ec fix: typos (#2591) 2019-01-23 09:59:48 -08:00
Doug Fawley 9572bbe0f9
cleanup: remove unused symbols (#2581) 2019-01-17 10:14:45 -08:00
Doug Fawley dfd7708d35
cleanup: use time.Until(t) instead of t.Sub(time.Now) (#2571) 2019-01-15 16:09:50 -08:00
Jean de Klerk 1b41b79fd1
internal: refactor transport to single retry mechanism (#2461)
Previously, the transport was able to reset via the retry loop,
or via the event closures calling resetTransport. This meant
a very large amount of synchronization was necessary: one
reset meant the other had to not reset; state had to be kept
at the addrconn; and very subtle interactions were hard to
reason about.

This change removes the ability for event closures to directly
reset the transport. Instead, they signal to to the retry
loop about the event, and the retry loop is always the single
place that retries occur.

This also allows us to refactor the address switching logic
into a much simpler for loop inside the retry loop instead of
using addrConn state to keep track of an index.
2018-12-17 13:10:13 -08:00
lyuxuan 5da252b6a6
health check test: prevent double close of hcEnterChan (#2441) 2018-12-13 16:44:36 -08:00
Doug Fawley f3eb5bc06e
client: add GRPC_GO_REQUIRE_HANDSHAKE options to control connection behavior (#2464)
Possible settings of this environment variable:

- "hybrid" (default; removed after the 1.17 release): do not wait for handshake before considering a connection ready, but wait before considering successful.

- "on" (default after the 1.17 release): wait for handshake before considering a connection ready/successful.

- "off": do not wait for handshake before considering a connection ready/successful.

This setting will be completely removed after the 1.18 release, and "on" will be the only supported behavior.
2018-11-26 15:06:46 -08:00
Doug Fawley 04ea82009c
cleanup: replace "x/net/context" import with "context" (#2439) 2018-11-12 13:30:41 -08:00
lyuxuan eb55fa50e6
resolverWrapper: remove the watcher goroutine (#2446) 2018-11-09 15:31:07 -08:00
Doug Fawley a612bb6847
client: block RPCs early until the resolver has returned addresses (#2409)
This allows the initial RPC(s) an opportunity to apply settings from the service config; without this change we would still block, but only after observing the current service config settings.
2018-11-09 13:53:47 -08:00
Doug Fawley 59a2cfbdf9
Remove support for Go1.6-1.8 (#2428) 2018-11-01 15:43:42 -07:00
lyuxuan 105f61423e
health: Client LB channel health checking (#2387) 2018-11-01 10:49:35 -07:00
Jean de Klerk e120c3f900
internal: transport nil should happen before backoff (#2392)
Seems to fix https://travis-ci.org/grpc/grpc-go/jobs/443409852, but regardless
it's a more correct place for it to happen.
2018-10-22 13:57:57 -07:00
Jean de Klerk ff2aa05958
internal: fix GO_AWAY deadlock (#2391)
internal: fix GO_AWAY deadlock

A deadlock can occur when a GO_AWAY is followed by a connection closure. This
happens because onClose needlessly closes the current ac.transport: if a
GO_AWAY already occured, and the transport was already reset, then the later
closure (of the original address) sets ac.transport - which is now healthy -
to nil.

The manifestation of this problem is that picker_wrapper spins forever trying
to use a READY connection whose ac.transport is nil.
2018-10-19 14:11:21 -07:00
Doug Fawley 0ee1544089
cleanup: remove ac.events (unused) and related dead code (#2385) 2018-10-18 16:29:41 -07:00
Jean de Klerk 04c0c4d299
internal: fix client send preface problems (#2380)
internal: fix client send preface problems

This CL fixes three problems:

- In clientconn_state_transitions_test.go, sometimes tests would flake because there's not enough buffer to send client side settings, causing the connection to unpredictably enter TRANSIENT FAILURE. Each time we set up a server to send SETTINGS, we should also set up the server to read. This allows the client to successfully send its SETTINGS, unflaking the test.

- In clientconn.go, we incorrectly transitioned into TRANSIENT FAILURE when creating an http2client returned an error. This should be handled in the outer resetTransport main reset loop. The reason this became a problem is that the outer resetTransport has very specific conditions around when to transition into TRANSIENT FAILURE that the egregious transition did not have. So, it could transition into TRANSIENT FAILURE after failing to dial, even if it was trying to connect to a non-final address in the list of addresses.

- In clientconn.go, we incorrectly stay in CONNECTING after `createTransport` when a server sends its connection preface but the client is not able to send its connection preface. This CL causes the addrconn to correctly enter TRANSIENT FAILURE when `createTransport` fails, even if a server preface was received. It does so by making ac.successfulHandshake to consider both server preface received as well as client preface sent.
2018-10-18 14:31:34 -07:00
Doug Fawley 5b2c343e0b
add header metadata to PickOptions (#2376) 2018-10-12 15:44:20 -07:00
Menghan Li c05280cc73
cleanup: remove unused channel ready (#2353) 2018-10-11 13:10:45 -07:00
Menghan Li cb11627444
clientconn: not panic when service config updated while closing (#2371)
Closing `ClientConn` sets `balancerWrapper` to nil.
If service config switches balancer, the new balancer will be notified of the existing addresses.

When these two happens together, there's a chance that a method will be called on the nil `balancerWrapper`. This change adds a check to make sure that never happens. 

fixes #2367
2018-10-11 11:43:16 -07:00
Jean de Klerk 8d75951f9b
Fix onclose state transition (#2346)
internal: fix onClose state transitions

When onClose occurs during WaitForHandshake, it should immediately
exit createTransport instead of leaving CONNECTING and entering READY.

Furthermore, when any onClose happens, the state should change to
TRANSIENT FAILURE.

Fixes #2340
Fixes #2341

Also fixes an unreported bug in which entering READY causes a
Dial call to end prematurely, instead of blocking until a READY
transport is found.
2018-10-08 16:58:54 -06:00
dfawley cc41663c52
client: fix panic caused by WithWaitForHandshake and related races (#2336) 2018-09-27 14:23:29 -07:00
Menghan Li 4dedfdc82c
credentials: support google default creds (#2315)
Google default creds is a combo of ALTS, TLS and OAuth2. The right set of creds will be picked to use based on environment.

This PR contains:
 - A new `creds.Bundle` type
   - changes to use it in ClientConn and transport
   - dial option to set the bundle for a ClientConn
   - balancer options and NewSubConnOption to set it for SubConn
 - Google default creds implementation by @cesarghali 
 - grpclb changes to use different creds mode for different servers
 - interop client changes for google default creds testing
2018-09-25 13:17:25 -07:00
Jean de Klerk 82f263dc2f internal: fix race between cancel and shutdown
This fixes a race in ac.tearDown and ac.resetTransport. If ac.resetTransport
is in backoff when ac.tearDown occurs, there's a race between the state
changing to Shutdown and ac.resetTransport calling ac.createTransport.

This fixes it by returning when ac.resetTransport encounters an error
during ac.nextAddr (specifically ac.ctx.Error()). It also fixes it by
making sure that ac.tearDown changes state to Shutdown before canceling
the context.

Both fixes were implemented because they both seem to be valuable
standalone additions: the former makes ac.resetTransport more
understandable and less dependent on behavior happening elsewhere,
and the latter makes ac.tearDown more correct.

Finally, TestDialParseTargetUnknownScheme had its buffer removed; the
buffer was likely added a while ago to assuage this issue. It should
not be necessary anymore.
2018-09-24 10:46:24 -07:00
Jean de Klerk 35c3afad17
Transport refactor (#2305)
internal: remove transportMonitor, replace with callbacks

This refactors the internal http2 transport to use callbacks instead
of continuously monitoring the transport in a separate goroutine. This
has several advantages:

- Less goroutines.
- Less complexity: synchronous callbacks are much easier to reason to
reason about than asynchronous monitoring goroutines.
- Callbacks: these provide definitive locations for monitoring the
creation and closure of a transport, paving the way for GracefulStop.

This CL also consolidates all the logic about backoff and iterating
through the list of addresses into a single method.
2018-09-20 15:45:40 -07:00
lyuxuan acd1429515
channelz: channel tracing (#2262)
* channelz: channel trancing

* add service

* update

* uuu

* better testing

* switch to single API

* fix lint

* fix review comments

* fix fix review

* uuuupdate

* switch on channel type, instead of using boolean
2018-09-12 11:15:32 -07:00
dfawley 5fe10fccaf
Remove unused symbols (#2287) 2018-09-05 12:29:02 -07:00
lyuxuan da7e20b83e
channelz: turn on channelz when importing service package, delete RegisterChannelz from grpc package (#2277) 2018-08-29 11:01:36 -07:00
dfawley d2aec4d7de
client: Add ClientConn.ResetConnectBackoff to force reconnections on demand (#2273)
Fixes #1037
2018-08-27 13:21:48 -07:00
Dustin Spicuzza 91c7ef84b5 client: fix FailOnNonTempDialError and add a test for it (#2276) 2018-08-27 10:28:41 -07:00
lyuxuan 07ef407d99
channelz: unexport unnecessary API on grpc entities (#2257) 2018-08-06 16:02:47 -07:00
lyuxuan f4da7eee53
channelz: use atomic instead of mutex (#2218) 2018-08-06 11:17:12 -07:00
dfawley b20cbb449d Revert "internal: remove transportMonitor, replace with callbacks" (#2252)
Reverts grpc/grpc-go#2219 because of #2251
2018-08-01 15:40:56 -07:00
Jean de Klerk 97da9e087c
internal: remove transportMonitor, replace with callbacks (#2219) 2018-07-31 14:10:13 -07:00
lyuxuan 980d9e0348
ClientConn: add Target() returning target string (#2233) 2018-07-23 16:19:11 -07:00
Menghan Li 445634bdcc
client: define dialOptions as interfaces instead of functions (#2230) 2018-07-19 17:33:42 -07:00
Jean de Klerk 1dab6d184d addrconn: remove unused wait() method (#2220) 2018-07-16 08:21:34 -07:00
dfawley e193757038
internal/transport: remove some unused fields from structs (#2213)
- Flush and Authority are never read by the transport.
- Authority is used indirectly; move it to dialOptions.
- Delay is only set to false.
2018-07-13 09:56:47 -07:00
Menghan Li 984bb2c619
internal: move DialOptions to a new file (#2193) 2018-07-12 18:01:30 -07:00
dfawley 11b582728a
transport: move to internal to make room for new, public transport API (#2212)
This is a breaking change, but the transport package was never intended for use outside of grpc.  Any current users that we are aware of are incorrect or have a preferred alternative.
2018-07-11 11:22:45 -07:00
Mike Cheng f57a529f33 balancer: add rpc method to PickOptions (#2204)
Provide additional context to Pickers that wish to make decisions based on the RPC method.

Relevant issue: https://github.com/grpc/grpc-go/issues/2103
2018-07-11 10:18:09 -07:00
lyuxuan c491b25057
createTransport: timeout under waitForHandshake case should not have transport transferred to ready stage (#2208) 2018-07-09 18:20:24 -07:00
lyuxuan 264daa2be4
Set and respect HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE (#2084) 2018-07-09 11:27:58 -07:00
dfawley 40a879c23a
client: Implement gRFC A6: configurable client-side retry support (#2111) 2018-06-27 16:18:41 -07:00
mmukhi 3ec535a269
client, server: update dial/server buffer options to support a "disable" setting (#2147) 2018-06-27 11:16:33 -07:00
Menghan Li b39aa9e037
Revert stickiness (#2175)
Stickiness will be reimplemented as part of a balancer/resolver redesigning/extending.
2018-06-26 10:02:54 -07:00
lyuxuan b28608a9db
channelz: move APIs to internal except channelz service (#2157) 2018-06-18 17:59:08 -07:00
Menghan Li 24f3cca1ff
internal: move backoff to internal (#2141)
So other components such as grpclb can reuse the backoff implementation.
2018-06-13 16:07:37 -07:00
dfawley fb845db15c
internal: Change Lock to RLock since no mutation is performed (#2142) 2018-06-12 12:50:43 -07:00
Carl Mastrangelo 4344c204c9 Split grpclb out of top level grpc package (#2107)
This PR splits out grpclb from grpc.  I have made the PR in several commits so you can see more clearly the steps that happened.

There are a few possibly contentious points that I would like to make clear up front:

* grpclb will no longer autoload as a load balancer.  I think this is okay, as service config is not widely (at all?) used, and I believe this is the only way to access it.
* `internal` is used more, as a way of having code shared between packages without exposing types
* ConnectivityStateEvaluator, as used by grpclb, is no longer thread safe.  I believe there is an outer mutex that guards access, but I want to point out this subtle change up here.

All but one tests pass with this, due to another cyclic dependency.  I can fix this, but it is a little more widely scoped (such as exposing grpc.server and grpc.errorDesc in the internal package).   This PR is a nearly-passing sample of that last step to get this working. 

PTAL @menghanl @dfawley
2018-06-05 09:54:12 -07:00
lyuxuan 854695bef0
client: introduce WithDisableServiceConfig DialOption (#2010) 2018-05-08 10:28:26 -07:00
Chyroc f8dbc38bdc Fix "deprecated" function godoc comments to match standard formatting (#2027) 2018-05-02 08:52:49 -07:00
Menghan Li e8a6e2844b
stickiness: add stickiness support (#1969) 2018-04-24 10:37:52 -07:00
lyuxuan 4166ea7dad
Stage 2: Channelz metric collection (#1909) 2018-04-23 11:22:25 -07:00
Karsten Weiss 7de9139327 Fix typos (#1994) 2018-04-16 10:03:02 -07:00
Karsten Weiss 35a2846daa Various simplifications (gosimple)
This fixes:
clientconn.go:948:3: should write m = cc.sc.Methods[method[:i+1]] instead of m, _ = cc.sc.Methods[method[:i+1]] (S1005)
encoding/proto/proto_test.go:43:5: should use !bytes.Equal(p.GetBody(), expectedBody) instead (S1004)
resolver/dns/dns_resolver.go:260:2: should merge variable declaration with assignment on next line (S1021)
resolver/dns/dns_resolver.go:344:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008)
2018-04-15 15:32:33 +02:00
Karsten Weiss 95bbf69653 Remove redundant return statements (gosimple)
This fixes:
balancer/base/balancer.go:149:2: redundant return statement (S1023)
balancer_v1_wrapper.go:260:2: redundant return statement (S1023)
balancer_v1_wrapper.go:273:2: redundant return statement (S1023)
balancer_v1_wrapper.go:285:2: redundant return statement (S1023)
benchmark/benchmark.go:68:2: redundant return statement (S1023)
clientconn.go:1461:2: redundant return statement (S1023)
grpclb.go:223:2: redundant return statement (S1023)
grpclb.go:260:2: redundant return statement (S1023)
grpclb_util.go:201:2: redundant return statement (S1023)
rpc_util.go:278:50: redundant return statement (S1023)
rpc_util.go:296:56: redundant return statement (S1023)
rpc_util.go:314:56: redundant return statement (S1023)
rpc_util.go:333:53: redundant return statement (S1023)
rpc_util.go:354:52: redundant return statement (S1023)
rpc_util.go:387:56: redundant return statement (S1023)
rpc_util.go:416:53: redundant return statement (S1023)
stream.go:651:2: redundant return statement (S1023)
2018-04-15 12:43:34 +02:00
Menghan Li 35aeaeb587 documentation: mention DialContext is non-blocking by default (#1970) 2018-04-12 15:11:22 -07:00
lyuxuan cf3bf7f774
createTransport: check for SHUTDOWN before assigning TransientFailure to ac.state (#1979) 2018-04-10 12:48:04 -07:00
lyuxuan 7f73c863c0
Channelz: Entity Registration and Deletion (#1811) 2018-04-09 11:13:06 -07:00
Sam Batschelet 7316918402 clientconn: add support for unix network in DialContext. (#1883) 2018-04-09 11:12:34 -07:00
mmukhi d0a21a3347
Export changes to OSS. (#1962) 2018-04-05 10:45:41 -07:00
Menghan Li f2620c3803
resolver: keep full unparsed target string if scheme in parsed target is not registered (#1943) 2018-03-27 13:58:27 -07:00
mmukhi 207e2760fd
Fix test race: Atomically access minConnecTimout in testing environment. (#1897) 2018-03-07 10:36:17 -08:00
mmukhi 7c5299d71e
Fix flaky test: TestCloseConnectionWhenServerPrefaceNotReceived (#1870)
* Atomically update minConnectTimeout in test.

* Refactor the flaky test.

* Post review update

* mend
2018-03-02 13:39:55 -08:00
Thomas Meson 12da026194 clientconn: fix a typo in GetMethodConfig documentation (#1867) 2018-02-21 10:14:52 -08:00
Menghan Li 3926816d54
addrConn: Report underlying connection error in RPC error (#1855) 2018-02-14 14:13:10 -08:00
Menghan Li e014063a43
addrConn: keep retrying even on non-temporary errors (#1856) 2018-02-13 16:07:10 -08:00
dfawley 365770fcbd
streams: Stop cleaning up after orphaned streams (#1854)
This change introduces some behavior changes that should not impact users that
are following the proper stream protocol. Specifically, one of the following
conditions must be satisfied:

1. The user calls Close on the ClientConn.
2. The user cancels the context provided to NewClientStream, or its deadline
    expires. (Note that it if the context is no longer needed before the deadline
    expires, it is still recommended to call cancel to prevent bloat.) It is always
    recommended to cancel contexts when they are no longer needed, and to
    never use the background context directly, so all users should always be
    doing this.
3. The user calls RecvMsg (or Recv in generated code) until a non-nil error is
    returned.
4. The user receives any error from Header or SendMsg (or Send in generated
    code) besides io.EOF.  If none of the above happen, this will leak a goroutine
    and a context, and grpc will not call the optionally-configured stats handler
    with a stats.End message.

Before this change, if a user created a stream and the server ended the stream,
the stats handler would be invoked with a stats.End containing the final status
of the stream. Subsequent calls to RecvMsg would then trigger the stats handler
with InPayloads, which may be unexpected by stats handlers.
2018-02-08 10:51:16 -08:00
Menghan Li 37346e3181
Revert "Add WithResolverUserOptions for custom resolver build options" (#1839)
This reverts commit ff1be3fcc5.
2018-02-05 12:52:35 -08:00
dfawley 5ba054bf37
encoding: Introduce new method for registering and choosing codecs (#1813) 2018-01-23 11:39:40 -08:00
Menghan Li 10598f3eb3
Explain target format in DialContext's documentation (#1785) 2018-01-18 13:10:52 -08:00
mmukhi e975017b47
Don't set reconnect parameters when the server has already responded. (#1779) 2018-01-04 11:16:47 -08:00
Menghan Li e6549e636d
Add dial option to set balancer (#1697)
WithBalancerName dial option specifies the name of the balancer to be used by the ClientConn. Service config updates can NOT override the balancer option.
2017-12-18 15:35:42 -08:00
lyuxuan 98b17f20a2
relocate check for shutdown in ac.tearDown() (#1723) 2017-12-15 12:03:41 -08:00
Menghan Li dba60db4f4
Switch balancer to grpclb when at least one address is grpclb address (#1692) 2017-12-12 12:45:05 -08:00
Menghan Li ff1be3fcc5
Add WithResolverUserOptions for custom resolver build options (#1711) 2017-12-06 15:54:01 -08:00
lyuxuan be077907e2
make load balancing policy name string case-insensitive (#1708) 2017-12-04 14:03:22 -08:00
mmukhi ddbb27e545
client: backoff before reconnecting if an HTTP2 server preface was not received (#1648) 2017-12-01 09:55:42 -08:00
Menghan Li 1e1a47f0f2
Re-resolve target when one connection becomes TransientFailure (#1679)
This allows ClientConn to get more up-to-date addresses from resolver.
ClientConn compares new addresses with the cached ones. So if resolver returns the same set of addresses, ClientConn will not notify balancer about it.

Also moved the initialization of resolver and balancer to avoid race. Balancer will only be started when ClientConn gets resolved addresses from balancer.
2017-11-28 13:16:53 -08:00
Menghan Li 2ef021f78d
New grpclb implementation (#1558)
The new grpclb supports fallback to backends if remote balancer is unavailable
2017-11-27 11:16:26 -08:00
Menghan Li 10873b30bf
Fix panics on balancer and resolver updates (#1684)
- NewAddress with empty list (addrConn with an empty address list)
 - NewServiceConfig to switch balancer before the first balancer is built
2017-11-22 13:59:20 -08:00