Commit Graph

5611 Commits

Author SHA1 Message Date
Justin Bassett 1241946c15 Always update the TagContext in filterContext()
This is a potential optimization, depending on the OpenCensus
implementation installed. Currently, the code checks TagContext equality
against the empty TagContext as an optimization to avoid updating the
Context, but checking equality may not be cheaper than updating the
Context. In particular, this condition is almost always true, because we
[update the parentCtx with an additional
tag](bacf18db8d/census/src/main/java/io/grpc/census/CensusStatsModule.java (L770-L774)).
It's only true when there is no OpenCensus implementation (i.e. some
kind of no-op implementation that ignores TagContexts) or when the empty
TagContext already has that tag set to the specific value which varies
depending on the RPC method.

For the default OpenCensus implementation, the equality check is
equality between two maps. Other implementations may require additional
work to determine equality.

Basically, we are trading off rarely avoiding updating the Context for
always doing at least a map equality or potentially even more depending
on the OpenCensus implementation in use. Given this, it makes sense to
just always update the Context.
2022-11-17 10:22:43 -08:00
Sergii Tkachenko 80cd7ec457
bazel: Migrate from `cfg = "host"` to `cfg = "exec"` (#9695)
This change migrates from `cfg = "host"` to `cfg = "exec"`.
This is a no-op cleanup: `cfg = "host"` is a deprecated alias
for `cfg = "exec"`.

Tested:

```
bazel build //grpclb:grpclb
bazel build //compiler:java_grpc_library_toolchain
bazel build //compiler:grpc_java_plugin
bazel build '//compiler:*'
```

Internal ref cl/487924699
2022-11-16 13:01:59 -08:00
RapperCL 096898a46e
ManagedChannelImpl.SubchannelImpl args check bug (#9651)
Previously it could trigger NPE without the string saying which argument
was null.
2022-11-10 16:15:13 -08:00
RapperCL b8f142c1e7 reduce redundant judgment 2022-11-10 14:27:43 -08:00
Sergii Tkachenko eb1e5a11c6 Start 1.52.0 development cycle 2022-11-07 11:56:25 -08:00
Eric Anderson a82ea0cb09 Fix jmh -PjmhIncludeSingleClass
I would have assumed a JMH plugin update renamed include to includes,
but I don't see a mention to it in the plugin changelog. Either it was
an undocumented rename, or devs just kept fixing it locally and not
fixing upstream. In either case, it works now.
2022-11-04 13:46:33 -07:00
Terry Wilson 0d44203bdc
xds: Delay priority LB updates from children (#9670)
If a child policy triggers an update to the parent priority policy
it will be ignored if an update is already in process.

This is the second attempt to make this change, the first one caused a
problem with the ring hash LB. A new test that uses actual control plane
and data plane servers is now included to prove the issue no longer
appears.
2022-11-04 09:17:17 -07:00
Terry Wilson ba182c3e02
core: round_robin to use acceptResolvedAddresses()
Switching to new API to allow eventual deprecation of
handleResolvedAddresses()
2022-11-03 12:40:05 -07:00
Terry Wilson c1d0e14799
xds: Fake control plane test setup code to Rules (#9666)
This extracts the startup and shutdown code for the control and data
plane server to reparate JUnit rules, which allows this logic to be
resued in other tests in a simple manner. Also makes the test easier to
read with the boiler plate init code removed.
2022-11-03 10:48:52 -07:00
Terry Wilson 39c264698d
xds: least_request LB to use acceptResolvedAddresses() (#9616)
This is part of a migration to move all LBs away from using
handleResolvedAddresses().
2022-11-02 16:29:32 -07:00
Terry Wilson a65ecef538
xds: ring_hash to use acceptResolvedAddresses() (#9617)
Part of a migration to move all LBs away from handleResolvedAddresses()
2022-11-02 16:28:31 -07:00
apolcyn a97db60fd7
c2p resolver: use federation if enabled via env var (#9660) 2022-10-28 06:02:55 -07:00
yifeizhuang 47ddfa4f20
okhttp: add maxConnectionAge and maxConnectionAgeGrace (#9649) 2022-10-21 12:06:26 -07:00
Eric Anderson 38311e8730 .github/workflows: Bump action major versions
Almost all of these major version bumps are because they upgraded to
Node 16, which requires a new minimum version of the Runner (which
matters for those maintaining their own runners). The main outlier is
lock-threads, which changed the names of its input parameters.
2022-10-21 10:25:10 -07:00
Sanjay Pujare 4cb090145b Update README etc to reference 1.50.2 2022-10-20 17:36:54 -07:00
yifeizhuang 7007d78b71
doc: improve java doc ManagedChannelOrphanWrapper (#9636) 2022-10-20 11:16:53 -07:00
yifeizhuang fa00094328
xds: fix javadoc warning (#9637) 2022-10-20 10:34:58 -07:00
Sergii Tkachenko 6f3c915267
Update README etc to reference 1.50.1 2022-10-19 11:20:08 -07:00
DNVindhya 13c2db1aa3
add period to service filter regular expression in logging config (#9631) 2022-10-19 11:07:41 -07:00
DNVindhya aeb90e3855
gcp-observability: updated config to public preview config (#9622) 2022-10-18 14:23:54 -07:00
DNVindhya 43942623fb
gcp-observability: update observability logging proto (#9608) 2022-10-17 22:47:54 -07:00
Terry Wilson e16f1436a9
xds: wrr_locality LB to use acceptResolvedAddresses() (#9625)
Part of a migration to move load balancers away from
handleResolvedAddresses().
2022-10-13 16:27:03 -07:00
Terry Wilson 3198195908
xds: weighted_target to use acceptResolvedAddresses() (#9624)
Part of a migration from handleResolvedAddresses().
2022-10-13 15:55:23 -07:00
Terry Wilson b873dc2a7b
xds: Priority LB to use acceptResolvedAddresses() (#9623)
Part of a migration to move load balancers away from
handleResolvedAddresses()
2022-10-13 15:51:14 -07:00
Terry Wilson 63f3787f86
xds: cluster_resolver to use acceptResolvedAddresses() (#9615)
Part of a wider migration to migrate load balancers away from
handleResolvedAddresses().
2022-10-13 13:27:51 -07:00
Eric Anderson 6904f88a7d Update README etc to reference 1.50.0 2022-10-13 07:50:08 -07:00
Eric Anderson 38ef8d22d4 services: Exclude io.grpc.protobuf.services.internal from javadoc 2022-10-12 09:42:20 -07:00
Eric Anderson 18602b74e1 COMPILING.md: Fix protobuf version number to 21.7
This is essentially a repeat of b118e00c, but for our compiling
documentation. Protobuf has two versions nowadays: 3.21.7 for Java and
21.7 for protobuf as a whole. For 21.1 they tagged it both as 21.1 and
3.21.1, but they didn't do that for 3.21.7.

Fixes #9582
2022-10-10 16:06:52 -07:00
Terry Wilson 458e06fafa
cds: ClusterImplLoadBalancer to use acceptResolvedAddresses() (#9571)
This is part of the API migration away from handleResolvedAddresses().
2022-10-10 15:55:57 -07:00
Terry Wilson ab78f39f23
xds: ClusterManagerLoadBalancer to use acceptResolvedAddresses() (#9572)
Part of an API migration away from handleResolvedAddresses().
2022-10-10 15:51:10 -07:00
Terry Wilson 8473e270eb
xds: CdsLoadBalancer2 to use acceptResolvedAddresses (#9570)
xds: CdsLoadBalancer2 to use acceptResolvedAddresses

Moving over from handleResolvedAddresses() as part of an API migration.
2022-10-10 15:06:59 -07:00
Terry Wilson 950fb7da61
rls: Migrate RLS LB to acceptResolvedAddresses() (#9612)
Second attempt at this, now with the understanding that RLS actually can
accept empty address lists.

This seems contrary to the behavior this LB advertizes with the canHandleEmptyAddressListFromNameResolution() method. This method is not overridden, so the default response of false is preserved. Empty address lists are supported though, and the parent LB never called the canHandleEmptyAddressListFromNameResolution() method.
2022-10-10 13:38:03 -07:00
Terry Wilson 31d777e212
grpclb: switch to use acceptResolvedAddresses() (#9568)
This is part of a migration to move all LB implementations from
handleResolvedAddresses() to this new method.
2022-10-10 13:31:46 -07:00
Trevor Edwards 73020a9dd7 grpclb: fix mismatched indices in addresses log 2022-10-10 09:56:48 -07:00
yifeizhuang fe8f474055
xds: Fix AbstractXdsClient fromTypeUrl to use subscribedResources instead of hardcoded (#9607) 2022-10-07 13:33:38 -07:00
yifeizhuang 68339250e4
xds: remove ResourceType enum, use XdsResourceType instead (#9587)
Now the xds resources are dynamically managed in resourceStore in xdsClient. The types is a xdsResourceType, singleton.
There is no longer hardcoded static list of known resource types, the subscription list is the source of truth.
AbstractXdsClient that manages AdsStream will only accept the xds resource types that has already has watchers subscribed to, same behaviour as before.
2022-10-06 13:10:55 -07:00
yifeizhuang cff8bd8d87
doc: name resolver start() should not throw (#9589) 2022-10-05 16:22:30 -07:00
Terry Wilson df0a4bdc1b
Update README etc to reference 1.49.2 (#9588) 2022-10-04 15:16:09 -07:00
Terry Wilson dd35ae5206
okhttp: Add client transport proxy socket timeout (#9586)
Not having a timeout when reading the response from a proxy server can
cause a hang if network connectivity is lost at the same time.
2022-10-04 12:43:02 -07:00
sanjaypujare 6b80efcfa8
xds: security code refactoring: delete unused code and rename misc things (#9583) 2022-10-04 12:41:17 -07:00
Eric Anderson b118e00cf9
Use Protobuf 21.7 in our code generator
This aligns the C++ version we're using for gRPC-generated code with the
Java version. This should have no real impact to our users, as there
were no features added to .proto files or the like that would be visible
to users.
2022-10-04 10:22:52 -07:00
Alexander Polcyn b7363bc854 Revert "rls: use acceptResolvedAddresses() (#9569)"
This reverts commit 3b62fbe365.
2022-10-03 16:15:51 -07:00
Alexander Polcyn 114e1dfbf7 google-c2p resolver: add authority entry to bootstrap config 2022-09-30 15:25:50 -07:00
Eric Anderson 85bdca45fa Bump Protobuf to 3.21.7 2022-09-30 14:02:45 -07:00
sanjaypujare ba8cd04191
xds: rename ClientXdsClient to XdsClientImpl (#9573) 2022-09-30 09:32:52 -07:00
Terry Wilson 3b62fbe365
rls: use acceptResolvedAddresses() (#9569)
Switch over from handleResolvedAddresses as part of a LoadBalancer
public API refactoring.
2022-09-29 12:51:31 -07:00
Sergii Tkachenko eaf8b28930
netty: create adaptive cumulator (#9558)
Creates "Adaptive" cumulator: cumulate ByteBuf's by dynamically switching between merge and compose strategies.

This cumulator applies a heuristic to make a decision whether to track a reference to the buffer with bytes received from the network stack in an array ("zero-copy"), or to merge into the last component (the tail) by performing a memory copy.

It is necessary as a protection from a potential attack on the COMPOSITE_CUMULATOR. Consider a pathological case when an attacker sends TCP packages containing a single byte of data, and forcing the cumulator to track each one in a separate buffer. In this case we'll be paying a memory overhead for each buffer, as well as extra compute to read the cumulation.

Implemented heuristic establishes a minimal threshold for the total size of the tail and incoming buffer, below which they are merged. The sum of the tail and the incoming buffer is used to avoid a case where attacker alternates the size of data packets to trick the cumulator into always selecting compose strategy.

Merging strategy attempts to minimize unnecessary memory writes. When possible, it expands the tail capacity and only copies the incoming buffer into available memory. Otherwise, when both tail and the buffer must be copied, the tail is reallocated (or fully replaced) with a new buffer of exponentially increasing capacity (bounded to minComposeSize) to ensure runtime O(n^2) amortized to O(n).

Note: this reintroduces https://github.com/grpc/grpc-java/pull/7532, addressing the subtle issue (ref b/155940949) with `CompositeByteBuf.component()` indexes getting out of sync, which results in the merge operation producing broken buffers.
2022-09-27 19:21:46 -07:00
Eric Anderson 5b62d22802 Start 1.51.0 development cycle 2022-09-26 16:37:56 -07:00
Eric Anderson e998955d1d xds: Avoid NPE from update after removing subscriptions
This fixes a regression in commit e1ad984. I'd create a test, but the
NPE gets thrown away in the context of the current test setup so can't
be created as quickly as we'd like to fix this. I have manually tested
in a custom reproduction to confirm it resolves the NPE.

Seen at b/248326695

```
java.lang.AssertionError: java.lang.NullPointerException
        at io.grpc.xds.ClientXdsClient$1.uncaughtException(ClientXdsClient.java:89)
        at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:97)
        at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
        at io.grpc.xds.ClientXdsClient.cancelXdsResourceWatch(ClientXdsClient.java:327)
        at io.grpc.xds.ClusterResolverLoadBalancer$ClusterResolverLbState$EdsClusterState.shutdown(ClusterResolverLoadBalancer.java:378)
        at io.grpc.xds.ClusterResolverLoadBalancer$ClusterResolverLbState.shutdown(ClusterResolverLoadBalancer.java:206)
        at io.grpc.util.GracefulSwitchLoadBalancer.shutdown(GracefulSwitchLoadBalancer.java:195)
        at io.grpc.xds.ClusterResolverLoadBalancer.shutdown(ClusterResolverLoadBalancer.java:141)
        at io.grpc.xds.CdsLoadBalancer2$CdsLbState.shutdown(CdsLoadBalancer2.java:136)
        at io.grpc.xds.CdsLoadBalancer2.shutdown(CdsLoadBalancer2.java:110)
        at io.grpc.util.GracefulSwitchLoadBalancer.shutdown(GracefulSwitchLoadBalancer.java:195)
        at io.grpc.xds.ClusterManagerLoadBalancer$ChildLbState.shutdown(ClusterManagerLoadBalancer.java:256)
        at io.grpc.xds.ClusterManagerLoadBalancer.shutdown(ClusterManagerLoadBalancer.java:138)
        at io.grpc.internal.AutoConfiguredLoadBalancerFactory$AutoConfiguredLoadBalancer.shutdown(AutoConfiguredLoadBalancerFactory.java:164)
        at io.grpc.internal.ManagedChannelImpl.shutdownNameResolverAndLoadBalancer(ManagedChannelImpl.java:381)
        at io.grpc.internal.ManagedChannelImpl.access$8200(ManagedChannelImpl.java:118)
        at io.grpc.internal.ManagedChannelImpl$DelayedTransportListener.transportTerminated(ManagedChannelImpl.java:2174)
        at io.grpc.internal.DelayedClientTransport$3.run(DelayedClientTransport.java:122)
        at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
        at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
        at io.grpc.internal.ManagedChannelImpl$RealChannel.shutdown(ManagedChannelImpl.java:1057)
        at io.grpc.internal.ManagedChannelImpl.shutdown(ManagedChannelImpl.java:817)
        at io.grpc.internal.ManagedChannelImpl.shutdownNow(ManagedChannelImpl.java:837)
        at io.grpc.internal.ManagedChannelImpl.shutdownNow(ManagedChannelImpl.java:117)
        at io.grpc.internal.ForwardingManagedChannel.shutdownNow(ForwardingManagedChannel.java:52)
        at io.grpc.internal.ManagedChannelOrphanWrapper.shutdownNow(ManagedChannelOrphanWrapper.java:65)
        at io.grpc.testing.integration.GrpclbFallbackTestClient.tearDown(GrpclbFallbackTestClient.java:178)
        at io.grpc.testing.integration.GrpclbFallbackTestClient.main(GrpclbFallbackTestClient.java:67)
Caused by: java.lang.NullPointerException
        at io.grpc.xds.ClientXdsClient.handleResourceResponse(ClientXdsClient.java:179)
        at io.grpc.xds.AbstractXdsClient$AbstractAdsStream.handleRpcResponse(AbstractXdsClient.java:358)
        at io.grpc.xds.AbstractXdsClient$AdsStreamV3$1$1.run(AbstractXdsClient.java:511)
        at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
        ... 26 more
```
2022-09-26 16:37:37 -07:00
sanjaypujare 6f8e44a7f5
xds: security code refactoring/renaming (#9555)
* xds: security code refactoring/renaming
1) move certprovider package under security
2) refactor inner Factory into  CertProviderClientSslContextProviderFactory and CertProviderServerSslContextProviderFactory
3) Make CertProviderClientSslContextProvider and CertProviderServerSslContextProvider non-public
4) use only public (non package private) types like SslContextProvider (instead of CertProviderClientSslContextProvider etc)
2022-09-24 00:05:15 -07:00