Skip to content

xds: CEL implementation#12770

Open
shivaspeaks wants to merge 2 commits intogrpc:masterfrom
shivaspeaks:cel
Open

xds: CEL implementation#12770
shivaspeaks wants to merge 2 commits intogrpc:masterfrom
shivaspeaks:cel

Conversation

@shivaspeaks
Copy link
Copy Markdown
Member

@shivaspeaks shivaspeaks commented Apr 22, 2026

This PR contains the core CEL evaluation logic and gRPC environment setup as defined in gRFC A106.

This is being carved out from #12640

@shivaspeaks
Copy link
Copy Markdown
Member Author

Pasting @AgraVator's comment here from #12640 (comment):

To support future attributes beyond just headers (like the aforementioned transport info or cluster metadata), we might want to consider a more pluggable way to populate MatchContext.

Currently, it has a fixed set of fields. A map-based approach or a registry of attribute providers might make it easier to add new attributes without changing the core MatchContext class every time.

@kannanjgithub
Copy link
Copy Markdown
Contributor

Currently, it has a fixed set of fields. A map-based approach or a registry of attribute providers might make it easier to add new attributes without changing the core MatchContext class every time.

I don't see what benefit is there in having a different class for each attribute like referer or user-agent. The list of Envoy request attributes is fixed and there is never a need to have some of them provided and other not.

Rather than think in terms of organizing our code in terms of plugin, we should think in terms of providing the evaluation context for the Cel runtime. With A106 supporting only request attributes for now we have this in GrpcCelEnvironment:

  @Override
  public Optional<Object> find(String name) {
    if (name.equals("request")) {
      return Optional.of(new LazyRequestMap(this));
    }
    return Optional.empty();
  }

that provides a map to Cel runtime for evaluating request.* variables. That map is backed by MatchContext (earlier implementation) that only knows about returning values for request.* keys. There is no need to further granularize how MatchContext implements that. One switch-case block will do.
Then for future unified matcher requirements you would check if name.equals("connection") and return a different map backed by something other than MatchContext. At that point we could may be rename MatchContext to RequestMatchContext and have a different one say ConnectionMatchContext the LazyRequestMap for connection variable evaluation uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants