Commit Graph

134 Commits

Author SHA1 Message Date
Chengyuan Zhang 67b54608da
alts: migrate java proto map getter from get<field> to get<field>Map (#7522)
Migrate java proto map getter from get to getMap.

This is part of a set of changes to java proto map API described here: go/java-proto-maplike

More information: go/java-proto-maplike-getFooMap
2020-10-14 13:37:16 -07:00
Eric Anderson 5a687e3da8 alts: Expose ChannelCredentials for the various negotiators
AltsChannelBuilder could be improved a bit more by removing the call to
InternalNettyChannelBuilder.setProtocolNegotiatorFactory. However, to do
that cleanest would require reworking how port is plumbed in
NettyChannelBuilder and potentially AbstractManagedChannelImplBuilder to
move getDefaultPort() to ProtocolNegotiator from ClientFactory. Saving
that for another day.
2020-10-07 13:58:37 -05:00
Esun Kim 2f60c0a66c Revert "Call Cipher APIs with non-direct ByteBuffers and perform copies in the ALTS code. (cl/308901367)"
This reverts commit a7bca23053.
2020-09-10 12:12:11 -05:00
Chengyuan Zhang c30505df04
core, alts, cronet: fix ByteBuffer covariant method usages (#7349)
Java 9 introduces overridden methods with covariant return types for the following methods in java.nio.ByteBuffer:

- position​(int newPosition)
- limit​(int newLimit)
- flip​()
- clear​()
- mark​()
- reset​()
- rewind​()

In Java 9 they all now return ByteBuffer, whereas the methods they override return Buffer, resulting in exceptions like this when executing on Java 8 and lower:

java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer

This is because the generated byte code includes the static return type of the method, which is not found on Java 8 and lower because the overloaded methods with covariant return types don't exist (the issue appears even with source and target 8 or lower in compilation parameters).
The solution is to cast ByteBuffer instances to Buffer before calling the method.
2020-08-25 17:21:34 -07:00
Eric Anderson e92b2275f9 Update to Error Prone 2.4
Most of the changes should be semi-clear why they were made. However, BadImport
may not be as obvious: https://errorprone.info/bugpattern/BadImport . That
impacted classes named Type, Entry, and Factory. Also
PublicContructorForAbstractClass:
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass

The JdkObsolete issue is already resolved but is not yet in a release.
2020-08-06 10:56:16 -05:00
d-reidenbach e9ea70935b
alts: add peer attribute access for the ALTS context (#7108)
* Added Peer Attribute getter for ALTS plumbing
2020-06-24 10:24:10 -07:00
Elliotte Rusty Harold 417d7700dd
deps: Update guava to 29.0 (#7079) 2020-06-03 13:48:02 -07:00
Esun Kim c7e8990cbb
alts: Explicit buffer management to avoid too many ShortBufferException
To avoid having too many ShortBufferException thrown in ALTS code path on Java 8, we came up with this workaround creating new managed buffer, filling it, and passing it to underlying Conscrypt not to hit the code path throwing the exception. This might look to introduce another inefficiency but it's more like making it explicit because Conscrypt will do for non-managed buffer which gRPC uses.

Fix: #6761
2020-05-20 08:59:40 -07:00
ZHANG Dapeng 0044f8ce56
all: migrate gradle build to java-library plugin
- Use gradle configuration `api` for dependencies that are part of grpc public api signatures.
- Replace deprecated gradle configurations `compile`, `testCompile`, `runtime` and `testRuntime`.
- With minimal change in dependencies: If we need dep X and Y to compile our code, and if X transitively depends on Y, then our build would still pass even if we only include X as `compile`/`implementation` dependency for our project. Ideally we should include both X and Y explicitly as `implementation` dependency for our project, but in this PR we don't add the missing Y if it is previously missing.
2020-05-04 16:44:30 -07:00
ashithasantosh 2cc46acc55
Change logging level from INFO to FINE. (#6920) 2020-04-13 11:18:50 -07:00
ashithasantosh cfe73eb484
Implemented Frame Size Negotiation in ALTS for gRPC Java. (#6840) 2020-04-10 13:38:46 -07:00
ZHANG Dapeng 7be75a0bcb
all: let interop test use shaded dependency correctly take 2
First rolls forward #6791, then fixes the issue of missing transitive dependency for the shadow configuration.
2020-03-04 16:10:46 -08:00
Chengyuan Zhang afc1f2e567
core, grpclb: clean up grpclb specific attributes in core (#6790)
Move ATTR_LB_ADDR_AUTHORITY and ATTR_LB_PROVIDED_BACKEND attributes definition in GrpcAttributes to GrpclbConstants. grpc-alts will have a compile dependency on grpc-grpclb.
2020-03-02 10:27:57 -08:00
ZHANG Dapeng 1df7d7ea8e
Revert "all: let interop test use shaded dependency correctly (#6780)"
This reverts commit c5f48b8e38.  (#6780)

Revert because caused a regression in the ALTS tests. https://source.cloud.google.com/results/invocations/691d9965-fea1-487d-b606-352a5234039e/targets/grpc%2Fcore%2Fpull_request%2Flinux%2Fgrpc_interop_toprod/log

2020-03-01 20:02:12,491 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/SystemUtils
at io.grpc.alts.CheckGcpEnvironment.isRunningOnGcp(CheckGcpEnvironment.java:69)
at io.grpc.alts.CheckGcpEnvironment.isOnGcp(CheckGcpEnvironment.java:44)
at io.grpc.alts.ComputeEngineChannelBuilder.(ComputeEngineChannelBuilder.java:62)
at io.grpc.alts.ComputeEngineChannelBuilder.forTarget(ComputeEngineChannelBuilder.java:72)
at io.grpc.alts.ComputeEngineChannelBuilder.forAddress(ComputeEngineChannelBuilder.java:77)
at io.grpc.testing.integration.TestServiceClient$Tester.createChannel(TestServiceClient.java:399)
at io.grpc.testing.integration.AbstractInteropTest.setUp(AbstractInteropTest.java:309)
at io.grpc.testing.integration.TestServiceClient.setUp(TestServiceClient.java:198)
at io.grpc.testing.integration.TestServiceClient.main(TestServiceClient.java:56)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.SystemUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 9 more
2020-03-02 10:22:50 -08:00
ZHANG Dapeng c5f48b8e38
all: let interop test use shaded dependency correctly (#6780) 2020-02-28 10:04:46 -08:00
Eric Anderson 255e5feb24 Sync grpc-proto to 1ff78907
This noticed that load_balancer.proto had local changes introduced
in #6549. This was not noticed by Bazel because grpclb was not using
the io_grpc_grpc_proto repository. These issues have been fixed.
2020-02-10 12:32:39 -08:00
Eric Anderson 5b726c07fe alts: _Actually_ use Conscrypt when available
Previously the check for Conscrypt would always fail because CONSCRYPT
was guaranteed to be null.
2020-02-03 17:38:54 -08:00
Chengyuan Zhang c0f37e59ab
core, grpclb: change policy selection strategy for Grpclb policy (take one: eliminate special logic for deciding grpclb policy in core) (#6637)
First take for grpclb selection stabilization: 

1. Changed DnsNameResolver to return balancer addresses as a GrpcAttributes.ATTR_LB_ADDRS attribute in ResolutionResult, instead of among the addresses.

2. AutoConfiguredLoadBalancerFactory decides LB policy solely based on parsed service config without looking at resolved addresses. Behavior changes:
  - If no LB policy is specified in service config, default to pick_first, even if there exist balancer addresses (in attributes).
  - If grpclb specified but not available and no other specified policies available, it will fail without fallback to round_robin.

3. GrpclbLoadBalancer populates balancer addresses from ResolvedAddresses's attribute (GrpclbConstants.ATTR_LB_ADDRS) instead of sieving from addresses.
2020-01-31 10:41:43 -08:00
Chengyuan Zhang cb4a7fb2de
alts: do not exclude opencensus-api from google-oauth2's transitive dependencies (#6607) 2020-01-15 12:33:57 -08:00
Jiangtao Li d82140cdbc
alts: change errr status to permission deny if alts context not found (#6562) 2019-12-27 12:41:51 -08:00
Jiangtao Li 04e1c9d44a
alts: add client authorization util library (#6529)
* alts: add client authorization util library
2019-12-18 10:54:59 -08:00
Tomo Suzuki 29638780ae build: Replaced outdated comments (#6492) 2019-12-05 13:53:51 -08:00
Jiangtao Li 0dfda93395
alts: fix lazychannel close (#6475) 2019-12-02 15:33:31 -08:00
Jihun Cho 7db873f1f6
Roll-forward of stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub #6196 (#6458)
This reverts commit 2eb3f8c34e (#6317).
2019-11-25 09:41:16 -08:00
Eric Anderson 8b242e1ca1
alts: Check Cipher before declaring Conscrypt working 2019-11-01 12:30:37 -07:00
ZHANG Dapeng b5e890bb72
alts: fix ComputeEngineChannelBuilder class signature 2019-11-01 12:04:52 -07:00
Jihun Cho 2eb3f8c34e
stub,compiler: Rollback Abstract{Future,Blocking,Async}Stub (#6317)
rollback of #6304 & #6196
2019-10-22 13:27:30 -07:00
Jihun Cho 45d49a56cc
stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub (#6196) 2019-10-17 14:49:24 -07:00
Eric Anderson 024a46bd11
bazel: Support --incompatible_load_proto_rules_from_bzl
This flag will be enabled by default in Bazel 1.0

Since I changed the grpc-proto repo version for Bazel, I also synced the
protos.
2019-10-09 14:46:17 -07:00
Eric Anderson e9921b77f2 Create ConscryptLoader for code sharing 2019-10-07 11:37:50 -07:00
Eric Anderson 0be86a5731
alts: Use Conscrypt when available
We depend on Conscrypt to help ensure Conscrypt 2.1.0 or newer is used.
It's not 100% clear this is the best approach, but it is the simplest at
present. If Conscrypt is not available then we will just use the JDK's
slower implementation of AES-GCM.

Fixes #6213
2019-09-30 13:39:22 -07:00
Jihun Cho 3f11b27a22 alts: make AltsHandshakerClient#close can be called multiple times 2019-09-27 14:42:40 -07:00
Jihun Cho 1ab651073d
alts: add close to TsiHandshaker to avoid resource leak for some impls (#6186)
* alts: add close to TsiHandshaker to avoid resource leak for some implementations

* fix linter error
2019-09-25 13:23:52 -07:00
Eric Anderson 2b945774b6 Apply animalsniffer plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 4215b80b81 Apply java plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 5b838e5284 Apply maven-publish plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 3c3a823a81 Swap to Gradle's Plugin DSL for much of build
Examples and android projects were left unchanged. They can be changed
later.

No plugin versions were changed, to make this as non-functional of a
change as possible. Upgrading Gradle to 5.6 was necessary for
pluginManagement in settings.gradle.
2019-09-13 09:42:17 -07:00
康智冬 415212fc49 alts: fix typo (#6113) 2019-09-10 14:13:35 -07:00
Jihun Cho c9177b2327
alts: convert TsiHandshakeHandler to fit new ProtocolNegotiation style (#6104) 2019-08-30 09:59:32 -07:00
liym 47b11ab7a1 compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service… (#5943)
* compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service_name$'

* compiler: Align indentation

* Fix typo

* Add modified golden files and all re-generated code to meet Travis CI and Windows build requirements

See PR #5943

* Polishing
2019-07-24 10:37:13 -07:00
Jihun Cho 1fbc61b280 alts: provide channel type to HandshakerServiceChannel to suppress warning 2019-07-22 09:50:03 -07:00
Carl Mastrangelo 6e2bb6b402
alts: fix server hang
Followup to #5893 which causes a server side hang. This is a hack.
2019-06-19 09:24:28 -07:00
Carl Mastrangelo c78907a9c7
alts: temporarily revert protocol negotiation to work with servers 2019-06-18 10:25:46 -07:00
Carl Mastrangelo 9c9ca659d4
netty,alts: fire initial protocol negotiation event in WBAEH
This change is needed after trying to use the new style protocol negotiators internally.  The problem is that some handlers fire the event in handlerAdded, which is too early.  The followup PNE is fired after handlerAdded, which breaks the composibility of the negotiators.

To fix this, this change modifies the negotiation flow.  Specifically:

* Negotiators should NEVER fire a negotiation from handlerAdded, instead they should wait until userEventTriggered
* Negotiators now do state checking on the PNE.  If it is set twice, it fails.  If it has not been received when doing the next stage of negotiation, it fails.
* WBAEH now fires the initial, default event.  This is the only handler that can fire it from handlerAdded

The tests updated are ones not using WBAEH (which they probably should).  This change ensures attributes aren't lost when doing negotiation.
2019-06-18 09:33:40 -07:00
Carl Mastrangelo 3432395119
alts: handle inline flushes on close in frame handler
gRPC issues flushes after close in the WriteQueue, which can show up as an NPE in the framer.  This was thought to have been handled, by checking to see if there were any pending writes, but if the close() call gets far enough, the writes will be null.    This causes an NPE when the flush comes though.

The issue is difficult to reproduce, and I think my test case emulates the failure.  EmbeddedChannel is different than the normal Channels we use, making the precise ordering tough.  The test case isn't exactly what the production code would do, but it does have the same ordering.

cc @jiangtaoli2016 

Sample Stack trace:

```
Jun 10, 2019 2:09:03 PM io.grpc.ChannelLogger log
FINEST: [OobChannel<10>] Entering SHUTDOWN state
Jun 10, 2019 2:09:03 PM io.grpc.ChannelLogger log
FINEST: [Subchannel-OOB<11>: (fake-authority-that-is-always-the-same)] NettyClientTransport<14>: (/0:0:0:0:0:0:0:1:20008) SHUTDOWN with UNAVAILABLE(OobChannel is shutdown)
Jun 10, 2019 2:09:03 PM io.grpc.netty.NettyClientHandler close
FINE: Network channel being closed by the application.
Jun 10, 2019 2:09:03 PM io.grpc.internal.ClientCallImpl logIfContextNarrowedTimeout
FINE: Call timeout set to '4999299080' ns, due to context deadline. Explicit call timeout was not set.
Jun 10, 2019 2:09:03 PM io.netty.handler.codec.http2.Http2FrameLogger logGoAway
FINE: [id: 0x4bcebba6, L:/0:0:0:0:0:0:0:1:33296 - R:/0:0:0:0:0:0:0:1:20008] OUTBOUND GO_AWAY: lastStreamId=0 errorCode=0 length=0 bytes=
Jun 10, 2019 2:09:03 PM io.grpc.netty.NettyClientHandler onConnectionError
FINE: Caught a connection error
java.lang.NullPointerException
        at io.grpc.alts.internal.TsiFrameHandler.flush(TsiFrameHandler.java:126)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:754)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:746)
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:732)
        at io.netty.handler.codec.http2.Http2ConnectionHandler.flush(Http2ConnectionHandler.java:201)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:754)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:746)
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:732)
        at io.netty.channel.DefaultChannelPipeline.flush(DefaultChannelPipeline.java:978)
        at io.netty.channel.AbstractChannel.flush(AbstractChannel.java:253)
        at io.grpc.netty.WriteQueue.flush(WriteQueue.java:124)
        at io.grpc.netty.WriteQueue.access$000(WriteQueue.java:32)
        at io.grpc.netty.WriteQueue$1.run(WriteQueue.java:44)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

Jun 10, 2019 2:09:03 PM io.netty.channel.AbstractChannelHandlerContext notifyHandlerException
WARNING: An exception was thrown by a user handler while handling an exceptionCaught event
java.lang.NullPointerException
        at io.grpc.alts.internal.TsiFrameHandler.flush(TsiFrameHandler.java:126)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:754)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:746)
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:732)
        at io.netty.handler.codec.http2.Http2ConnectionHandler.onError(Http2ConnectionHandler.java:629)
        at io.grpc.netty.AbstractNettyHandler.exceptionCaught(AbstractNettyHandler.java:81)
        at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:297)
        at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:276)
        at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:268)
        at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:143)
        at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:297)
        at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:836)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:756)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:746)
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:732)
        at io.netty.handler.codec.http2.Http2ConnectionHandler.flush(Http2ConnectionHandler.java:201)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:754)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:746)
        at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:732)
        at io.netty.channel.DefaultChannelPipeline.flush(DefaultChannelPipeline.java:978)
        at io.netty.channel.AbstractChannel.flush(AbstractChannel.java:253)
        at io.grpc.netty.WriteQueue.flush(WriteQueue.java:124)
        at io.grpc.netty.WriteQueue.access$000(WriteQueue.java:32)
        at io.grpc.netty.WriteQueue$1.run(WriteQueue.java:44)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

Jun 10, 2019 2:09:03 PM io.grpc.netty.NettyClientHandler channelInactive
FINE: Network channel is closed
Jun 10, 2019 2:09:03 PM io.grpc.ChannelLogger log
FINEST: [Subchannel-OOB<11>: (fake-authority-that-is-always-the-same)] NettyClientTransport<14>: (/0:0:0:0:0:0:0:1:20008) Terminated
Jun 10, 2019 2:09:03 PM io.grpc.ChannelLogger log
FINEST: [Subchannel-OOB<11>: (fake-authority-that-is-always-the-same)] Terminated
```
2019-06-12 11:06:12 -07:00
Carl Mastrangelo f8ba38a0e4
alts: ensure only the first few bytes of key are used
Fixes grpc/grpc#19271
2019-06-06 14:59:22 -07:00
Carl Mastrangelo 7657523b28
all: update to error prone 2.3.3 2019-06-05 15:28:43 -07:00
Jihun Cho 23170c298e
alts: add TsiPeer boolean property (#5824) 2019-06-03 16:29:48 -07:00
Chengyuan Zhang d86d3dd363
all: fix lint and revert redundant lint fixes in #5570 (#5787)
* Revert "all: fix lint (#5770)"

This reverts commit 00d4cc29ad.

* all: fix lint and revert redundant lint fix in #5570
2019-05-24 01:02:12 -07:00
Carl Mastrangelo b0167b97e1
alts: don't log in Framer after close 2019-05-23 11:36:00 -07:00