Skip to content

Commit

Permalink
xds: refactor xdsServer wrapper, modify filter chain matching handler…
Browse files Browse the repository at this point in the history
… for server routing config (#8333)

This is split from #8318, refactoring changes include:
1. FilterChainMatchingHandler
1.1. Previously filter chain match is built-in in XdsServerCredential for xdsServer. (But it does not have to be XdsServerCredential.) The protocol negotiator associated with the XdsServerCredential does the filter chain match computation. Now filter chain match is through a FilterChainMatchingHandler and it always run. As a result, it sets attributes of sslContextProviderSupplier from xds config in protocol negotiation event.
1.2. The previous protocol negotiator associated with the XdsServerCredential is modified to just lookup the config in the attribute set above and decide to use xds config credential or fallback credential.
1.3. Previously credential is a must in XdsBuilder. Now credential becomes optional to allow routing config to be fetched. Xds TCP listener update will always be used to run filter chain match.
Later, we will add routing config in filter chain match and apply http filter configs by installing ConfigApplyingInterceptor.
2. Removed xdsClientWrapperForServerXds, unnecessarily complicated. 
3. Changed event attribute key. Previously filter chain matching happens in the xdsClientWrapperForServerXds, the xds client wrapper is passed to negotiation handler via attributes to allow protocol negotiator to trigger the filter chain matching computation.
Now the attributes becomes an atomic config selector reference that xdsServerWrapper will inject by watching xds resources updates via xds client.
4. Previously there are multiple server states enum in xdsServerWrapper, this is removed because it is unnecessarily complicated. But there are still isServing status to avoid re-start delegate upon listener update.
5. Previously xdsServerWrapper ignores any xds updates once initial started, now we allow dynamic update to happen even if server is up. This is done via updating config selector atomic reference upon listener update.
6. Previously xdsServerWrapper synchronizes on the server object, this is modified to syncContext to be more manageable.
  • Loading branch information
YifeiZhuang committed Aug 9, 2021
1 parent cbda32a commit bb06739
Show file tree
Hide file tree
Showing 18 changed files with 3,207 additions and 2,590 deletions.
2 changes: 1 addition & 1 deletion xds/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ javadoc {
exclude 'io/grpc/xds/*LoadBalancer*'
exclude 'io/grpc/xds/Bootstrapper.java'
exclude 'io/grpc/xds/Envoy*'
exclude 'io/grpc/xds/FilterChainMatchingProtocolNegotiators.java'
exclude 'io/grpc/xds/TlsContextManager.java'
exclude 'io/grpc/xds/XdsAttributes.java'
exclude 'io/grpc/xds/XdsClientWrapperForServerSds.java'
exclude 'io/grpc/xds/XdsInitializationException.java'
exclude 'io/grpc/xds/XdsNameResolverProvider.java'
exclude 'io/grpc/xds/internal/**'
Expand Down
2 changes: 1 addition & 1 deletion xds/src/main/java/io/grpc/xds/EnvoyServerProtoData.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public String toString() {
/**
* Corresponds to Envoy proto message {@link io.envoyproxy.envoy.api.v2.listener.FilterChain}.
*/
public static final class FilterChain {
static final class FilterChain {
// Unique name for the FilterChain.
private final String name;
// TODO(sanjaypujare): flatten structure by moving FilterChainMatch class members here.
Expand Down

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions xds/src/main/java/io/grpc/xds/InternalXdsAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import io.grpc.Internal;
import io.grpc.NameResolver;
import io.grpc.internal.ObjectPool;
import io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector;
import io.grpc.xds.XdsNameResolverProvider.CallCounterProvider;
import io.grpc.xds.internal.sds.SslContextProviderSupplier;
import java.util.concurrent.atomic.AtomicReference;

/**
* Internal attributes used for xDS implementation. Do not use.
Expand Down Expand Up @@ -75,5 +77,13 @@ public final class InternalXdsAttributes {
static final Attributes.Key<Long> ATTR_SERVER_WEIGHT =
Attributes.Key.create("io.grpc.xds.InternalXdsAttributes.serverWeight");

/**
* Filter chain match for network filters.
*/
@Grpc.TransportAttr
static final Attributes.Key<AtomicReference<FilterChainSelector>>
ATTR_FILTER_CHAIN_SELECTOR_REF = Attributes.Key.create(
"io.grpc.xds.InternalXdsAttributes.filterChainSelectorRef");

private InternalXdsAttributes() {}
}

0 comments on commit bb06739

Please sign in to comment.