This commit makes the following changes:
- Keep track of the time of the last read in the transport.
- Use this in the keepalive implementation to decide when to send out
keepalives.
- Address the issue of keepalives being sent every [Time+Timeout] period
instead of every [Time] period, as mandated by proposal A8.
Proposal A8 is here:
https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md
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.
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.
* Make healthcheck tests in end2end_test.go more readable.
- Made these tests use the default health service implementation
wherever possible.
- Refactored some common code used in these tests into helper functions.
- Added function comments for all these tests to improve readability.
In a follow up PR, I will be moving all these tests into
healthcheck_test.go.
For large messages this generates far less garbage than ioutil.ReadAll().
Implement for gzip - RFC1952 requires it, and the Go implementation
checks it already (modulo 2^32).
Add a RequestInfo struct which initially is used for passing the full request method (though could later be expanded to pass more info) so that things like GetRequestMetadata can be used to apply logic based on that data.
This is a fix for #3019
* 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.
* 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.
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.
Previously this would fall into returning the same "s.header.Copy(), nil"
condition at the end of the function, returning an empty MD. After a recent
change it would instead check headerValid, which is always false on servers,
and return nil and an error. Callers were ignoring this error so no behavior
change was seen, but there is no need to check s.headers here.
`transport/Stream.RecvCompress` returns what the header contains, if present,
or empty string if a context error occurs. However, it "prefers" the header
data even if there is a context error, to prevent a related race. What happens
here is:
1. RPC starts.
2. Client cancels RPC.
3. `RecvCompress` tells `ClientStream.Recv` that compression used is "" because
of the context error. `as.decomp` is left nil, because there is no
compressor to look up in the registry.
4. Server's header and first message hit client.
5. Client sees the header and message and allows grpc's stream to see them.
(We only provide context errors if we need to block.)
6. Client performs a successful `Read` on the stream, receiving the gzipped
payload, then checks `as.decomp`.
7. We have no decompressor but the payload has a bit set indicating the message
is compressed, so this is an error. However, when forming the error string,
`RecvCompress` now returns "gzip" because it doesn't need to block to get
this from the now-received header. This leads to the confusing message
about how "gzip" is not installed even though it is.
This change makes `waitOnHeader` close the stream when context cancellation happens.
Then `RecvCompress` uses whatever value is present in the stream at that time, which
can no longer change because the stream is closed. Also, this will be in sync with
the messages on the stream - if there are any messages present, the headers must
have been processed first, and `RecvCompress` will contain the proper value.
In the event of a race, the first server may not be fully serving before the
client attempt to connect, then the second server may attempt to field the
FullDuplexCall, which it does not implement.
Fix the race by giving the client only the first server's address until after
the FullDuplexCall is started.