Commit Graph

5140 Commits

Author SHA1 Message Date
Grant Oakley e28145ab6a
Enclose all operations using obtained Parcels in try-finally blocks that will recycle the Parcel in the case that any exception is thrown. (#8733) 2021-12-08 14:39:42 -08:00
apolcyn 24330bccff
Replace C2P resolver env var with experimental scheme suffix (#8744)
Java analogue of grpc/grpc#28294
2021-12-07 13:29:29 -08:00
Sergii Tkachenko 7aaa418ec7 rls: Fix RouteLookupConfig test arguments
This PR fixes a few cosmetic violations of the ErrorProne patterns
introduced in PR #8645: ParameterName, and TimeUnitMismatch.
2021-12-01 18:54:13 -05:00
John Cormie 27b03c66a6
Send empty shutdown flags to avoid a binder memory leak (#8728) 2021-11-30 16:00:43 -08:00
ZHANG Dapeng 65c00cf24e
Start 1.44.0 development cycle (#8729) 2021-11-30 11:53:56 -08:00
ZHANG Dapeng 2330922c38
rls: overhaul RouteLookupConfig validation (#8645)
The `RlsProtoData.RouteLookupConfig` class is out-of-date. 

- Some of the fields were long, but now are of `Duration` type. 
- Some of the fields are deleted. 
- The validation of some of the fields either have been changed or were wrong since beginning.

Now overhaul all the fields in `RlsProtoData.RouteLookupConfig` class based on the spec http://go/grpc-rls-lb-policy-design#heading=h.y3h669gfpown.

Also move the validation logic in json parsing rather than in the constructor of `RouteLookupConfig`.
2021-11-30 08:36:20 -08:00
ZHANG Dapeng cb4b91418c
javadoc: update new API `@since` version (#8727)
The @since version in commits 5a3b8e2 and a2398ce were missing and incorrect respectively.
2021-11-29 10:22:32 -08:00
ZHANG Dapeng a4334eb5c3
census: fix NPE in calling recordFinishedAttempt() (#8706)
Fix the NPE as shown in the following stacktrace:

```
Caused by: java.lang.RuntimeException: java.lang.NullPointerException with message: null
        at io.grpc.census.CensusStatsModule$ClientTracer.recordFinishedAttempt(CensusStatsModule.java:388) ~[grpc-census-1.42.0.jar:1.42.0]
        at io.grpc.census.CensusStatsModule$CallAttemptsTracerFactory.recordFinishedCall(CensusStatsModule.java:525) ~[grpc-census-1.42.0.jar:1.42.0]
        at io.grpc.census.CensusStatsModule$CallAttemptsTracerFactory.attemptEnded(CensusStatsModule.java:492) ~[grpc-census-1.42.0.jar:1.42.0]
        at io.grpc.census.CensusStatsModule$ClientTracer.streamClosed(CensusStatsModule.java:345) ~[grpc-census-1.42.0.jar:1.42.0]
        at io.grpc.internal.StatsTraceContext.streamClosed(StatsTraceContext.java:155) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.closeListener(AbstractClientStream.java:458) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.access$400(AbstractClientStream.java:221) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState$1.run(AbstractClientStream.java:442) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.deframerClosed(AbstractClientStream.java:278) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.Http2ClientStreamTransportState.deframerClosed(Http2ClientStreamTransportState.java:31) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.MessageDeframer.close(MessageDeframer.java:233) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.MessageDeframer.closeWhenComplete(MessageDeframer.java:191) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractStream$TransportState.closeDeframer(AbstractStream.java:200) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.transportReportStatus(AbstractClientStream.java:445) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.transportReportStatus(AbstractClientStream.java:401) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.AbstractClientStream$TransportState.inboundTrailersReceived(AbstractClientStream.java:384) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.internal.Http2ClientStreamTransportState.transportTrailersReceived(Http2ClientStreamTransportState.java:183) ~[grpc-core-1.42.0.jar:1.42.0]
        at io.grpc.netty.shaded.io.grpc.netty.NettyClientStream$TransportState.transportHeadersReceived(NettyClientStream.java:334) ~[grpc-netty-shaded-1.42.0.jar:1.42.0]
        at io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler.onHeadersRead(NettyClientHandler.java:372) ~[grpc-netty-shaded-1.42.0.jar:1.42.0]
        at io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler.access$1200(NettyClientHandler.java:91) ~[grpc-netty-shaded-1.42.0.jar:1.42.0]
        at io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler$FrameListener.onHeadersRead(NettyClientHandler.java:934) ~[grpc-netty-shaded-1.42.0.jar:1.42.0]
```

The NPE can happen when `ClientCall.Listener.onClose()` and `StatsTraceContext.streamClosed()` (or `ClientStreamListener.closed()`) are invoked concurrently in different threads.  Note that `CensusStatsModule$CallAttemptsTracerFactory.attemptEnded()` in the above stack trace would observe `callEnded==true` in such a race condition.

The following are the possible scenarios that the race between `ClientCall.Listener.onClose()` and `ClientStreamListener.closed()` can happen:

- Deadline exceeded but the underlying real stream is [not committed](https://github.com/grpc/grpc-java/blob/v1.42.0/core/src/main/java/io/grpc/internal/RetriableStream.java#L486-L495), the `ClientCall.Listener` may be closed earlier than the stream listener. (This is the case of the above stack trace, in which the inbound end-of-stream is received observing `callEnded==true`. Even if nothing inbound is received, there is still a chance that the NPE can happen.)
- DelayedClientTransport.PendingStream has created a realStream but `setStream(realStream)` is [not called yet](https://github.com/grpc/grpc-java/blob/v1.42.0/core/src/main/java/io/grpc/internal/DelayedClientTransport.java#L366-L372), when deadline exceeded. (This has little chance to happen, only for the very first RPC on the channel.)
- Hedging case.

In deadline-exceeded cases, the shorter the deadline is, the more likely the race can happen.
2021-11-29 08:48:51 -08:00
markb74 ee581bfdfa
buildscripts: add config for building grpc-binder artifact (#8722) 2021-11-23 18:11:54 +01:00
ZHANG Dapeng 5f3a5f8b37
xds: support xdstp scheme in resource URIs for federation (#8716)
Implement applying `server_listener_resource_name_template` and `client_listener_resource_name_template` with xdstp scheme, extracting authorities from xdstp resource URI and lookup authorities map in bootstrap.
2021-11-22 09:02:35 -08:00
ZHANG Dapeng a5f1fb51b8
core: have JsonUtil support parsing String value as number (#8711)
As documented in https://developers.google.com/protocol-buffers/docs/proto3#json,
the canonical proto-to-json converter converts int64 (Java long) values to string values in Json rather than Json numbers (Java Double). Conversely, either Json string value or number value are accepted to be converted to int64 proto value.

To better support service configs defined by protobuf messages, support parsing String values as numbers in `JsonUtil`.
2021-11-19 10:12:39 -08:00
yifeizhuang 8382bd8e04
xds: fix clusterImplLoadBalancer NPE when lrs is null (#8713) 2021-11-18 14:30:35 -08:00
ZHANG Dapeng dd0db6cf41
xds: terminate XdsServer start() thread when shutdownNow() is called
`XdsServerWrapper.start()` [blocks](https://github.com/grpc/grpc-java/blob/master/xds/src/main/java/io/grpc/xds/XdsServerWrapper.java#L162) until `LdsResourceWatcher`'s callback is called. If no callback is called due to whatever issue of the XdsClient, the server start() will be stuck forever, even we call `shutdownNow()`.

Changing the `shutdownNow()` behavior to unblock `start()` immediately.
2021-11-17 19:54:40 -08:00
beatrausch 5a3b8e2141
okhttp: introduced new TLS1.2 cipher suites and internal okhttp implementation for TLS1.3 prepared (#8650)
This introduces new TLS 1.2 cipher suites (#8610) and prepares the
internal okhttp implementation for TLS1.3. A new method for creating
internal ConnectionSpec was added to be able to use the newly introduced
cipher suites in the OkHttpChannelBuilder. Okhttp cipher suites
synchronized with the ones from netty.
2021-11-16 18:29:29 -08:00
Mohan Li a2398ce5db
alts: Make GoogleDefaultChannelCredentials take a CallCredentials (#8548)
DirectPath is going to support non-default service account. This commit
allows users to pass CallCredentials to GoogleDefaultChannelCredentials.
See design in go/directpath-file-credential-google-default-creds
2021-11-15 15:46:56 -08:00
sanjaypujare b746bab97b
buildscripts: rename xds-k8s to psm-security as part of tech-debt cleanup and name clarity (#8695) 2021-11-12 17:40:07 -08:00
yifeizhuang 71c5eb07d3
Update README etc to reference 1.42.1 (#8694) 2021-11-12 16:54:35 -08:00
yifeizhuang 881747a63d
xds: migrate udpa proto to xds directory (#8686)
fix https://github.com/grpc/grpc-java/issues/8631:
1. import udpa protos form new git repo `https://github.com/cncf/xds.git` instead of  `https://github.com/cncf/udpa.git`
2. use proto from xds directory not udpa directory in `https://github.com/cncf/xds.git`, details was here https://github.com/cncf/xds/issues/2#issuecomment-875838155
3. support both versions of TypeStruct
4. remove v1 orca service in old directory and use the new one v3, and refer to v3 in ORCA related area
2021-11-11 10:07:14 -08:00
ZHANG Dapeng ad0971ef5f
xds: fix parsing RouteLookupClusterSpecifier mistake (#8641)
- Partially revert the change of RlsProtoData.java  in #8612  by removing `public` accessor
- Have grpc-xds no longer strongly depend on grpc-rls. The application will need grpc-rls as runtime dependencies if they need route lookup feature in xds.
- Parse RouteLookupServiceClusterSpecifierPlugin config to the Json/Map representation of `io.grpc.lookup.v1.RouteLookupClusterSpecifier` instead of `io.grpc.rls.RlsProtoData.RouteLookupConfig`
2021-11-10 11:27:42 -08:00
ZHANG Dapeng b3579db574
xds: Migrate away deprecated fields in CsdsService (#8675)
Migrate deprecate `xds_config` field to `generic_xds_configs` 

https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/status/v3/csds.proto#service-status-v3-clientconfig

As per grpc/proposal#267.

The c++ version is grpc/grpc#27794
2021-11-10 08:38:44 -08:00
ZHANG Dapeng 389b865b9b
xds: populate LRS ServerInfo to CdsUpdate (#8676)
Replace `String lrsServerName` with `ServerInfo lrsServerInfo` in `CdsUpdate`.

See http://go/grpc-xds-federation#heading=h.gh3gjftay27x for details.

This PR is only refactoring. Federation support is not implemented until the TODO [here](a5c526c12f/xds/src/main/java/io/grpc/xds/ClientXdsClient.java (L2280)) is addressed.

Resolves #8628
2021-11-09 16:37:54 -08:00
Kevin Wooten 6518d7bd6d
Copy macOS x86 artifacts to aarch during upload (#8680) 2021-11-09 10:36:04 -08:00
Eric Anderson b6eafbe695 netty: Add system property to disable Connection header check
A user has a proxy that is sending "Connection: close", which is against
the HTTP/2 spec, but will take time to fix.

Fixes #8674
2021-11-09 09:26:18 -08:00
yifeizhuang 0b0079c8a1
xds: fix xdsClient resource not exist for invalid resource, fix xdsServerWrapper start on resource not exist (#8660)
Fix bugs:
1. Invalid resource at xdsClient, the watcher should have been delivered an error instead of resource not found.
2. If the resource is properly determined to not exist, it shouldn't cause start() to fail. From A36 xDS for Servers:
"XdsServer's start must not fail due to transient xDS issues, like missing xDS configuration from the xDS server."
2021-11-08 15:21:59 -08:00
cfredri4 ab7f867a4a
xds: Fix incorrect (old) javadoc for BootstrapperImpl (#8671) 2021-11-08 10:25:03 -08:00
Eric Anderson fe9026ed8a kokoro: Increase xds-k8s timeout to 3 hours
The addition of the authz tests in 0d345721 is causing the tests to
exceed their timeout. By itself, the authz test takes about an hour in
this environment. Before the authz tests, xds-k8s was taking an hour
and a half.
2021-11-05 10:04:48 -07:00
Sergii Tkachenko d548a35ab9 Update README etc to reference 1.42.0 2021-11-05 13:01:50 -04:00
Eric Anderson 0d34572149 kokoro: Enable xds authz_test
It is successfully passing against prod:
https://source.cloud.google.com/results/invocations/e2be0996-ed4d-4a4c-90ad-20bc706f9f70/targets
2021-11-04 16:31:16 -07:00
yifeizhuang a5c526c12f
xds: remove filter chain uuid name generator (#8663)
Generating a uuid in filterChain breaks the de-duplication detection which causes XdsServer to cycle connections, so removing it.
An empty name is now allowed. The name is currently only used for debug purpose.
2021-11-04 14:10:03 -07:00
sanjaypujare c0b8eff984
interop-testing: assign server as soon as it is built instead of after start (#8662) 2021-11-04 12:31:11 -07:00
Sergii Tkachenko efec994f4c Update MAINTAINERS.md 2021-11-04 14:50:34 -04:00
yifeizhuang 93a77a78a9
Revert "xds: add xds end to end interop test (#8618)" (#8656)
This reverts commit 0000cba665.
2021-11-03 12:13:05 -07:00
Eric Anderson bc12a1eb66 RELEASING.md: Individual OSSRH account is no longer needed
Most of the OSSRH interactions are performed by a robot.
2021-11-03 11:26:27 -07:00
yifeizhuang 0000cba665
xds: add xds end to end interop test (#8618)
Add AbstractXdsInteropTest, XdsTestControlPlaneService and only ping-pong testcase in initial implementation.
AbstractXdsInteropTest sets up the test control plane, create xdsClient and xdServer using bootstrap override, test case extending AbstractXdsInteropTest is supposed to override the control plane config and run the verification.

XdsTestControlPlaneService only has static xds configurations, not able to keep states.

How to run:
 ./gradlew :grpc-interop-testing:installDist -PskipCodegen=true
 ./interop-testing/build/install/grpc-interop-testing/bin/xds-e2e-test-client
2021-11-02 13:20:41 -07:00
Terry Wilson c1e19af86d
grpclb: fallback timer only when not already using fallback backends. (#8646)
Addresses a problem where we initially only resolve addresses to the backends, but not the load balancer and then later resolve addresses to both. In this situation the fallback timer was started during the second instance even if it resulted in the timer later failing as we were already using fallback backends.

This change assures that a fallback time is only ever started if we are not already using the fallback backends.

This is a follow-up fix to #8253.
2021-11-02 12:47:47 -07:00
markb74 746501dff6
binder: SecurityPolicy updates (take 2). (#8637)
The previous attempt at this CL relied on guava's Hashing class which
is still in beta. This update compares Signature objects directly instead
of SHA256 hashs, removing the need for the Hashing class.

Add additional comments to the security policy class, to mention that
implementing new policies requires significant care.

With that in mind, add security policies to check the peer app's
signature, so people can create cross-app communication without
having to implement their own policy.

Finally, add the UntrustedSecurityPolicies class, since that's
inevitably a policy which is sometimes needed.
2021-11-01 18:57:30 +01:00
ZHANG Dapeng a46560e4fc
xds: refactor XdsClient in preparation to support federation (#8630)
See go/java-xds-client-api-for-federation for detailed description
2021-11-01 09:44:58 -07:00
markb74 14eb3b265f
Support BinderChannelBuilder.forTarget. (#8633)
Allows this class to be used with custom name resolvers.
2021-11-01 14:01:56 +01:00
ZHANG Dapeng 59c6b49fd4
xds: lazily init MessagePrinter (#8639)
Just for cleanup. The printer might be used in other class e.g. to convert RLS proto to string/Map.
2021-10-29 11:46:00 -07:00
ZHANG Dapeng 602624887f
rls: sync latest rls protos from grpc-proto (#8638) 2021-10-29 10:12:38 -07:00
Eric Anderson ee395e0e43 Revert "binder: SecurityPolicy updates. (#8632)"
This reverts commit 997592192b.

Hashing is a Beta API in Guava, so we can't use it as-is.
2021-10-28 13:18:14 -07:00
markb74 997592192b
binder: SecurityPolicy updates. (#8632)
Add additional comments to the security policy class, to mention that implementing new policies requires significant care.

Also add security policies which check the Sha256 of a peer apps's signature, so people can do trusted cross-app communication without having to implement their own policy.

Finally, add the UntrustedSecurityPolicies class, since that's inevitably a policy you sometimes need as well.
2021-10-28 11:30:43 +02:00
ZHANG Dapeng f30d07dc2d
xds: add RlsClusterSpecifierPlugin for RLS-in-xDS (#8612)
Add RlsClusterSpecifierPlugin as per the [design doc](http://go/grpc-rls-in-xds#heading=h.dmyrvi6ohebx)

The structure of `ClusterSpecifierPlugin` is very similar to `io.grpc.xds.Filter`.

The following changes to the existing code are made:

- move `ConfigOrError` class out of `Filter` class to be shared with `ClusterSpecifierPlugin`
- make `io.grpc.rls.RlsProtoData` public to be accessible by `io.grpc.xds`
- treat empty defaultTarget in `io.grpc.rls.RlsProtoData.RouteLookupConfig` as null to support both json and proto config without defaultTarget field specified.
2021-10-27 09:07:15 -07:00
Sergii Tkachenko e0ecd5cfde
RELEASING.md: remove Travis; check milestones before the cut
* Update RELEASING.md

1) Remove Travis Job
2) Add a note to check milestones before cutting the branch
2021-10-25 15:34:28 -04:00
markb74 607362a7d2
Add support for anonymous in-process servers. (#8589)
Support anonymous in-process servers, and InProcessChannelBuilder.forTarget.

Anonymous servers aren't registered statically, meaning they can't be looked up by name.
Only the AnonymousInProcessSocketAddress passed to InProcessServerBuilder.forAddress(),
(or subsequently fetched from Server.getListenSockets()) can be used to connect to the server.

Supporting InProcessChannelBuilder.forTarget is particularly useful for production
Android usage of in-process servers, where process startup latency is crucial.
A custom name resolver can be used to create the server instance on demand
without directly impacting the startup latency of in-process gRPC clients.

Together, these features support a more-standard approach to "OnDeviceServer" referenced in gRFC L73.
https://github.com/grpc/proposal/blob/master/L73-java-binderchannel.md#ondeviceserver
2021-10-25 20:59:48 +02:00
ZHANG Dapeng 203515dd3d
rls: fix connectivity state aggregation (#8625)
Fix connectivity state aggregation as per http://go/grpc-rls-lb-policy-design#heading=h.6e8tt7xcwcdn

> Note that, for the purposes of aggregation, when a child policy reports TRANSIENT_FAILURE, we consider it to continue to be in that state until it reports READY (i.e., we ignore CONNECTING in between the two, no matter how many times it bounces back and forth between TRANSIENT_FAILURE and CONNECTING).
2021-10-21 21:24:51 -07:00
ZHANG Dapeng 00bb283090
xds: add protection flag for federation (#8619)
See https://github.com/grpc/proposal/pull/268/files#diff-e68147af61f13db5bd497e86ffd970fef6af29b88f4f23fb486deefdb35dfea3R659 for detail.
2021-10-20 17:59:21 -07:00
ZHANG Dapeng 2e87cd6ae3
Update README for Android API level (#8620)
We dropped support for Android API levels <19 in #8583
2021-10-20 17:56:53 -07:00
Benjamin Peterson 1fe62dd417
Fix sentences with a missing "be". (#8613) 2021-10-20 15:14:10 -07:00
yifeizhuang b86f4eba55
xds: fix non permanent link to envoy rbac doc #8615 2021-10-20 11:13:57 -07:00