Skip to content

Commit c265a5a

Browse files
Merge branch 'grpc:master' into master
2 parents eaed8c9 + 03decaf commit c265a5a

File tree

49 files changed

+1217
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1217
-197
lines changed

core/src/main/java/io/grpc/internal/AbstractClientStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ private void closeListener(
455455
if (!listenerClosed) {
456456
listenerClosed = true;
457457
statsTraceCtx.streamClosed(status);
458-
listener().closed(status, rpcProgress, trailers);
459458
if (getTransportTracer() != null) {
460459
getTransportTracer().reportStreamClosed(status.isOk());
461460
}
461+
listener().closed(status, rpcProgress, trailers);
462462
}
463463
}
464464
}

interop-testing/src/test/java/io/grpc/testing/integration/RetryTest.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static java.util.concurrent.TimeUnit.SECONDS;
21+
import static org.junit.Assert.assertNotNull;
22+
import static org.mockito.AdditionalAnswers.delegatesTo;
2123
import static org.mockito.ArgumentMatchers.any;
24+
import static org.mockito.Mockito.mock;
2225
import static org.mockito.Mockito.never;
2326
import static org.mockito.Mockito.timeout;
2427
import static org.mockito.Mockito.verify;
@@ -78,8 +81,6 @@
7881
import org.junit.Test;
7982
import org.junit.runner.RunWith;
8083
import org.junit.runners.JUnit4;
81-
import org.mockito.ArgumentCaptor;
82-
import org.mockito.Mock;
8384
import org.mockito.junit.MockitoJUnit;
8485
import org.mockito.junit.MockitoRule;
8586

