-
Notifications
You must be signed in to change notification settings - Fork 4k
xds: Add composite filter #12646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
xds: Add composite filter #12646
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,15 @@ | |
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import com.google.protobuf.Struct; | ||
| import io.grpc.Attributes; | ||
| import io.grpc.EquivalentAddressGroup; | ||
| import io.grpc.Grpc; | ||
| import io.grpc.NameResolver; | ||
| import io.grpc.xds.XdsNameResolverProvider.CallCounterProvider; | ||
| import io.grpc.xds.client.Locality; | ||
| import io.grpc.xds.client.XdsClient; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Attributes used for xDS implementation. | ||
|
|
@@ -100,5 +102,18 @@ final class XdsAttributes { | |
| static final Attributes.Key<Long> ATTR_DRAIN_GRACE_NANOS = | ||
| Attributes.Key.create("io.grpc.xds.XdsAttributes.drainGraceTime"); | ||
|
|
||
| /** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the usages for these newly added attributes in code, but I can see for others. Is there something I am missing here or will something be added in followup PRs? |
||
| * Attribute key for xDS route metadata used in filter matching. | ||
| */ | ||
| @NameResolver.ResolutionResultAttr | ||
| public static final Attributes.Key<Map<String, Struct>> ATTR_FILTER_METADATA = Attributes.Key | ||
| .create("io.grpc.xds.XdsAttributes.filterMetadata"); | ||
|
|
||
| /** | ||
| * CallOptions key for xDS route metadata used in filter matching. | ||
| */ | ||
| public static final io.grpc.CallOptions.Key<Map<String, Struct>> CALL_OPTIONS_FILTER_METADATA = | ||
| io.grpc.CallOptions.Key.create("io.grpc.xds.XdsAttributes.filterMetadata"); | ||
|
|
||
| private XdsAttributes() {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,7 +230,7 @@ static FilterChain parseFilterChain( | |
| // FilterChain contains L4 filters, so we ensure it contains only HCM. | ||
| if (proto.getFiltersCount() != 1) { | ||
| throw new ResourceInvalidException("FilterChain " + filterChainName | ||
| + " should contain exact one HttpConnectionManager filter"); | ||
| + " should contain exactly one HttpConnectionManager filter"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Okay for now. But it's usually better to move small unrelated changes into a separate PR. |
||
| } | ||
| io.envoyproxy.envoy.config.listener.v3.Filter l4Filter = proto.getFiltersList().get(0); | ||
| if (!l4Filter.hasTypedConfig()) { | ||
|
|
@@ -513,6 +513,7 @@ static io.grpc.xds.HttpConnectionManager parseHttpConnectionManager( | |
| } | ||
|
|
||
| // Parse http filters. | ||
| // todo: AgraVator are we changing the assumption here ?? | ||
| if (proto.getHttpFiltersList().isEmpty()) { | ||
| throw new ResourceInvalidException("Missing HttpFilter in HttpConnectionManager."); | ||
| } | ||
|
Comment on lines
516
to
518
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping this the same, assuming we will still be getting Filters here and not all through ExtensionWithMatcherPerRoute |
||
|
|
@@ -582,6 +583,7 @@ private static boolean isTerminalFilter(Filter.FilterConfig filterConfig) { | |
| static StructOrError<Filter.FilterConfig> parseHttpFilter( | ||
| io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter | ||
| httpFilter, FilterRegistry filterRegistry, boolean isForClient) { | ||
| // todo: AgraVator do we need to change anything here for composite filter ?? | ||
| String filterName = httpFilter.getName(); | ||
| boolean isOptional = httpFilter.getIsOptional(); | ||
| if (!httpFilter.hasTypedConfig()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,7 @@ private void updateResolutionResult(XdsConfig xdsConfig) { | |
| .setAttributes(attrs) | ||
| .setServiceConfig(parsedServiceConfig) | ||
| .build(); | ||
| // todo: abhishek probably the filters are getting applied here ?? | ||
| if (!listener.onResult2(result).isOk()) { | ||
| resolveState.xdsDependencyManager.requestReresolution(); | ||
| } | ||
|
|
@@ -404,6 +405,7 @@ static boolean matchHostName(String hostName, String pattern) { | |
| private final class ConfigSelector extends InternalConfigSelector { | ||
| @Override | ||
| public Result selectConfig(PickSubchannelArgs args) { | ||
| // todo: AgraVator probably the filters are getting populated here | ||
| RoutingConfig routingCfg; | ||
| RouteData selectedRoute; | ||
| String cluster; | ||
|
|
@@ -716,6 +718,7 @@ public void onUpdate(StatusOr<XdsConfig> updateOrStatus) { | |
| } | ||
|
|
||
| VirtualHost virtualHost = update.getVirtualHost(); | ||
| // filters and there configurations | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change relevant? |
||
| ImmutableList<NamedFilterConfig> filterConfigs = httpConnectionManager.httpFilterConfigs(); | ||
| long streamDurationNano = httpConnectionManager.httpMaxStreamDurationNano(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,4 +97,26 @@ public static Matchers.StringMatcher parseStringMatcher( | |
| "Unknown StringMatcher match pattern: " + proto.getMatchPatternCase()); | ||
| } | ||
| } | ||
|
|
||
| /** Translate StringMatcher xDS proto to internal StringMatcher. */ | ||
| public static Matchers.StringMatcher parseStringMatcher( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stringMatcher parsing logic should not be in this PR. It will be covered by A106. You then need to just modify add the |
||
| com.github.xds.type.matcher.v3.StringMatcher proto) { | ||
| switch (proto.getMatchPatternCase()) { | ||
| case EXACT: | ||
| return Matchers.StringMatcher.forExact(proto.getExact(), proto.getIgnoreCase()); | ||
| case PREFIX: | ||
| return Matchers.StringMatcher.forPrefix(proto.getPrefix(), proto.getIgnoreCase()); | ||
| case SUFFIX: | ||
| return Matchers.StringMatcher.forSuffix(proto.getSuffix(), proto.getIgnoreCase()); | ||
| case SAFE_REGEX: | ||
| return Matchers.StringMatcher.forSafeRegEx( | ||
| Pattern.compile(proto.getSafeRegex().getRegex())); | ||
| case CONTAINS: | ||
| return Matchers.StringMatcher.forContains(proto.getContains()); | ||
| case MATCHPATTERN_NOT_SET: | ||
| default: | ||
| throw new IllegalArgumentException( | ||
| "Unknown StringMatcher match pattern: " + proto.getMatchPatternCase()); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go/java-practices/null#collection
Is there a semantic difference between a null
filterMetadataand emptyfilterMetadata?