Skip to content

Commit

Permalink
ext_proc: send and receive dynamic metadata (envoyproxy#30747)
Browse files Browse the repository at this point in the history
Introduce the ability to send dynamic metadata in the External Processing Request. Also implements the API for returning dynamic metadata as part of the External Processing Response.

---------

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
  • Loading branch information
jbohanon committed Mar 1, 2024
1 parent 5c630d2 commit 318a915
Show file tree
Hide file tree
Showing 12 changed files with 1,106 additions and 29 deletions.
41 changes: 38 additions & 3 deletions api/envoy/extensions/filters/http/ext_proc/v3/ext_proc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
// **Current Implementation Status:**
// All options and processing modes are implemented except for the following:
//
// * Dynamic metadata in responses from the external processor is ignored.
// * "async mode" is not implemented.

// The filter communicates with an external gRPC service called an "external processor"
Expand Down Expand Up @@ -97,7 +96,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
// <arch_overview_advanced_filter_state_sharing>` object in a namespace matching the filter
// name.
//
// [#next-free-field: 16]
// [#next-free-field: 17]
message ExternalProcessor {
// Configuration for the gRPC service that the filter will communicate with.
// The filter supports both the "Envoy" and "Google" gRPC clients.
Expand Down Expand Up @@ -203,6 +202,35 @@ message ExternalProcessor {
// Instead, the stream to the external processor will be closed. There will be no
// more external processing for this stream from now on.
bool disable_immediate_response = 15;

// Options related to the sending and receiving of dynamic metadata.
MetadataOptions metadata_options = 16;
}

// The MetadataOptions structure defines options for the sending and receiving of
// dynamic metadata. Specifically, which namespaces to send to the server, whether
// metadata returned by the server may be written, and how that metadata may be written.
message MetadataOptions {
message MetadataNamespaces {
// Specifies a list of metadata namespaces whose values, if present,
// will be passed to the ext_proc service as an opaque *protobuf::Struct*.
repeated string untyped = 1;

// Specifies a list of metadata namespaces whose values, if present,
// will be passed to the ext_proc service as a *protobuf::Any*. This allows
// envoy and the external processing server to share the protobuf message
// definition for safe parsing.
repeated string typed = 2;
}

// Describes which typed or untyped dynamic metadata namespaces to forward to
// the external processing server.
MetadataNamespaces forwarding_namespaces = 1;

// Describes which typed or untyped dynamic metadata namespaces to accept from
// the external processing server. Set to empty or leave unset to disallow writing
// any received dynamic metadata. Receiving of typed metadata is not supported.
MetadataNamespaces receiving_namespaces = 2;
}

// The HeaderForwardingRules structure specifies what headers are
Expand Down Expand Up @@ -245,7 +273,7 @@ message ExtProcPerRoute {
}

// Overrides that may be set on a per-route basis
// [#next-free-field: 6]
// [#next-free-field: 7]
message ExtProcOverrides {
// Set a different processing mode for this route than the default.
ProcessingMode processing_mode = 1;
Expand All @@ -266,4 +294,11 @@ message ExtProcOverrides {

// Set a different gRPC service for this route than the default.
config.core.v3.GrpcService grpc_service = 5;

// Options related to the sending and receiving of dynamic metadata.
// Lists of forwarding and receiving namespaces will be overridden in their entirety,
// meaning the most-specific config that specifies this override will be the final
// config used. It is the prerogative of the control plane to ensure this
// most-specific config contains the correct final overrides.
MetadataOptions metadata_options = 6;
}
11 changes: 7 additions & 4 deletions api/envoy/service/ext_proc/v3/external_processor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ service ExternalProcessor {

// This represents the different types of messages that Envoy can send
// to an external processing server.
// [#next-free-field: 8]
// [#next-free-field: 9]
message ProcessingRequest {
// Specify whether the filter that sent this request is running in synchronous
// or asynchronous mode. The choice of synchronous or asynchronous mode
Expand Down Expand Up @@ -115,6 +115,9 @@ message ProcessingRequest {
// in the filter configuration.
HttpTrailers response_trailers = 7;
}

// Dynamic metadata associated with the request.
config.core.v3.Metadata metadata_context = 8;
}

// For every ProcessingRequest received by the server with the ``async_mode`` field
Expand Down Expand Up @@ -158,9 +161,9 @@ message ProcessingResponse {
ImmediateResponse immediate_response = 7;
}

// [#not-implemented-hide:]
// Optional metadata that will be emitted as dynamic metadata to be consumed by the next
// filter. This metadata will be placed in the namespace ``envoy.filters.http.ext_proc``.
// Optional metadata that will be emitted as dynamic metadata to be consumed by
// following filters. This metadata will be placed in the namespace(s) specified by the top-level
// field name(s) of the struct.
google.protobuf.Struct dynamic_metadata = 8;

// Override how parts of the HTTP request and response are processed
Expand Down
8 changes: 8 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ new_features:
and
:ref:`response_attributes <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.response_attributes>`
config APIs to enable sending and receiving attributes to/from the external processing server.
- area: ext_proc
change: |
added
:ref:`metadata_options <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.metadata_options>`
config API to enable sending and receiving metadata from/to the external processing server. Both typed and untyped dynamic
metadata may be sent to the server. If
:ref:`receiving_namespaces <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.MetadataOptions.receiving_namespaces>`
is defined, returned metadata may be written to the specified allowed namespaces.
deprecated:
Loading

0 comments on commit 318a915

Please sign in to comment.