@@ -103,8 +104,11 @@ public class RetryTest {
103104
@Rule
104105
public final GrpcCleanupRule cleanupRule = new GrpcCleanupRule();
105106
private final FakeClock fakeClock = new FakeClock();
106-
@Mock
107-
private ClientCall.Listener<Integer> mockCallListener;
107+
private TestListener testCallListener = new TestListener();
108+
@SuppressWarnings("unchecked")
109+
private ClientCall.Listener<Integer> mockCallListener =
110+
mock(ClientCall.Listener.class, delegatesTo(testCallListener));
111+
108112
private CountDownLatch backoffLatch = new CountDownLatch(1);
109113
private final EventLoopGroup group = new DefaultEventLoopGroup() {
110114
@SuppressWarnings("FutureReturnValueIgnored")
@@ -245,7 +249,9 @@ private void assertInboundWireSizeRecorded(long length) throws Exception {
245249
private void assertRpcStatusRecorded(
246250
Status.Code code, long roundtripLatencyMs, long outboundMessages) throws Exception {
247251
MetricsRecord record = clientStatsRecorder.pollRecord(7, SECONDS);
252+
assertNotNull(record);
248253
TagValue statusTag = record.tags.get(RpcMeasureConstants.GRPC_CLIENT_STATUS);
254+
assertNotNull(statusTag);
249255
assertThat(statusTag.asString()).isEqualTo(code.toString());
250256
assertThat(record.getMetricAsLongOrFail(DeprecatedCensusConstants.RPC_CLIENT_FINISHED_COUNT))
251257
.isEqualTo(1);
@@ -295,14 +301,14 @@ public void retryUntilBufferLimitExceeded() throws Exception {
295301
verify(mockCallListener, never()).onClose(any(Status.class), any(Metadata.class));
296302
// send one more message, should exceed buffer limit
297303
call.sendMessage(message);
304+
298305
// let attempt fail
306+
testCallListener.clear();
299307
serverCall.close(
300308
Status.UNAVAILABLE.withDescription("2nd attempt failed"),
301309
new Metadata());
302310
// no more retry
303-
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
304-
verify(mockCallListener, timeout(5000)).onClose(statusCaptor.capture(), any(Metadata.class));
305-
assertThat(statusCaptor.getValue().getDescription()).contains("2nd attempt failed");
311+
testCallListener.verifyDescription("2nd attempt failed", 5000);
306312
}
307313

308314
@Test
@@ -534,4 +540,26 @@ public ClientStreamTracer newClientStreamTracer(StreamInfo info, Metadata header
534540
assertRpcStatusRecorded(Code.INVALID_ARGUMENT, 0, 0);
535541
assertRetryStatsRecorded(0, 1, 0);
536542
}
543+
544+
private static class TestListener extends ClientCall.Listener<Integer> {
545+
Status status = null;
546+
private CountDownLatch closeLatch = new CountDownLatch(1);
547+
548+
@Override
549+
public void onClose(Status status, Metadata trailers) {
550+
this.status = status;
551+
closeLatch.countDown();
552+
}
553+
554+
void clear() {
555+
status = null;
556+
closeLatch = new CountDownLatch(1);
557+
}
558+
559+
void verifyDescription(String description, long timeoutMs) throws InterruptedException {
560+
closeLatch.await(timeoutMs, TimeUnit.MILLISECONDS);
561+
assertNotNull(status);
562+
assertThat(status.getDescription()).contains(description);
563+
}
564+
}
537565
}

xds/src/main/java/io/grpc/xds/XdsClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* protocols (e.g., LDS, RDS, VHDS, CDS and EDS) over a single channel. Watch-based interfaces
4949
* are provided for each set of data needed by gRPC.
5050
*/
51+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10862")
5152
public abstract class XdsClient {
5253

5354
static boolean isResourceNameValid(String resourceName, String typeUrl) {

xds/src/main/java/io/grpc/xds/XdsListenerResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ private LdsUpdate processServerSideListener(Listener proto, Args args)
130130
if (args.bootstrapInfo != null && args.bootstrapInfo.certProviders() != null) {
131131
certProviderInstances = args.bootstrapInfo.certProviders().keySet();
132132
}
133-
return LdsUpdate.forTcpListener(parseServerSideListener(proto, args.tlsContextManager,
133+
return LdsUpdate.forTcpListener(parseServerSideListener(proto,
134+
(TlsContextManager) args.securityConfig,
134135
filterRegistry, certProviderInstances));
135136
}
136137

xds/src/main/java/io/grpc/xds/XdsResourceType.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ public abstract class XdsResourceType<T extends ResourceUpdate> {
8585
// the resources that need an update.
8686
protected abstract boolean isFullStateOfTheWorld();
8787

88+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10847")
8889
public static class Args {
8990
final ServerInfo serverInfo;
9091
final String versionInfo;
9192
final String nonce;
9293
final Bootstrapper.BootstrapInfo bootstrapInfo;
93-
final TlsContextManager tlsContextManager;
94+
final Object securityConfig;
9495
// Management server is required to always send newly requested resources, even if they
9596
// may have been sent previously (proactively). Thus, client does not need to cache
9697
// unrequested resources.
@@ -99,17 +100,18 @@ public static class Args {
99100

100101
public Args(ServerInfo serverInfo, String versionInfo, String nonce,
101102
Bootstrapper.BootstrapInfo bootstrapInfo,
102-
TlsContextManager tlsContextManager,
103+
Object securityConfig,
103104
@Nullable Set<String> subscribedResources) {
104105
this.serverInfo = serverInfo;
105106
this.versionInfo = versionInfo;
106107
this.nonce = nonce;
107108
this.bootstrapInfo = bootstrapInfo;
108-
this.tlsContextManager = tlsContextManager;
109+
this.securityConfig = securityConfig;
109110
this.subscribedResources = subscribedResources;
110111
}
111112
}
112113

114+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10847")
113115
public static final class ResourceInvalidException extends Exception {
114116
private static final long serialVersionUID = 0L;
115117

xds/third_party/envoy/import.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
set -e
1919
# import VERSION from the google internal copybara_version.txt for Envoy
20-
VERSION=0478eba2a495027bf6ac8e787c42e2f5b9eb553b
20+
VERSION=147e6b9523d8d2ae0d9d2205254d6e633644c6fe
2121
DOWNLOAD_URL="https://github.com/envoyproxy/envoy/archive/${VERSION}.tar.gz"
2222
DOWNLOAD_BASE_DIR="envoy-${VERSION}"
2323
SOURCE_PROTO_BASE_DIR="${DOWNLOAD_BASE_DIR}/api"
@@ -79,6 +79,7 @@ envoy/config/core/v3/event_service_config.proto
7979
envoy/config/core/v3/extension.proto
8080
envoy/config/core/v3/grpc_service.proto
8181
envoy/config/core/v3/health_check.proto
82+
envoy/config/core/v3/http_service.proto
8283
envoy/config/core/v3/http_uri.proto
8384
envoy/config/core/v3/protocol.proto
8485
envoy/config/core/v3/proxy_protocol.proto
@@ -124,6 +125,7 @@ envoy/config/trace/v3/opentelemetry.proto
124125
envoy/config/trace/v3/service.proto
125126
envoy/config/trace/v3/trace.proto
126127
envoy/config/trace/v3/zipkin.proto
128+
envoy/data/accesslog/v3/accesslog.proto
127129
envoy/extensions/clusters/aggregate/v3/cluster.proto
128130
envoy/extensions/filters/common/fault/v3/fault.proto
129131
envoy/extensions/filters/http/fault/v3/fault.proto

xds/third_party/envoy/src/main/proto/envoy/admin/v3/config_dump.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ message ConfigDump {
3333
// * ``bootstrap``: :ref:`BootstrapConfigDump <envoy_v3_api_msg_admin.v3.BootstrapConfigDump>`
3434
// * ``clusters``: :ref:`ClustersConfigDump <envoy_v3_api_msg_admin.v3.ClustersConfigDump>`
3535
// * ``ecds_filter_http``: :ref:`EcdsConfigDump <envoy_v3_api_msg_admin.v3.EcdsConfigDump>`
36+
// * ``ecds_filter_quic_listener``: :ref:`EcdsConfigDump <envoy_v3_api_msg_admin.v3.EcdsConfigDump>`
3637
// * ``ecds_filter_tcp_listener``: :ref:`EcdsConfigDump <envoy_v3_api_msg_admin.v3.EcdsConfigDump>`
3738
// * ``endpoints``: :ref:`EndpointsConfigDump <envoy_v3_api_msg_admin.v3.EndpointsConfigDump>`
3839
// * ``listeners``: :ref:`ListenersConfigDump <envoy_v3_api_msg_admin.v3.ListenersConfigDump>`

xds/third_party/envoy/src/main/proto/envoy/api/v2/scoped_route.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ option (udpa.annotations.file_status).package_version_status = FROZEN;
3939
// fragments:
4040
// - header_value_extractor:
4141
// name: X-Route-Selector
42-
// element_separator: ,
42+
// element_separator: ","
4343
// element:
4444
// separator: =
4545
// key: vip

xds/third_party/envoy/src/main/proto/envoy/config/accesslog/v3/accesslog.proto

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package envoy.config.accesslog.v3;
44

55
import "envoy/config/core/v3/base.proto";
66
import "envoy/config/route/v3/route_components.proto";
7+
import "envoy/data/accesslog/v3/accesslog.proto";
78
import "envoy/type/matcher/v3/metadata.proto";
89
import "envoy/type/v3/percent.proto";
910

@@ -43,7 +44,7 @@ message AccessLog {
4344
}
4445
}
4546

46-
// [#next-free-field: 13]
47+
// [#next-free-field: 14]
4748
message AccessLogFilter {
4849
option (udpa.annotations.versioning).previous_message_type =
4950
"envoy.config.filter.accesslog.v2.AccessLogFilter";
@@ -87,6 +88,9 @@ message AccessLogFilter {
8788

8889
// Metadata Filter
8990
MetadataFilter metadata_filter = 12;
91+
92+
// Log Type Filter
93+
LogTypeFilter log_type_filter = 13;
9094
}
9195
}
9296

@@ -250,6 +254,8 @@ message ResponseFlagFilter {
250254
in: "UPE"
251255
in: "NC"
252256
in: "OM"
257+
in: "DF"
258+
in: "DO"
253259
}
254260
}
255261
}];
@@ -310,6 +316,17 @@ message MetadataFilter {
310316
google.protobuf.BoolValue match_if_key_not_found = 2;
311317
}
312318

319+
// Filters based on access log type.
320+
message LogTypeFilter {
321+
// Logs only records which their type is one of the types defined in this field.
322+
repeated data.accesslog.v3.AccessLogType types = 1
323+
[(validate.rules).repeated = {items {enum {defined_only: true}}}];
324+
325+
// If this field is set to true, the filter will instead block all records
326+
// with a access log type in types field, and allow all other records.
327+
bool exclude = 2;
328+
}
329+
313330
// Extension filter is statically registered at runtime.
314331
message ExtensionFilter {
315332
option (udpa.annotations.versioning).previous_message_type =

xds/third_party/envoy/src/main/proto/envoy/config/bootstrap/v3/bootstrap.proto

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
4141
// <config_overview_bootstrap>` for more detail.
4242

4343
// Bootstrap :ref:`configuration overview <config_overview_bootstrap>`.
44-
// [#next-free-field: 38]
44+
// [#next-free-field: 41]
4545
message Bootstrap {
4646
option (udpa.annotations.versioning).previous_message_type =
4747
"envoy.config.bootstrap.v2.Bootstrap";
@@ -101,6 +101,48 @@ message Bootstrap {
101101
core.v3.ApiConfigSource ads_config = 3;
102102
}
103103

104+
message ApplicationLogConfig {
105+
message LogFormat {
106+
oneof log_format {
107+
option (validate.required) = true;
108+
109+
// Flush application logs in JSON format. The configured JSON struct can
110+
// support all the format flags specified in the :option:`--log-format`
111+
// command line options section, except for the ``%v`` and ``%_`` flags.
112+
google.protobuf.Struct json_format = 1;
113+
114+
// Flush application log in a format defined by a string. The text format
115+
// can support all the format flags specified in the :option:`--log-format`
116+
// command line option section.
117+
string text_format = 2;
118+
}
119+
}
120+
121+
// Optional field to set the application logs format. If this field is set, it will override
122+
// the default log format. Setting both this field and :option:`--log-format` command line
123+
// option is not allowed, and will cause a bootstrap error.
124+
LogFormat log_format = 1;
125+
}
126+
127+
message DeferredStatOptions {
128+
// When the flag is enabled, Envoy will lazily initialize a subset of the stats (see below).
129+
// This will save memory and CPU cycles when creating the objects that own these stats, if those
130+
// stats are never referenced throughout the lifetime of the process. However, it will incur additional
131+
// memory overhead for these objects, and a small increase of CPU usage when a at least one of the stats
132+
// is updated for the first time.
133+
// Groups of stats that will be lazily initialized:
134+
// - Cluster traffic stats: a subgroup of the :ref:`cluster statistics <config_cluster_manager_cluster_stats>`
135+
// that are used when requests are routed to the cluster.
136+
bool enable_deferred_creation_stats = 1;
137+
}
138+
139+
message GrpcAsyncClientManagerConfig {
140+
// Optional field to set the expiration time for the cached gRPC client object.
141+
// The minimal value is 5s and the default is 50s.
142+
google.protobuf.Duration max_cached_entry_idle_duration = 1
143+
[(validate.rules).duration = {gte {seconds: 5}}];
144+
}
145+
104146
reserved 10, 11;
105147

106148
reserved "runtime";
@@ -163,6 +205,9 @@ message Bootstrap {
163205
// Optional set of stats sinks.
164206
repeated metrics.v3.StatsSink stats_sinks = 6;
165207

208+
// Options to control behaviors of deferred creation compatible stats.
209+
DeferredStatOptions deferred_stat_options = 39;
210+
166211
// Configuration for internal processing of stats.
167212
metrics.v3.StatsConfig stats_config = 13;
168213

@@ -360,6 +405,12 @@ message Bootstrap {
360405
// Envoy only supports ListenerManager for this field and Envoy Mobile
361406
// supports ApiListenerManager.
362407
core.v3.TypedExtensionConfig listener_manager = 37;
408+
409+
// Optional application log configuration.
410+
ApplicationLogConfig application_log_config = 38;
411+
412+
// Optional gRPC async manager config.
413+
GrpcAsyncClientManagerConfig grpc_async_client_manager_config = 40;
363414
}
364415

365416
// Administration interface :ref:`operations documentation
@@ -397,6 +448,7 @@ message Admin {
397448
}
398449

399450
// Cluster manager :ref:`architecture overview <arch_overview_cluster_manager>`.
451+
// [#next-free-field: 6]
400452
message ClusterManager {
401453
option (udpa.annotations.versioning).previous_message_type =
402454
"envoy.config.bootstrap.v2.ClusterManager";
@@ -437,6 +489,11 @@ message ClusterManager {
437489
// <envoy_v3_api_field_config.core.v3.ApiConfigSource.api_type>` :ref:`GRPC
438490
// <envoy_v3_api_enum_value_config.core.v3.ApiConfigSource.ApiType.GRPC>`.
439491
core.v3.ApiConfigSource load_stats_config = 4;
492+
493+
// Whether the ClusterManager will create clusters on the worker threads
494+
// inline during requests. This will save memory and CPU cycles in cases where
495+
// there are lots of inactive clusters and > 1 worker thread.
496+
bool enable_deferred_cluster_creation = 5;
440497
}
441498

442499
// Allows you to specify different watchdog configs for different subsystems.

0 commit comments

Comments
 (0)