Problem
The in-process resolver of the flagd provider opens a long-lived gRPC stream. It calls the SyncFlags method. The provider builds the gRPC metadata for this call. The function _create_metadata adds only one header. It adds the flagd-selector header. It adds this header only when the user sets a selector.
The provider gives the user no way to add other metadata headers. The Config object has no field for custom metadata. The user cannot add a header to the sync stream.
Effect
A user cannot send an infrastructure-specific header on the sync stream. One example is a proxy timeout header. A proxy can close a stream after a default request timeout. To keep the stream open, the client must send a header such as x-envoy-upstream-rq-timeout-ms: 0. The current provider cannot send this header. Because of this, a proxy can close the long-lived sync stream.
Proposed change
- Add a
sync_metadata option to FlagdProvider and to Config. The value is a sequence of key-value pairs (header name and header value).
- In
_create_metadata, add these pairs to the metadata. Keep the flagd-selector header. Send both the selector header and the user headers together.
- Keep the current behavior when the user does not set
sync_metadata. If the user sets no selector and no custom metadata, the function returns no metadata, as before.
Compatibility
The change is backward compatible. The custom metadata is added only when the user sets sync_metadata. The default behavior does not change.
Scope
The change is small. It touches config.py, provider.py, and grpc_watcher.py. It affects only the in-process resolver, because only that resolver uses the SyncFlags metadata function.
Problem
The in-process resolver of the flagd provider opens a long-lived gRPC stream. It calls the
SyncFlagsmethod. The provider builds the gRPC metadata for this call. The function_create_metadataadds only one header. It adds theflagd-selectorheader. It adds this header only when the user sets a selector.The provider gives the user no way to add other metadata headers. The
Configobject has no field for custom metadata. The user cannot add a header to the sync stream.Effect
A user cannot send an infrastructure-specific header on the sync stream. One example is a proxy timeout header. A proxy can close a stream after a default request timeout. To keep the stream open, the client must send a header such as
x-envoy-upstream-rq-timeout-ms: 0. The current provider cannot send this header. Because of this, a proxy can close the long-lived sync stream.Proposed change
sync_metadataoption toFlagdProviderand toConfig. The value is a sequence of key-value pairs (header name and header value)._create_metadata, add these pairs to the metadata. Keep theflagd-selectorheader. Send both the selector header and the user headers together.sync_metadata. If the user sets no selector and no custom metadata, the function returns no metadata, as before.Compatibility
The change is backward compatible. The custom metadata is added only when the user sets
sync_metadata. The default behavior does not change.Scope
The change is small. It touches
config.py,provider.py, andgrpc_watcher.py. It affects only the in-process resolver, because only that resolver uses theSyncFlagsmetadata function.