Skip to content

Commit a85b38f

Browse files
authored
Revert "xds: xDS-based HTTP CONNECT configuration (#12099)" (#12120)
This reverts commit 7776d37.
1 parent 80ea4e9 commit a85b38f

16 files changed

+220
-665
lines changed

xds/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ java_proto_library(
8585
"@envoy_api//envoy/extensions/load_balancing_policies/ring_hash/v3:pkg",
8686
"@envoy_api//envoy/extensions/load_balancing_policies/round_robin/v3:pkg",
8787
"@envoy_api//envoy/extensions/load_balancing_policies/wrr_locality/v3:pkg",
88-
"@envoy_api//envoy/extensions/transport_sockets/http_11_proxy/v3:pkg",
8988
"@envoy_api//envoy/extensions/transport_sockets/tls/v3:pkg",
9089
"@envoy_api//envoy/service/discovery/v3:pkg",
9190
"@envoy_api//envoy/service/load_stats/v3:pkg",

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ private void handleClusterDiscovered() {
243243
}
244244

245245
ClusterResolverConfig config = new ClusterResolverConfig(
246-
Collections.unmodifiableList(instances),
247-
configOrError.getConfig(),
248-
root.result.isHttp11ProxyAvailable());
246+
Collections.unmodifiableList(instances), configOrError.getConfig());
249247
if (childLb == null) {
250248
childLb = lbRegistry.getProvider(CLUSTER_RESOLVER_POLICY_NAME).newLoadBalancer(helper);
251249
}

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

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.protobuf.Struct;
2626
import io.grpc.Attributes;
2727
import io.grpc.EquivalentAddressGroup;
28-
import io.grpc.HttpConnectProxiedSocketAddress;
2928
import io.grpc.InternalLogId;
3029
import io.grpc.LoadBalancer;
3130
import io.grpc.LoadBalancerProvider;
@@ -61,8 +60,6 @@
6160
import io.grpc.xds.client.XdsClient.ResourceWatcher;
6261
import io.grpc.xds.client.XdsLogger;
6362
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
64-
import java.net.InetSocketAddress;
65-
import java.net.SocketAddress;
6663
import java.net.URI;
6764
import java.net.URISyntaxException;
6865
import java.util.ArrayList;
@@ -434,18 +431,8 @@ public void run() {
434431
.set(XdsAttributes.ATTR_SERVER_WEIGHT, weight)
435432
.set(XdsAttributes.ATTR_ADDRESS_NAME, endpoint.hostname())
436433
.build();
437-
438-
EquivalentAddressGroup eag;
439-
if (config.isHttp11ProxyAvailable()) {
440-
List<SocketAddress> rewrittenAddresses = new ArrayList<>();
441-
for (SocketAddress addr : endpoint.eag().getAddresses()) {
442-
rewrittenAddresses.add(rewriteAddress(
443-
addr, endpoint.endpointMetadata(), localityLbInfo.localityMetadata()));
444-
}
445-
eag = new EquivalentAddressGroup(rewrittenAddresses, attr);
446-
} else {
447-
eag = new EquivalentAddressGroup(endpoint.eag().getAddresses(), attr);
448-
}
434+
EquivalentAddressGroup eag = new EquivalentAddressGroup(
435+
endpoint.eag().getAddresses(), attr);
449436
eag = AddressFilter.setPathFilter(eag, Arrays.asList(priorityName, localityName));
450437
addresses.add(eag);
451438
}
@@ -483,35 +470,6 @@ public void run() {
483470
new EndpointsUpdated().run();
484471
}
485472

486-
private SocketAddress rewriteAddress(SocketAddress addr,
487-
ImmutableMap<String, Object> endpointMetadata,
488-
ImmutableMap<String, Object> localityMetadata) {
489-
if (!(addr instanceof InetSocketAddress)) {
490-
return addr;
491-
}
492-
493-
SocketAddress proxyAddress;
494-
try {
495-
proxyAddress = (SocketAddress) endpointMetadata.get(
496-
"envoy.http11_proxy_transport_socket.proxy_address");
497-
if (proxyAddress == null) {
498-
proxyAddress = (SocketAddress) localityMetadata.get(
499-
"envoy.http11_proxy_transport_socket.proxy_address");
500-
}
501-
} catch (ClassCastException e) {
502-
return addr;
503-
}
504-
505-
if (proxyAddress == null) {
506-
return addr;
507-
}
508-
509-
return HttpConnectProxiedSocketAddress.newBuilder()
510-
.setTargetAddress((InetSocketAddress) addr)
511-
.setProxyAddress(proxyAddress)
512-
.build();
513-
}
514-
515473
private List<String> generatePriorityNames(String name,
516474
Map<Locality, LocalityLbEndpoints> localityLbEndpoints) {
517475
TreeMap<Integer, List<Locality>> todo = new TreeMap<>();

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,10 @@ static final class ClusterResolverConfig {
7474
final List<DiscoveryMechanism> discoveryMechanisms;
7575
// GracefulSwitch configuration
7676
final Object lbConfig;
77-
private final boolean isHttp11ProxyAvailable;
7877

79-
ClusterResolverConfig(List<DiscoveryMechanism> discoveryMechanisms, Object lbConfig,
80-
boolean isHttp11ProxyAvailable) {
78+
ClusterResolverConfig(List<DiscoveryMechanism> discoveryMechanisms, Object lbConfig) {
8179
this.discoveryMechanisms = checkNotNull(discoveryMechanisms, "discoveryMechanisms");
8280
this.lbConfig = checkNotNull(lbConfig, "lbConfig");
83-
this.isHttp11ProxyAvailable = isHttp11ProxyAvailable;
84-
}
85-
86-
boolean isHttp11ProxyAvailable() {
87-
return isHttp11ProxyAvailable;
8881
}
8982

9083
@Override

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.auto.value.AutoValue;
2222
import com.google.common.annotations.VisibleForTesting;
2323
import com.google.common.collect.ImmutableList;
24-
import com.google.common.collect.ImmutableMap;
2524
import io.grpc.EquivalentAddressGroup;
2625
import java.net.InetSocketAddress;
2726
import java.util.List;
@@ -42,13 +41,11 @@ abstract static class LocalityLbEndpoints {
4241
// Locality's priority level.
4342
abstract int priority();
4443

45-
abstract ImmutableMap<String, Object> localityMetadata();
46-
4744
static LocalityLbEndpoints create(List<LbEndpoint> endpoints, int localityWeight,
48-
int priority, ImmutableMap<String, Object> localityMetadata) {
45+
int priority) {
4946
checkArgument(localityWeight > 0, "localityWeight must be greater than 0");
5047
return new AutoValue_Endpoints_LocalityLbEndpoints(
51-
ImmutableList.copyOf(endpoints), localityWeight, priority, localityMetadata);
48+
ImmutableList.copyOf(endpoints), localityWeight, priority);
5249
}
5350
}
5451

@@ -66,20 +63,17 @@ abstract static class LbEndpoint {
6663

6764
abstract String hostname();
6865

69-
abstract ImmutableMap<String, Object> endpointMetadata();
70-
7166
static LbEndpoint create(EquivalentAddressGroup eag, int loadBalancingWeight,
72-
boolean isHealthy, String hostname, ImmutableMap<String, Object> endpointMetadata) {
73-
return new AutoValue_Endpoints_LbEndpoint(
74-
eag, loadBalancingWeight, isHealthy, hostname, endpointMetadata);
67+
boolean isHealthy, String hostname) {
68+
return new AutoValue_Endpoints_LbEndpoint(eag, loadBalancingWeight, isHealthy, hostname);
7569
}
7670

7771
// Only for testing.
7872
@VisibleForTesting
79-
static LbEndpoint create(String address, int port, int loadBalancingWeight, boolean isHealthy,
80-
String hostname, ImmutableMap<String, Object> endpointMetadata) {
73+
static LbEndpoint create(
74+
String address, int port, int loadBalancingWeight, boolean isHealthy, String hostname) {
8175
return LbEndpoint.create(new EquivalentAddressGroup(new InetSocketAddress(address, port)),
82-
loadBalancingWeight, isHealthy, hostname, endpointMetadata);
76+
loadBalancingWeight, isHealthy, hostname);
8377
}
8478
}
8579

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import io.grpc.Status;
3737
import io.grpc.auth.MoreCallCredentials;
3838
import io.grpc.xds.MetadataRegistry.MetadataValueParser;
39-
import io.grpc.xds.client.XdsResourceType.ResourceInvalidException;
4039
import java.util.LinkedHashMap;
4140
import java.util.Map;
4241
import java.util.concurrent.ScheduledExecutorService;
@@ -241,16 +240,11 @@ public String getTypeUrl() {
241240
}
242241

243242
@Override
244-
public String parse(Any any) throws ResourceInvalidException {
245-
Audience audience;
246-
try {
247-
audience = any.unpack(Audience.class);
248-
} catch (InvalidProtocolBufferException ex) {
249-
throw new ResourceInvalidException("Invalid Resource in address proto", ex);
250-
}
243+
public String parse(Any any) throws InvalidProtocolBufferException {
244+
Audience audience = any.unpack(Audience.class);
251245
String url = audience.getUrl();
252246
if (url.isEmpty()) {
253-
throw new ResourceInvalidException(
247+
throw new InvalidProtocolBufferException(
254248
"Audience URL is empty. Metadata value must contain a valid URL.");
255249
}
256250
return url;

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

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
package io.grpc.xds;
1818

1919
import com.google.common.annotations.VisibleForTesting;
20-
import com.google.common.collect.ImmutableMap;
2120
import com.google.protobuf.Any;
22-
import com.google.protobuf.Struct;
23-
import io.envoyproxy.envoy.config.core.v3.Metadata;
21+
import com.google.protobuf.InvalidProtocolBufferException;
2422
import io.grpc.xds.GcpAuthenticationFilter.AudienceMetadataParser;
25-
import io.grpc.xds.XdsEndpointResource.AddressMetadataParser;
26-
import io.grpc.xds.client.XdsResourceType.ResourceInvalidException;
27-
import io.grpc.xds.internal.ProtobufJsonConverter;
2823
import java.util.HashMap;
2924
import java.util.Map;
3025

@@ -41,7 +36,6 @@ final class MetadataRegistry {
4136

4237
private MetadataRegistry() {
4338
registerParser(new AudienceMetadataParser());
44-
registerParser(new AddressMetadataParser());
4539
}
4640

4741
static MetadataRegistry getInstance() {
@@ -61,54 +55,6 @@ void removeParser(MetadataValueParser parser) {
6155
supportedParsers.remove(parser.getTypeUrl());
6256
}
6357

64-
/**
65-
* Parses cluster metadata into a structured map.
66-
*
67-
* <p>Values in {@code typed_filter_metadata} take precedence over
68-
* {@code filter_metadata} when keys overlap, following Envoy API behavior. See
69-
* <a href="https://github.com/envoyproxy/envoy/blob/main/api/envoy/config/core/v3/base.proto#L217-L259">
70-
* Envoy metadata documentation </a> for details.
71-
*
72-
* @param metadata the {@link Metadata} containing the fields to parse.
73-
* @return an immutable map of parsed metadata.
74-
* @throws ResourceInvalidException if parsing {@code typed_filter_metadata} fails.
75-
*/
76-
public ImmutableMap<String, Object> parseMetadata(Metadata metadata)
77-
throws ResourceInvalidException {
78-
ImmutableMap.Builder<String, Object> parsedMetadata = ImmutableMap.builder();
79-
80-
// Process typed_filter_metadata
81-
for (Map.Entry<String, Any> entry : metadata.getTypedFilterMetadataMap().entrySet()) {
82-
String key = entry.getKey();
83-
Any value = entry.getValue();
84-
MetadataValueParser parser = findParser(value.getTypeUrl());
85-
if (parser != null) {
86-
try {
87-
Object parsedValue = parser.parse(value);
88-
parsedMetadata.put(key, parsedValue);
89-
} catch (ResourceInvalidException e) {
90-
throw new ResourceInvalidException(
91-
String.format("Failed to parse metadata key: %s, type: %s. Error: %s",
92-
key, value.getTypeUrl(), e.getMessage()), e);
93-
}
94-
}
95-
}
96-
// building once to reuse in the next loop
97-
ImmutableMap<String, Object> intermediateParsedMetadata = parsedMetadata.build();
98-
99-
// Process filter_metadata for remaining keys
100-
for (Map.Entry<String, Struct> entry : metadata.getFilterMetadataMap().entrySet()) {
101-
String key = entry.getKey();
102-
if (!intermediateParsedMetadata.containsKey(key)) {
103-
Struct structValue = entry.getValue();
104-
Object jsonValue = ProtobufJsonConverter.convertToJson(structValue);
105-
parsedMetadata.put(key, jsonValue);
106-
}
107-
}
108-
109-
return parsedMetadata.build();
110-
}
111-
11258
interface MetadataValueParser {
11359

11460
String getTypeUrl();
@@ -118,8 +64,8 @@ interface MetadataValueParser {
11864
*
11965
* @param any the {@link Any} object to parse.
12066
* @return the parsed metadata value.
121-
* @throws ResourceInvalidException if the parsing fails.
67+
* @throws InvalidProtocolBufferException if the parsing fails.
12268
*/
123-
Object parse(Any any) throws ResourceInvalidException;
69+
Object parse(Any any) throws InvalidProtocolBufferException;
12470
}
12571
}

0 commit comments

Comments
 (0)