Commit Graph

3699 Commits

Author SHA1 Message Date
Carl Mastrangelo 9aa3981ada
netty: use varargs logger in ProtocolNegotiators 2019-06-27 15:59:43 -07:00
Carl Mastrangelo 023b9a3f14
netty: don't use InternalProtocolNegotiators in ProtocolNegotiators 2019-06-27 15:07:43 -07:00
Carl Mastrangelo 0a1805db43
netty: include pipeline on exceptions too 2019-06-27 13:04:31 -07:00
Carl Mastrangelo 1be3bd8ea4
stub,core: avoid calling onready if the call is UNARY or SERVER_STREAMING 2019-06-27 10:22:54 -07:00
Carl Mastrangelo 9e5f60b86a
netty: upstream ProtocolNegotiatiorHandler, and swap the appropriate classes to it
ALTS is not switched yet, since it is shared between client and server. Once the server is changed to use WBAEH, it can be moved too.
2019-06-26 18:23:12 -07:00
Carl Mastrangelo d5e1a4bb5d
interop-testing: support just ServerBuilder types 2019-06-26 16:47:17 -07:00
Chengyuan Zhang 36476cb1f8
xds: clean up client load reporting code (#5928)
* Cleaned up XdsLoadStatsStore.
- Renamed the StatsStore interface to XdsLoadStatsStore and its corresponding implementation is XdsLoadStatsStoreImpl.
- Revised/reworded specification for XdsLoadStatsStore.

* Cleaned up ClientLoadCounter specification.

Reworded specification for ClientLoadCounter

* Cleaned up XdsLoadReportClient, reworded specifications, formatted tests.

* Removed Xds prefix from LoadStatsStore.

* Removed Xds prefix from XdsLoadReportClient.
2019-06-26 16:27:01 -07:00
ZHANG Dapeng f0a824bb53
all: fix lint 2019-06-26 15:25:18 -07:00
Carl Mastrangelo 7895c33efa
netty: make unexpected reads fail negotiation, and log close failures
In case a negotiating handler misses a read, and it reaches the WBAEH, it should cause a failure. Also, if closing the channel fails while handling another error, log the second failure.
2019-06-26 14:43:06 -07:00
ZHANG Dapeng 1e04dcf5c9
core, examples: allow empty nonfatalStatusCodes, and integer status codes 2019-06-25 15:29:52 -07:00
ZHANG Dapeng 84f8bac8d4
xds: ADS RPC retry
Resolves #5812
2019-06-25 13:13:18 -07:00
Chengyuan Zhang e36ad47695
xds: integrate receiving and reporting OOB backend metrics in xDS load balancer (#5924)
* augmented xds child balancer helper with orcaOobReportingHelperWrapper and added an interface method in LocalityStore for updating out-of-band backend metrics reporting interval

* added an callback for passing load reporting interval received from lrs response to xDS load balancer, thus, LocalityStore for configuring OOB backend metrics reporting

* moved XdsLoadReportCallback interface into XdsLoadReportClient
2019-06-24 16:05:32 -07:00
Chengyuan Zhang 44bbccff79
xds: use order-deterministic locality map for preserving most recent locality update to eliminate test flakiness (#5921)
* xds: use order-deterministic locality map for preserving most recent locality update to eliminate test flakiness

* make localityMap immutable
2019-06-21 15:56:37 -07:00
Jihun Cho 5edd726551
all: fix lint errors (#5919) 2019-06-21 15:16:31 -07:00
Zhaonian Luan b466d8d380 README.md: Updated compile to implementation. (#5914) 2019-06-21 14:28:54 -07:00
ZHANG Dapeng 81391c1fad
doc: Update NOTICE.txt with gogoproto 2019-06-21 13:01:28 -07:00
ZHANG Dapeng ea08150551
doc: Update javadoc that hedging is supported 2019-06-20 14:46:44 -07:00
ZHANG Dapeng 40595de05a
examples: rename GOOGLE_AUTH_EXAMPLE.md to README.md
This will make the git webpage show the README content automatically in the browser, when you browse https://github.com/grpc/grpc-java/tree/master/examples/example-gauth.
2019-06-20 14:45:53 -07:00
ZHANG Dapeng 18645422c9
netty: Delete deprecated HandlerSettings 2019-06-20 11:34:19 -07:00
Chengyuan Zhang 95d02410a2
xds: redesign client load recording and backend metrics receiving interface (#5903)
* Redefined StatsStore interface.
- Removed interface method StatsStore#interceptPickResult and implementation do not take the resposibility intercepting PickResult with locality-level load recording.
- Introduce a wrapper class for SubchannelPicker to let users wrap SubchannelPicker by themselves, with client side load recording logic.
- Associate the corresponding locality counter with child helper when it is created, child helper will intercept the SubchannelPicker it creates.

* Renamed backend metrics listener class to be more abstract, hides the implementation detail of doing locality-level aggregation.

* Integrate client load recording and backend metrics recording with xDS load balancer.

- Created LoadRecordingSubchannelPicker class for applying XdsClientLoadRecorder that records client load to PickResult.
- Created MetricsObservingSubchannel class for applying OrcaReportingTracerFactory that takes listener to receive ORCA reports to PickResult.
- In xDS load balancer LocalityStore, the original picker is wrapped two layers inside the above wrappers.

* Renamed XdsClientLoadRecorder to ClientLoadRecorder. It should only be used for testing, xDS load balancer should use SubchannelPicker wrappers instead of this load recorder directly.

* Removed redudent layer of wrapping for SubchannelPicker in LocalityStore

* Added toString for SubchannelPicker wrapper classes.

* Rename ClientLoadRecorder to LoadRecordingStreamTracerFactory.

* Renamed StreamInstrumentedSubchannelPicker to TracerWrappingSubchannelPicker.

* Eliminate duplicated code in LocalityStoreTest, put them into a loop.
2019-06-20 10:42:28 -07:00
Eric Anderson 29cb7c4dd4 netty: Use await instead of sync
We only care about when closing is done, not whether it is successful or not.
If there's a failure, we're already going to log a warning. Use await to avoid
throwing unexpectedly.
2019-06-20 07:19:56 -07:00
Kun Zhang ddbaf743cc
core: attach debug information about stream to DEADLINE_EXCEEDED (#5892)
Works for #4740 

- Subclasses of `AbstractClientStream` include remote address in insight if available.
- `DelayedStream` adds buffered time, and the insight of real stream if it's set.
- `RetriableStream` insights outputs of Substreams.

Example error message:
```
deadline exceeded after 8112071ns. [buffered_nanos=24763, remote_addr=foo.test.google.fr/127.0.0.1:44749]
```
or
```
deadline exceeded after 8112071ns. [buffered_nanos=22344324763, waiting_for_connection]
```

This is related to #4776 but taking a more usage-specific approach.
2019-06-19 17:30:44 -07:00
Carl Mastrangelo 74e945ceb4
core,netty: block server shutdown until the socket is unbound 2019-06-19 17:23:08 -07:00
Kun Zhang 9739e5b8b6
core: ClientStream.getAttributes() can be called at any time. (#5904)
In #5892 getAttributes() is called without any regard of timing.
Currently DelayedStream.getAttributes() wil throw if called before
passThrough was set.  Just to be safe, we are removing that
restriction and making it clear on the javadoc.

On the other hand, we intend to keep the timing restriction on
ClientCall.getAttributes().
2019-06-19 16:42:55 -07:00
ZHANG Dapeng b24263a023
examples: hedging example
See README change for details.
2019-06-19 11:53:54 -07:00
Eric Anderson 3d289213ce
netty-shaded: Use compile instead of runtime dependency in pom (#5901)
Maven does not include transitive runtime dependencies in the
compile-time classpath (testing shows Gradle 4 does; docs say
Gradle 5 doesn't). So if a user references the shaded
NettyServerBuilder without also depending on grpc-core directly,
compilation will fail because AbstractServerImplBuilder couldn't
be found.

This isn't technically a problem, since we're not wanting to encourage
users to reference the shaded classes directly. But some users will
certainly reference the classes anyway and the error is pretty confusing
while also being trivially worked around. In other words: it justs
wastes people's time and benefits nobody.

Fixes #5881
2019-06-19 09:51:00 -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
Jihun Cho e57d4c5a8e
Start 1.23.0 development cycle (#5899) 2019-06-18 15:54:16 -07:00
Eric Anderson f079a9b570 core: Protect jndi loading against broken classloaders
b/133797847
2019-06-18 15:18:49 -07:00
Jihun Cho aba45cd2e3
RELEASING.md: add missing version file for android strictmode example (#5898) 2019-06-18 13:43:37 -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 40854dc9e1
core,netty: use PerfMark tags with the HTTP/2 stream ids
This change removes the WriteQueue linking and splits it out into each
of the commands, so that the trace is more precise, and the tag
information is correct.

It is still unclear what the initial Tag should be for ClientCallImpl,
since it should not access the TransportState to get the HTTP/2 stream id.
2019-06-17 15:25:39 -07:00
Chengyuan Zhang 3829574c1c
removed abstract class StatsStore, make ClientLoadCounter not mockable (#5890) 2019-06-17 14:08:08 -07:00
Kun Zhang ff33ecd339
services: fix HealthCheckingLoadBalancer.shutdown() (#5887)
The issue: HealthCheckingLoadBalancer.shutdown() calls
hcState.onSubchannelState(SHUTDOWN) which removes that hcState from
helper.hcStates. Therefore, if more than one Subchannels are present,
ConcurrentModificationException will be thrown.

This is an alternative approach from #5848 that was reverted in #5875. Thanks to #5883, HealthCheckingLoadBalancer.shutdown() no longer has to fake SHUTDOWN notifications, and can completely rely on Subchannels' real SHUTDOWN notifications for triggering the clean-up.
2019-06-14 16:47:17 -07:00
Chengyuan Zhang fda406b0ff added missing RunWith annotations 2019-06-14 15:26:55 -07:00
Eric Anderson 675b37a027 Revert "interop-testing: Observe flow control in TestServiceImpl"
This reverts commit e795f14bed. It breaks some of
our internal tests. At the very least the cast fails because we are reusing the
service for something without going through the normal stub. There may also
have been a test hang, but it'd take more effort to figure out.
2019-06-14 15:17:22 -07:00
Kun Zhang c92c9e71bb
core: SubchannelStateListener continues to receive updates after LoadBalancer is shutdown. (#5883)
No more methods on the `LoadBalancer` will be called after
`LoadBalancer#shutdown()` is called.  This includes
`LoadBalancer#handleSubchannelState()` too.  `SubchannelStateListener`
inherited this restriction.  However, this special case makes
`onSubchannelState(SHUTDOWN)` an unreliable way of being notified
about `Subchannel` SHUTDOWN, and may confuse/complicate a
wrapping `LoadBalancer` that expects the full notification (e.g., #5875).

The javadoc isn't clear whether this restriction applies.  I think
it's more useful to make it no apply.
2019-06-14 14:43:54 -07:00
Carl Mastrangelo e5bd7f282c
Revert "Revert "core, netty: add io.perfmark Annotations" (#5853)" (#5884)
This reverts commit 2db3abc9ad.
2019-06-14 14:09:05 -07:00
Eric Anderson b836b36777 core: Fix FINE deadline logging
We were logging when withDeadline() was used, not when the Context was used. As
discovered while looking at https://stackoverflow.com/q/56593692/4690866 .

In e19e8f7d updateTimeoutHeaders was removed and logIfContextNarrowedTimeout
was called directly. However, the two methods had reverse ordering of
callDeadine/outerCallDeadline and the caller did not get their arguments
swapped.
2019-06-14 11:27:57 -07:00
Chengyuan Zhang 5f4bc15f83
xds: StatsStore#interceptPickResult should not intercept NO_RESULT (#5876)
* fixed bug of intercepting a PickResult with no Subchannel, it should just return the original PickResult. Also, the test was not correct, fixed it.

* changed ClientLoadCounter to a mock in XdsLoadStatsStoreTest, it's not necessary to instantiate a real instance.

* added a TODO comment for suggesting a warning for desired locality counter missing when intercepting a PickResult

* use isSameInstanceAs for verifying intercepting invalid PickResult instead of isEqualTo.
2019-06-14 10:50:36 -07:00
Kun Zhang aa783ee252
core/test: re-enable tests for panic mode. (#5879)
panic mode was temporarily disabled by #4152 and re-enabled by #4245,
but the tests were not.  This has caused a few test code that was
broken but not executed at all.
2019-06-14 10:28:06 -07:00
Eric Anderson e795f14bed interop-testing: Observe flow control in TestServiceImpl 2019-06-14 09:01:29 -07:00
ZHANG Dapeng 0b27e2862d
xds: let ChannelLogger log more useful information 2019-06-13 15:43:53 -07:00
Eric Anderson 8e59a2d1e5 Revert "services: fix HealthCheckingLoadBalancer.shutdown(). (#5848)"
This reverts commit c6f15162ff. It broke
an internal health checking test because the server wouldn't shut down.
We assume the health checking RPC isn't getting closed.
2019-06-13 15:04:41 -07:00
Chengyuan Zhang 77544786b6
xds: integrate client load reporting with xds load balancer (part 2) (#5867)
* integrate recordDropRequest in LocalityStore

* integrated StatsStore#addLocality and StatsStore#removeLocality in LocalityStore in handling EDS response.

* integrated picker interception in LocalityStore

* integrate XdsLoadReportClient in XdsLoadBalancer

* put removing locality counters after updating subchannl pickers to narrow down race window

* fixed modifier for XdsLoadReportClientFactory

* refactor handleNewConfig method in XdsLoadBalancer for better readability

* edited message for closing lb rpc when balancer name changes

* weaker the specification of XdsLoadReportClient to allow start/stop be called multiple times.

* removed lrsWorking flag as we relaxed precondition of calling start/stop on XdsLoadReportClient

* refactor initLbChannel to be a factory method for better readability

* added comment for the case when child policy changes, lrs should not be affected

* changed comments for eliminating potential load lose upon locality update.

* make lb RPC cancellation message more informative
2019-06-13 13:43:45 -07:00
Nick Travers 6aed34231f netty: refine filtering for benign transport level exceptions
Transport level exceptions (e.g. "Connection reset by peer") are not
useful and clutter the logs. `NettyServerTransport` contains logic to
log such exceptions at level `FINE`.

When running with epoll, transport level exceptions are prefixed with
additional contextual information (e.g. "syscall:read(..) failed:") that
causes the exceptions to be logged at level `INFO`.

Update the filtering logic to match on error messages _containing_ the
blacklisted messages, rather than using string equality.

Closes #5872.

Signed-off-by: Nick Travers <n.e.travers@gmail.com>
2019-06-13 09:24:36 -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
Sebastian Schmidt e4b666aaeb Fixing typo in SECURITY.md
See https://en.wikipedia.org/wiki/Cipher_suite
2019-06-11 22:33:30 -07:00
Chengyuan Zhang ef5a992e77
xds: fix bug of using the wrong cluster name for client load reporting (#5865)
* fixed bug of using the wrong cluster name for client load reporting

* moved clusterName into LrsStream
2019-06-11 15:54:05 -07:00