Skip to content

Commit

Permalink
api: adds AllowModeOverride for extproc (#5099)
Browse files Browse the repository at this point in the history
* api: adds AllowModeOverride for extproc

Signed-off-by: Takeshi Yoneda <[email protected]>

* add test

Signed-off-by: Takeshi Yoneda <[email protected]>

* review: move it to inside processingMode

Signed-off-by: Takeshi Yoneda <[email protected]>

---------

Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Jan 21, 2025
1 parent 69d3e42 commit ebdba31
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/ext_proc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ type ExtProcProcessingMode struct {
//
// +optional
Response *ProcessingModeOptions `json:"response,omitempty"`

// AllowModeOverride allows the external processor to override the processing mode set via the
// `mode_override` field in the gRPC response message. This defaults to false.
//
// +optional
AllowModeOverride bool `json:"allowModeOverride,omitempty"`
}

// ExtProc defines the configuration for External Processing filter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,11 @@ spec:
ProcessingMode defines how request and response body is processed
Default: header and body are not sent to the external processor
properties:
allowModeOverride:
description: |-
AllowModeOverride allows the external processor to override the processing mode set via the
`mode_override` field in the gRPC response message. This defaults to false.
type: boolean
request:
description: |-
Defines processing mode for requests. If present, request headers are sent. Request body is processed according
Expand Down
1 change: 1 addition & 0 deletions internal/gatewayapi/envoyextensionpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ func (t *Translator) buildExtProc(
extProcIR.ResponseAttributes = append(extProcIR.ResponseAttributes, extProc.ProcessingMode.Response.Attributes...)
}
}
extProcIR.AllowModeOverride = extProc.ProcessingMode.AllowModeOverride
}

if extProc.Metadata != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ envoyExtensionPolicies:
Namespace: envoy-gateway
Port: 8000
processingMode:
allowModeOverride: true
request:
body: Buffered
attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ envoyExtensionPolicies:
writableNamespaces:
- envoy.filters.http.my_custom
processingMode:
allowModeOverride: true
request:
attributes:
- request.path
Expand Down Expand Up @@ -357,7 +358,8 @@ xdsIR:
weight: 1
envoyExtensions:
extProcs:
- authority: grpc-backend.envoy-gateway:8000
- allowModeOverride: true
authority: grpc-backend.envoy-gateway:8000
destination:
name: envoyextensionpolicy/default/policy-for-gateway/extproc/0
settings:
Expand Down
3 changes: 3 additions & 0 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,9 @@ type ExtProc struct {

// ReceivingMetadataNamespaces are metadata namespaces updatable by external processor
ReceivingMetadataNamespaces []string `json:"receivingMetadataNamespaces,omitempty" yaml:"receivingMetadataNamespaces,omitempty"`

// AllowModeOverride allows the external processor to modify the processing mode.
AllowModeOverride bool `json:"allowModeOverride,omitempty" yaml:"allowModeOverride,omitempty"`
}

// Wasm holds the information associated with the Wasm extensions.
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/extproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func extProcConfig(extProc ir.ExtProc) *extprocv3.ExternalProcessor {
}
}
}

config.AllowModeOverride = extProc.AllowModeOverride
return config
}

Expand Down
1 change: 1 addition & 0 deletions internal/xds/translator/testdata/in/xds-ir/ext-proc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ http:
responseAttributes:
- request.path
responseBodyProcessingMode: Streamed
allowModeOverride: true
authority: grpc-backend-4.default:4000
forwardingMetadataNamespaces:
- envoy.filters.http.ext_authz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
name: envoy.filters.http.ext_proc/envoyextensionpolicy/default/policy-for-route-2/extproc/0
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor
allowModeOverride: true
failureModeAllow: true
grpcService:
envoyGrpc:
Expand Down
1 change: 1 addition & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ _Appears in:_
| --- | --- | --- | --- | --- |
| `request` | _[ProcessingModeOptions](#processingmodeoptions)_ | false | | Defines processing mode for requests. If present, request headers are sent. Request body is processed according<br />to the specified mode. |
| `response` | _[ProcessingModeOptions](#processingmodeoptions)_ | false | | Defines processing mode for responses. If present, response headers are sent. Response body is processed according<br />to the specified mode. |
| `allowModeOverride` | _boolean_ | false | | AllowModeOverride allows the external processor to override the processing mode set via the<br />`mode_override` field in the gRPC response message. This defaults to false. |


#### ExtensionAPISettings
Expand Down
1 change: 1 addition & 0 deletions site/content/zh/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ _Appears in:_
| --- | --- | --- | --- | --- |
| `request` | _[ProcessingModeOptions](#processingmodeoptions)_ | false | | Defines processing mode for requests. If present, request headers are sent. Request body is processed according<br />to the specified mode. |
| `response` | _[ProcessingModeOptions](#processingmodeoptions)_ | false | | Defines processing mode for responses. If present, response headers are sent. Response body is processed according<br />to the specified mode. |
| `allowModeOverride` | _boolean_ | false | | AllowModeOverride allows the external processor to override the processing mode set via the<br />`mode_override` field in the gRPC response message. This defaults to false. |


#### ExtensionAPISettings
Expand Down

0 comments on commit ebdba31

Please sign in to comment.