Commit Graph

1705 Commits

Author SHA1 Message Date
Eric Gribkoff c0eca6de25
Start 1.39.0 development cycle (#8147) 2021-05-05 16:30:38 -07:00
Chengyuan Zhang 368c43aec4
core: throw away subchannel references after round_robin is shutdown (#8132)
Triggering balancing state updates after already being shutdown can be confusing for the upstream of round_robin. In cases of the callers not managing round_robin's lifecycle (e.g., not ignoring updates after it shuts down round_robin, which it should), it can make problem very bad, especially with the behavior that round_robin is actually propagating TRANSIENT_FAILURE with a picker that buffers RPCs.

This change only polishes round_robin by always preserving its invariant. Callers/LBs should not rely on this and should still manage the balancing updates from its downstream correctly based on the downstream's lifetime.
2021-04-30 15:42:44 -07:00
ZhenLian 1703d692bc
advancedtls: Add a Utility Class For Loading Certs/Keys (#8023) 2021-04-21 10:07:44 -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
ZHANG Dapeng d25ebaf57d
core: fix NPE in ConfigSelectingClientCall
Fix the following bug:

ManagedChannelImpl.ConfigSelectingClientCall may return early in start() leaving delegate null, and fails request() method after start().

Currently the bug can only be triggered when using xDS.
2021-04-14 23:06:37 -07:00
Sergii Tkachenko e4b292aa9b Start 1.38.0 development cycle 2021-03-25 18:49:03 -04:00
yifeizhuang 6a9c9901e4
grpclb: support multiple authorities in lb backends for all SRV records (#7951) 2021-03-11 13:29:41 -08:00
yifeizhuang 528ef63c58
core: Move negotiationLogger from channel attributes to GrpcHttp2ConnectionHandler (#7933) 2021-03-10 16:43:56 -08:00
Chengyuan Zhang b5c0a4a97a Make addServices() a final method on ServerBuilder and delete from its forwarders. 2021-03-05 10:03:22 -08:00
Chengyuan Zhang 37b94b3074
api: delete deprecated NameResolver APIs (#7936)
Deletes deprecated (~2 years) NameResolver APIs that uses NameResolver.Helper/Attributes for passing information from Channel to resolver.
2021-03-04 13:08:18 -08:00
Chengyuan Zhang a598b973a3
api: add ServerBuilder.addServices() API (#7926) 2021-02-28 23:36:27 -08:00
ZHANG Dapeng 132a40a1cf
xds: implement fault injection interceptor in XdsNameResolver 2021-02-18 14:35:45 -08:00
Eric Anderson 2140480736 Start 1.37.0 development cycle 2021-02-11 13:53:10 -08:00
ZHANG Dapeng 92e7fd370b
core: user is responsible to override authority for resolvingOobChannelBuilder
ManagedChannelImpl should not override authority for createResolvingOobChannel(target, creds), because ManagedChannelImpl does not know what target and creds are.
2021-01-29 09:50:59 -08:00
yifeizhuang ef76337f5c
core: add more delayedStream tests (#7843)
Add more delayedStream tests related to #7750, where we changed to call realStream.start() synchronously with setting realStream.
2021-01-29 09:42:10 -08:00
ZHANG Dapeng 9437783838
core: enhance ManagedChannelBuilder.overrideAuthority()
Enhance `ManagedChannelBuilder.overrideAuthority()` to make it impossible to use a different authority to a backend by wrapping ClientTransportFactory.newClientTransport() and setting ClientTransportOptions’ authority. To avoid confusing the LB policy, it would need to keep the original addresses to return during `Subchannel.getAddresses()`

The class `OverrideAuthorityNameResolverFactory` is deleted and its logic is moved into `ManagedChannelImpl`.
2021-01-29 09:29:06 -08:00
ZHANG Dapeng 45a151810c
all: implement Helper.createResolvingOobChannelBuilder(target, creds)
- Add APIs to `ClientTransportFactory`:
```java
public interface ClientTransportFactory {
  /**
   * Swaps to a new ChannelCredentials with all other settings unchanged. Returns null if the
   * ChannelCredentials is not supported by the current ClientTransportFactory settings.
   */
  SwapChannelCredentialsResult swapChannelCredentials(ChannelCredentials channelCreds);

  final class SwapChannelCredentialsResult {
    final ClientTransportFactory transportFactory;
    @Nullable final CallCredentials callCredentials;
  }
}
```

- Add `ChannelCredentials` to constructor args of `ManagedChannelImplBuilder`:
 ```java
public ManagedChannelImplBuilder(
      String target, @Nullable ChannelCredentials channelCreds, @Nullable CallCredentials callCreds, ...)
  ```
2021-01-28 09:49:53 -08:00
yifeizhuang ac2ead70b4
core: delay CallCredentialsApplyingTransport shutdown until metadataApplier finalized (#7813)
Improve the CallCredentialsApplyingTransport shutdown lifecycle management. Right now CallCredentialsApplyingTransport shutdown the delegated real transport too early. It should be waiting for the metadataAppliers to finish because they may execute asynchronously. In addition, there is no shutdown check on CallCredentialsApplyingTransport for newStream(). The degraded lifecycle implementation may cause RejectionExecutionException, or accepting new RPCs after the underlying transport is already closed during channel shutdown.

We added listener on metadataApplier to notify completion, a magic counter to track the pending metadataApplier for delaying shutdown, also added shutdown check for newStream().
2021-01-26 12:01:16 -08:00
Eric Anderson dbd903c018
core: Rewrite builder class signatures to avoid internal class
This provides us a path forward with #7211 (hiding
AbstractManagedChannelImplBuilder and AbstractServerImplBuilder) while
providing users a migration path to manage the ABI breakage (#7552). We
do a .class hack so that recompiling avoids the internal class reference
yet the old methods are still available.

Leaving the classes as-is causes javac to compile two versions of each
method, one returning the public class (e.g. ServerBuilder) and one
returning the internal class (e.g., AbstractServerImplBuilder). However,
we rewrite the signature that is used at compile time so that new
compilations will not reference internal-returning methods.

This is intended to be temporary, just to give a migration path. Once we
have given users some time to recompile we will remove this rewriting
and change the generics to use public classes.
2021-01-25 17:29:12 -08:00
Nick Hill 2072df9be6
Random acts of garbage reduction
I noticed some opportunities to reduce allocations on hot paths
2021-01-21 10:45:31 -08:00
Eric Anderson 7b8105e100
core: DelayedStream should start() real stream immediately
DelayedClientTransport needs to avoid becoming terminated while it owns
RPCs. Previously DelayedClientTransport could terminate when some of its
RPCs had their realStream but realStream.start() hadn't yet been called.

To avoid that, we now make sure to call realStream.start()
synchronously with setting realStream. Since start() and the method
calls before start execute quickly, we can run it in-line. But it does
mean we now need to split the Stream methods into "before start" and
"after start" categories for queuing.

Fixes #6283
2021-01-20 15:01:49 -08:00
Chengyuan Zhang ffcc360ba9
core: further clean up leftovers in ManagedChannelImpl's LoadBalancer.Helper and Subchannel implementations (#7806) 2021-01-14 10:41:36 -08:00
Chengyuan Zhang 389c5403e9
core: make subchannel creation timing restriction stricter (#7790)
Throw for subchannel creation if the channel is being shutting down and the delayed transport is terminated (aka, all retry calls has been finished). This enforces load balancer implementations to avoid creating subchannels after being shut down.
2021-01-13 17:01:02 -08:00
Chengyuan Zhang b66d182bb9
api: delete LoadBalancer.Helper APIs that had been deprecated for a long time (#7793) 2021-01-11 15:25:35 -08:00
Yifei Zhuang 53da588dd1
Move multiple-port ServerImpl to NettyServer (#7674)
Change InternalServer to handle multiple addresses and implemented in NettyServer.
It makes ServerImpl to have a single transport server, and this single transport server (NettyServer) will bind to all listening addresses during bootstrap. (#7674)
2021-01-05 13:24:16 -08:00
Eric Gribkoff f2f3bbeb5d
Start 1.36.0 development cycle (#7770) 2020-12-30 17:14:04 -08:00
Eric Anderson 20197d36ce core: Include wait-for-ready in deadline exceeded insights
There was a report from a user in b/176088054 that experienced an RPC
waiting_for_connection that failed after 45 minutes due to deadline.
That would be quite normal for wait-for-ready, but because we didn't
include that detail in the status we have to do code inspection to
determine if wait-for-ready was enabled.
2020-12-23 13:37:21 -08:00
ZHANG Dapeng 90d61178a3
all: ChannelCredentials.withoutBearerTokens() and LoadBalancer.Helper API change (#7748)
API change (See go/grpc-rls-callcreds-to-server):

- Add `ChannelCredentials.withoutBearerTokens()`
- Add `createResolvingOobChannelBuilder(String, ChannelCredentials)`, `getChannelCredentials()` and `getUnsafeChannelCredentials()` for `LoadBalancer.Helper`

This PR does not include the implementation of `createResolvingOobChannelBuilder(String, ChannelCredentials)`.
2020-12-22 22:48:39 -08:00
Yifei Zhuang a67d816f4b
Revert " check pending stream completion at delayed transport lifecycle (#7720)" (#7744)
This reverts commit 90850128a6.
Alternative solution: alternative #7743
2020-12-21 15:15:00 -08:00
Yifei Zhuang 90850128a6
check pending stream completion at delayed transport lifecycle (#7720)
add onTransferComplete() at delayedStream and wait for all pending streams to complete transfer when shutting down delayedClientTransport
2020-12-21 11:56:51 -08:00
Eric Anderson ec70b64610
Bump Gradle and plugin versions
Android plugins weren't touched, since they will need a lot more testing
when doing so.
2020-12-17 15:02:27 -08:00
Eric Anderson 60d3e7c536
core: On unexpected EOS, mention whether the frame was empty
Empty DATA frames with EOS tell a stronger tale as to where the server
may have its bug.
2020-12-10 14:54:33 -08:00
Eric Anderson 4be68f3287
core: Don't leak CallCredentials into OOB channels
The addition of CompositeChannelCredentials allowed CallCredentials to
be passed to the ManagedChannel itself. But the implementation was buggy
and used the call creds for out-of-band channels as well, which is
inappropriate since they have a different authority.

This also fixes a bug where resolving OOB channels would have CallCreds
duplicated; that wasn't noticed or important because we don't use
CallCreds in OOB channels.

Fixes #7643
2020-12-10 11:49:29 -08:00
ZHANG Dapeng af29777686
all: migrate to interceptor-based config selector
This is migration following #7610
2020-12-04 11:11:57 -08:00
ZHANG Dapeng ac2327deb7
api,core: interceptor-based config selector (#7610)
Interceptor-based config selector will be needed for fault injection.

Add `interceptor` field to `InternalConfigSelector.Result`. Keep `callOptions` and `committedCallback` fields for the moment, because it needs a refactoring to migrate the existing xds config selector implementation to the new API.
2020-11-30 09:16:22 -08:00
Chengyuan Zhang f5bbe12c9f
Start 1.35.0 development cycle (#7641) 2020-11-18 13:59:40 -08:00
Chengyuan Zhang 10dc41af74
core: round robin should ignore name resolution error for channel state change when there are READY subchannels (#7595)
Round robin is keeping use of READY subchannels even if there is name resolution error. However, it moves Channel state to TRANSIENT_ERROR.

In hierarchical load balancers, the upstream LB policy may need to aggregate pickers from multiple downstream round_robin LB policy while filtering out non-ready subchannels. It cannot infer if the subchannel can be used just from the SubchannelPicker interface. It relies on the state that the round_robin intends to set channel to.

So the change is to match the readiness of the picker/subchannel with the state that round_robin tries to update. It will completely ignore name resolution error if there are READY subchannels.
2020-11-04 14:36:12 -08:00
Sergii Tkachenko d314c68126
Fix builders ABI backward compatibility broken in v1.33.0
* fix channel builders ABI backward compatibility broken in v1.33.0
* fix server builders ABI backward compatibility broken in v1.33.0
* makes ForwardingServerBuilder package-private
2020-10-29 12:06:37 -04:00
Eric Anderson 735b85fb33 netty: Differentiate GOAWAY closure status descriptions
With this, it will be clear if the RPC failed because the server didn't
use a double-GOAWAY or if it failed because of MAX_CONCURRENT_STREAMS or
if it was due to a local race. It also fixes the status code to be
UNAVAILABLE except for the RPCs included in the GOAWAY error (modulo the
Netty bug).

Fixes #5855
2020-10-29 09:04:37 -07:00
ZHANG Dapeng 654f7c3dc6
core: fix floating-point number formatting Locale (#7473) 2020-10-28 17:23:57 -07:00
Eric Anderson 5733cd481a core: Add ChannelCredentials 2020-10-07 13:58:37 -05:00
Eric Anderson c8a94d1059 api: Add ChannelCredentials 2020-10-07 13:58:37 -05:00
ZHANG Dapeng 9b73e2365d
Start 1.34.0 development cycle 2020-10-06 16:10:51 -07:00
Eric Anderson 4c1bab9ed5 Prepare for JUnit 4.13
It deprecates ExpectedException and Assert.assertThat(T, org.hamcrest.Matcher).
Without Java 8 we don't want to migrate away from ExpectedException at
this time. We tend to prefer Truth over Hamcrest, so I swapped the one
instance of Assert.assertThat() to use Truth. With this change we get a
warning-less build with JUnit 4.13. We don't yet upgrade because we
still need to support JUnit 4.12 for some use-cases, but will be able to
upgrade to 4.13 soon when they upgrade.
2020-09-28 17:07:50 -05:00
Ran 7ca6c02312
Revert "core: delay sending cancel request on client-side when deadline expires (#6328)" (#7457) 2020-09-25 10:38:21 -07:00
ZHANG Dapeng d5668b9ee1
core,xds: remove deprecated rawConfig field from PolicySelection 2020-09-22 18:30:54 -07:00
Sergii Tkachenko ef7846496c
core: Inline AbstractManagedChannelImplBuilder 2020-09-22 10:48:31 -04:00
Sergii Tkachenko b571f23ad2
core: Inline AbstractServerImplBuilder 2020-09-18 16:31:08 -04:00
Chengyuan Zhang bf7a42dbd1
api, core: delete io.grpc.LoadBalancer.loadBalancingConfig attribute (#7440) 2020-09-18 12:54:48 -07:00
Chengyuan Zhang 80f6d874cf
core: lint remove redundant field (#7433) 2020-09-16 15:32:20 -07:00