Skip to content

Commit 6d2335d

Browse files
committed
xds: redo ext_proc client half-close and metric label changes after master merge
- Drop backend_service metric label from ExternalProcessorClientInterceptor. - Set end_of_stream on client half-close alongside end_of_stream_without_message. - Handle end_of_stream_without_message per ext_proc spec on StreamedBodyResponse. - Update tests and mocks to reflect the updated half-close semantics. TAG=agy CONV=86c74ebe-9fd7-4876-b27c-a4c1b230d346
1 parent f93f5df commit 6d2335d

2 files changed

Lines changed: 651 additions & 94 deletions

File tree

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static synchronized void initMetricInstruments() {
132132
"s",
133133
LATENCY_BUCKETS,
134134
ImmutableList.of("grpc.target"),
135-
ImmutableList.of("grpc.lb.backend_service"),
135+
ImmutableList.of(),
136136
true);
137137

138138
clientHalfCloseDuration = registry.registerDoubleHistogram(
@@ -142,7 +142,7 @@ static synchronized void initMetricInstruments() {
142142
"s",
143143
LATENCY_BUCKETS,
144144
ImmutableList.of("grpc.target"),
145-
ImmutableList.of("grpc.lb.backend_service"),
145+
ImmutableList.of(),
146146
true);
147147

148148
serverHeadersDuration = registry.registerDoubleHistogram(
@@ -152,7 +152,7 @@ static synchronized void initMetricInstruments() {
152152
"s",
153153
LATENCY_BUCKETS,
154154
ImmutableList.of("grpc.target"),
155-
ImmutableList.of("grpc.lb.backend_service"),
155+
ImmutableList.of(),
156156
true);
157157

158158
serverTrailersDuration = registry.registerDoubleHistogram(
@@ -162,7 +162,7 @@ static synchronized void initMetricInstruments() {
162162
"s",
163163
LATENCY_BUCKETS,
164164
ImmutableList.of("grpc.target"),
165-
ImmutableList.of("grpc.lb.backend_service"),
165+
ImmutableList.of(),
166166
true);
167167
}
168168
}
@@ -246,8 +246,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
246246

247247
DataPlaneClientCall dataPlaneCall = new DataPlaneClientCall(
248248
delayedCall, rawCall, extProcStub, filterConfig, filterConfig.getMutationRulesConfig(),
249-
scheduler, rawMethod, next, metricsRecorder, next.authority(),
250-
callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY));
249+
scheduler, rawMethod, next, metricsRecorder, next.authority());
251250

252251
return (ClientCall<ReqT, RespT>) (ClientCall<?, ?>) dataPlaneCall;
253252
}
@@ -340,7 +339,6 @@ private static class DataPlaneClientCall
340339
private final Channel channel;
341340
private final MetricRecorder metricsRecorder;
342341
private final String target;
343-
private final String backendService;
344342
private volatile Context callContext = Context.ROOT;
345343

346344
private volatile long clientHeadersStartNanos;
@@ -374,8 +372,7 @@ protected DataPlaneClientCall(
374372
MethodDescriptor<?, ?> method,
375373
Channel channel,
376374
MetricRecorder metricsRecorder,
377-
String target,
378-
String backendService) {
375+
String target) {
379376
super(delayedCall);
380377
this.delayedCall = delayedCall;
381378
this.rawCall = rawCall;
@@ -388,7 +385,6 @@ protected DataPlaneClientCall(
388385
this.channel = channel;
389386
this.metricsRecorder = checkNotNull(metricsRecorder, "metricsRecorder");
390387
this.target = checkNotNull(target, "target");
391-
this.backendService = checkNotNull(backendService, "backendService");
392388
}
393389

394390
private boolean activateCall() {
@@ -420,7 +416,7 @@ private void recordDuration(DoubleHistogramMetricInstrument instrument, long dur
420416
instrument,
421417
durationSecs,
422418
ImmutableList.of(target),
423-
ImmutableList.of(backendService));
419+
ImmutableList.of());
424420
}
425421
}
426422

@@ -1124,6 +1120,7 @@ public void halfClose() {
11241120

11251121
ProcessingRequest.Builder builder = ProcessingRequest.newBuilder()
11261122
.setRequestBody(HttpBody.newBuilder()
1123+
.setEndOfStream(true)
11271124
.setEndOfStreamWithoutMessage(true)
11281125
.build());
11291126
mergeAccumulatedWindowUpdates(builder);
@@ -1156,7 +1153,10 @@ private void handleRequestBodyResponse(BodyResponse bodyResponse) {
11561153
BodyMutation mutation = bodyResponse.getResponse().getBodyMutation();
11571154
if (mutation.hasStreamedResponse()) {
11581155
StreamedBodyResponse streamed = mutation.getStreamedResponse();
1159-
if (!streamed.getEndOfStreamWithoutMessage()) {
1156+
boolean isEndOfStream = streamed.getEndOfStream();
1157+
boolean isEndOfStreamWithoutMessage =
1158+
isEndOfStream && streamed.getEndOfStreamWithoutMessage();
1159+
if (!isEndOfStreamWithoutMessage) {
11601160
ByteString body = streamed.getBody();
11611161
boolean sendImmediately = false;
11621162
synchronized (streamLock) {
@@ -1173,7 +1173,7 @@ private void handleRequestBodyResponse(BodyResponse bodyResponse) {
11731173
trySendAccumulatedWindowUpdates();
11741174
}
11751175
}
1176-
if (streamed.getEndOfStream() || streamed.getEndOfStreamWithoutMessage()) {
1176+
if (isEndOfStream) {
11771177
synchronized (streamLock) {
11781178
if (pendingUpstreamBodyMessages.isEmpty()) {
11791179
if (requestSideClosed.compareAndSet(false, true)) {

0 commit comments

Comments
 (0)