Skip to content

Add Baggage metadata propagation#6776

Merged
istio-testing merged 5 commits into
istio:experimental-ambient-multicluster-telemetryfrom
keithmattix:ambient-mx-downstream-propagation
Jan 22, 2026
Merged

Add Baggage metadata propagation#6776
istio-testing merged 5 commits into
istio:experimental-ambient-multicluster-telemetryfrom
keithmattix:ambient-mx-downstream-propagation

Conversation

@keithmattix
Copy link
Copy Markdown
Contributor

@keithmattix keithmattix commented Jan 21, 2026

What this PR does / why we need it:
Enable baggage as a peer_metadata propagation method to upstream and downstream peers (via request and response headers respectively). Also add tests.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes istio/istio#58830. Also fixes the propagation part of istio/istio#58794.

Special notes for your reviewer:
I kept the old encoding for baggage; @krinkinmu @Stevenjin8 let me know if I need to move to something else for consistency. This does appear to be the format ztunnel uses, so I just went with it.

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
@keithmattix keithmattix requested review from a team, Stevenjin8 and grnmeira as code owners January 21, 2026 01:17
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 21, 2026
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
return absl::StrJoin(parts, ",");
}

void BaggagePropagationMethod::inject(const StreamInfo::StreamInfo&, Http::HeaderMap& headers,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so lost... where does this even get called. Is this for waypoints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's kind of confusing. There are N number of propagation methods and initialized in each instance of the filter. On the encodeHeaders and decodeHeaders callbacks, we call injectUpstream or injectDownstream which end up calling inject on the propagation method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more addition, we run peer metadata HTTP filter in two places actually:

  1. in connect_terminate listener for all the incoming connections (and that's where I'd imagine this new method will be used - to propagate waypoint metadata into response to let downstream know waypoint workload)
  2. in the main_internal listener - we probably will not configure this propagation method there, since we it would insert the baggage header into the actual user request instead of the HBONE CONNECT request.

{Istio::Common::AppNameToken, "app.name"},
{Istio::Common::AppVersionToken, "app.version"},
{Istio::Common::WorkloadNameToken, "k8s.workload.name"},
{Istio::Common::WorkloadTypeToken, "k8s.workload.type"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite right. This is how we format it in ztunnel

        "k8s.cluster.name={cluster},k8s.namespace.name={namespace},k8s.{workload_type}.name={workload_name},service.name={name},service.version={version},cloud.region={region},cloud.availability_zone={zone}",

emphasis on the k8s.{workload_type}.name={workload_name}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; we're also not adding topology info like region and availability zone. @krinkinmu, we should document all of the baggage fields we support and the format they should be encoded in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keithmattix updated the document - it shows all the baggage fields we support, how they are encoded and what is WDS Workload equivalent of those.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Stevenjin8 I think i've addressed this now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I might need to make ztunnel modifications? As is, the locality fields will always be unknown for cross cluster communication. But maybe that's ok?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good call on locality. I don't think we originally added them in proxies but we do seem to have it in local mode metadata. Let me see what I can do

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
@keithmattix
Copy link
Copy Markdown
Contributor Author

/test release-test-arm64

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
@istio-testing istio-testing merged commit 0794f72 into istio:experimental-ambient-multicluster-telemetry Jan 22, 2026
7 checks passed
keithmattix added a commit that referenced this pull request Jan 27, 2026
* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Go back to old baggage impl

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix baggage format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Actually use new baggage approach

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
istio-testing added a commit that referenced this pull request Jan 28, 2026
* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Use single match - creating multiple matches means that the later overrides the earlier

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Add Baggage metadata propagation (#6776)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Go back to old baggage impl

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix baggage format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Actually use new baggage approach

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Introduce new filters discovering peer metadata from baggage header (#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix BUILD formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting of C++ code

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Populate peer principal in the upstream workload metadata as well

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Support propagating baggage header to upstream and additional safety checks for upstream network filter

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Move peer_metadata filter proto config in the same directory

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix typo

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Baggage discovery (#6779)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Add locality to proxy metadata (#6780)

* Add locality to proxy metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Buildifier format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Rebase and fix some bugs

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Drop app labels from baggage and propagate principal (#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Keep backwards compatibility for app.service and app.version baggage fields

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix some test compilation errors

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Merge master branch and resolve merge conflicts properly (#6795)

* Automator: update envoy@ in istio/proxy@master (#6777)

* Automator: update envoy@ in istio/proxy@master (#6778)

* Don't do workload discovery for cross-network traffic (#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* One more tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Switch to debug for logging

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Automator: update envoy@ in istio/proxy@master (#6782)

* Automator: update envoy@ in istio/proxy@master (#6784)

* Automator: update go-control-plane in istio/proxy@master (#6786)

* Automator: update envoy@ in istio/proxy@master (#6787)

* Automator: update envoy@ in istio/proxy@master (#6788)

* update x-network header key (#6790)

Signed-off-by: Ian Rudie <ian.rudie@solo.io>

* Automator: update envoy@ in istio/proxy@master (#6794)

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Krinkin, Mike <mkrinkin@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
keithmattix added a commit to keithmattix/proxy that referenced this pull request Jan 28, 2026
* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (istio#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Use single match - creating multiple matches means that the later overrides the earlier

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Add Baggage metadata propagation (istio#6776)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Go back to old baggage impl

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix baggage format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Actually use new baggage approach

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Introduce new filters discovering peer metadata from baggage header (istio#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix BUILD formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting of C++ code

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Populate peer principal in the upstream workload metadata as well

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Support propagating baggage header to upstream and additional safety checks for upstream network filter

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Move peer_metadata filter proto config in the same directory

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix typo

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Baggage discovery (istio#6779)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Add locality to proxy metadata (istio#6780)

* Add locality to proxy metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Buildifier format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Rebase and fix some bugs

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Drop app labels from baggage and propagate principal (istio#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Keep backwards compatibility for app.service and app.version baggage fields

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix some test compilation errors

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Merge master branch and resolve merge conflicts properly (istio#6795)

* Automator: update envoy@ in istio/proxy@master (istio#6777)

* Automator: update envoy@ in istio/proxy@master (istio#6778)

* Don't do workload discovery for cross-network traffic (istio#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* One more tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Switch to debug for logging

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Automator: update envoy@ in istio/proxy@master (istio#6782)

* Automator: update envoy@ in istio/proxy@master (istio#6784)

* Automator: update go-control-plane in istio/proxy@master (istio#6786)

* Automator: update envoy@ in istio/proxy@master (istio#6787)

* Automator: update envoy@ in istio/proxy@master (istio#6788)

* update x-network header key (istio#6790)

Signed-off-by: Ian Rudie <ian.rudie@solo.io>

* Automator: update envoy@ in istio/proxy@master (istio#6794)

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Krinkin, Mike <mkrinkin@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
istio-testing added a commit that referenced this pull request Jan 28, 2026
* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch



* Use single match - creating multiple matches means that the later overrides the earlier



---------



* Add Baggage metadata propagation (#6776)

* Add Baggage metadata propagation



* clang-tidy



* Go back to old baggage impl



* Fix baggage format



* Actually use new baggage approach



---------



* Introduce new filters discovering peer metadata from baggage header (#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.



* Fix BUILD formatting



* Fix formatting of C++ code



* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.



* Populate peer principal in the upstream workload metadata as well



* Support propagating baggage header to upstream and additional safety checks for upstream network filter



* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery



* Move peer_metadata filter proto config in the same directory



* Fix typo



---------



* Baggage discovery (#6779)

* Add Baggage metadata propagation



* clang-tidy



* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------




* Add locality to proxy metadata (#6780)

* Add locality to proxy metadata



* Clang-tidy



* Buildifier format



* Rebase and fix some bugs



---------



* Drop app labels from baggage and propagate principal (#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.



* Keep backwards compatibility for app.service and app.version baggage fields



---------





* Fix some test compilation errors



* Merge master branch and resolve merge conflicts properly (#6795)

* Automator: update envoy@ in istio/proxy@master (#6777)

* Automator: update envoy@ in istio/proxy@master (#6778)

* Don't do workload discovery for cross-network traffic (#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata



* clang-tidy



* One more tidy



* Switch to debug for logging



---------



* Automator: update envoy@ in istio/proxy@master (#6782)

* Automator: update envoy@ in istio/proxy@master (#6784)

* Automator: update go-control-plane in istio/proxy@master (#6786)

* Automator: update envoy@ in istio/proxy@master (#6787)

* Automator: update envoy@ in istio/proxy@master (#6788)

* update x-network header key (#6790)



* Automator: update envoy@ in istio/proxy@master (#6794)

* Merge upstream/master and resolve merge conflicts



* Missed one



* Fixed a wrong one



---------








---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Krinkin, Mike <mkrinkin@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
istio-testing added a commit that referenced this pull request Jan 29, 2026
* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Use single match - creating multiple matches means that the later overrides the earlier

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Add Baggage metadata propagation (#6776)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Go back to old baggage impl

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix baggage format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Actually use new baggage approach

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Introduce new filters discovering peer metadata from baggage header (#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix BUILD formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting of C++ code

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Populate peer principal in the upstream workload metadata as well

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Support propagating baggage header to upstream and additional safety checks for upstream network filter

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Move peer_metadata filter proto config in the same directory

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix typo

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Baggage discovery (#6779)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Add locality to proxy metadata (#6780)

* Add locality to proxy metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Buildifier format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Rebase and fix some bugs

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Drop app labels from baggage and propagate principal (#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Keep backwards compatibility for app.service and app.version baggage fields

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix some test compilation errors

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Merge master branch and resolve merge conflicts properly (#6795)

* Automator: update envoy@ in istio/proxy@master (#6777)

* Automator: update envoy@ in istio/proxy@master (#6778)

* Don't do workload discovery for cross-network traffic (#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* One more tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Switch to debug for logging

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Automator: update envoy@ in istio/proxy@master (#6782)

* Automator: update envoy@ in istio/proxy@master (#6784)

* Automator: update go-control-plane in istio/proxy@master (#6786)

* Automator: update envoy@ in istio/proxy@master (#6787)

* Automator: update envoy@ in istio/proxy@master (#6788)

* update x-network header key (#6790)

Signed-off-by: Ian Rudie <ian.rudie@solo.io>

* Automator: update envoy@ in istio/proxy@master (#6794)

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>

* Add e2e test for proxy baggage-based metadata discovery + fixes

This adds an e2e test for new proxy filters that verifies both baggage
propagation as well as metrics that stats filter will generate.

I also made some changes to how we parse and generate baggage header.
Basically, WorkloadMetadataObject supports cases where app and service
might have different values. In xDS-based metadata discovery
implementation however app is always derived from the service name, at
least in ztunnel.

So there is a bit of a mismatch there. In practice this mismatch should
not matter, but purely hypothetically, if I didn't change the logic, we
could end up in a situation where waypoint node metadata is configured
in such a way that app is set, but service is not. And if that happens,
waypoint will generate a baggage, that ztunnels cannot interpret
correctly yet and it will result in metrics with unknown values.

I figured that I can rewrite code in a way that accounts for all corner
cases like that by making sure that:

1. When we parse baggage we set both app and service, and if any of
   those is not provided in the baggage, we use the other to backfill
2. When we generate baggage, we always generate service (because ztunnel
   needs it), and we generate app, if it's different from the service.

All-in-all, under normal circumstances in the baggage we will only have
service; if app is different from the service - we will add it to the
baggage as well; and when parsing baggage we will use either service or
app, depending on what is provided.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
krinkinmu added a commit to krinkinmu/proxy that referenced this pull request Jan 29, 2026
…o#6798)

* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (istio#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Use single match - creating multiple matches means that the later overrides the earlier

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Add Baggage metadata propagation (istio#6776)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Go back to old baggage impl

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix baggage format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Actually use new baggage approach

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Introduce new filters discovering peer metadata from baggage header (istio#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix BUILD formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting of C++ code

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Populate peer principal in the upstream workload metadata as well

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Support propagating baggage header to upstream and additional safety checks for upstream network filter

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Move peer_metadata filter proto config in the same directory

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix typo

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Baggage discovery (istio#6779)

* Add Baggage metadata propagation

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Add locality to proxy metadata (istio#6780)

* Add locality to proxy metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Buildifier format

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Rebase and fix some bugs

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Drop app labels from baggage and propagate principal (istio#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Keep backwards compatibility for app.service and app.version baggage fields

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>

* Fix some test compilation errors

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Merge master branch and resolve merge conflicts properly (istio#6795)

* Automator: update envoy@ in istio/proxy@master (istio#6777)

* Automator: update envoy@ in istio/proxy@master (istio#6778)

* Don't do workload discovery for cross-network traffic (istio#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* clang-tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* One more tidy

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Switch to debug for logging

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Automator: update envoy@ in istio/proxy@master (istio#6782)

* Automator: update envoy@ in istio/proxy@master (istio#6784)

* Automator: update go-control-plane in istio/proxy@master (istio#6786)

* Automator: update envoy@ in istio/proxy@master (istio#6787)

* Automator: update envoy@ in istio/proxy@master (istio#6788)

* update x-network header key (istio#6790)

Signed-off-by: Ian Rudie <ian.rudie@solo.io>

* Automator: update envoy@ in istio/proxy@master (istio#6794)

* Merge upstream/master and resolve merge conflicts

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Missed one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fixed a wrong one

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>

* Add e2e test for proxy baggage-based metadata discovery + fixes

This adds an e2e test for new proxy filters that verifies both baggage
propagation as well as metrics that stats filter will generate.

I also made some changes to how we parse and generate baggage header.
Basically, WorkloadMetadataObject supports cases where app and service
might have different values. In xDS-based metadata discovery
implementation however app is always derived from the service name, at
least in ztunnel.

So there is a bit of a mismatch there. In practice this mismatch should
not matter, but purely hypothetically, if I didn't change the logic, we
could end up in a situation where waypoint node metadata is configured
in such a way that app is set, but service is not. And if that happens,
waypoint will generate a baggage, that ztunnels cannot interpret
correctly yet and it will result in metrics with unknown values.

I figured that I can rewrite code in a way that accounts for all corner
cases like that by making sure that:

1. When we parse baggage we set both app and service, and if any of
   those is not provided in the baggage, we use the other to backfill
2. When we generate baggage, we always generate service (because ztunnel
   needs it), and we generate app, if it's different from the service.

All-in-all, under normal circumstances in the baggage we will only have
service; if app is different from the service - we will add it to the
baggage as well; and when parsing baggage we will use either service or
app, depending on what is provided.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

* Fix formatting

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
istio-testing added a commit that referenced this pull request Feb 27, 2026
… (#6802)

* Include myself, Steven and Gustavo as owners of the experimental-ambient-multicluster-telemetry branch (#6772)

* Include myself, Steven and Gustavo as owners of the
experimental-ambient-multicluster-telemetry branch



* Use single match - creating multiple matches means that the later overrides the earlier



---------



* Add Baggage metadata propagation (#6776)

* Add Baggage metadata propagation



* clang-tidy



* Go back to old baggage impl



* Fix baggage format



* Actually use new baggage approach



---------



* Introduce new filters discovering peer metadata from baggage header (#6771)

* Introduce new filters discovering peer metadata from baggage header

This a combination of two filters that have to be used together:
- regular network filter (expected to be configured in connect_originate
  or inner_connect_originate listeners before TCP Proxy filter)
- upstream network filter (expected to be configuration in all clusters
  that use HBONE or double-HBONE for endpoints)

Those two filters together basically create a tunnel. The tunnel
protocol just prepends a fixed size header to data stream coming from
regular network filter to the upstream network filter, followed by the
peer metadatra encoded as protobuf Any containing a protobuf Struct
inside (I'm just re-using existing code from Istio proxy, that's why
encoding is such as it is).

The regular network filter only triggers when there is some data coming
from upstream connection in response. It's not correct in general, but
in waypoints we do know that we proxy an L7 protocol (http or gRPC), so
we do expect a some data in reply.

The regular network filter relies on TCP Proxy filter extracting
response headers and saving them in the filter state. It then extracts
and parses the baggage header from the saved headers.

In all cases I explicitly communicate when no peer metadata has been
discovered by sending some data downstream. This ensures that upstream
network filter running downstream can always remove the prefix from the
data stream and does not really need to guess if it's there or not.

NOTE: We still do some checks to confirm that the prefix is there, but
we cannot really rely on those checks for correctness in all the cases.

The upstream network filter, as pointed out above, extracts the data
sent by the regular network filter from the data stream, it parses the
data and populates filter state based on that.

Unlike the HTTP peer metadata filter, this one runs in the context of
the upstream connection, so it populates the upstream filter state and
not the regular one.

I plan to add support to the HTTP peer metadata filter option for new
upstream metadata discovery via upstream filter metadata, thus
propagating it all the way to the istio stats filter.

NOTE: None of those filters are yet generated by pilot and there are
certainly some additional options to configure (e.g., maybe we can come
up with a good way to transfer metadata via Envoy TLS instead of
injecting it into the data stream directly - this way, in principle, we
could avoid creating a custom upstream filter all together, if http peer
metadata filter could get the peer metadata directly from
connect_originate listener). All-in-all, it's not the final
implementation.



* Fix BUILD formatting



* Fix formatting of C++ code



* Update HTTP peer_metadata filter to consume filter state set by upstream
peer_metadata filter

This basically taps the upstream peer metadata into the regular filter
state consumed by the istio stats filter. http peer metadata filter also
takes care of priorities between different discovery methods - we just
need to put different discovery methods in the right order in the
configuration.



* Populate peer principal in the upstream workload metadata as well



* Support propagating baggage header to upstream and additional safety checks for upstream network filter



* Only register UpstreamFilterState peer metadata discovery method for upstream peer discovery



* Move peer_metadata filter proto config in the same directory



* Fix typo



---------



* Baggage discovery (#6779)

* Add Baggage metadata propagation



* clang-tidy



* basics for baggage discovery downstream

* removing unnecessary tests

* reverting crazy claude changes in release-binary.sh

* fixing tests, fixing baggage key tokens

* removing comment

* make lint

* fixing unit tests for metadata_object

* make lint

* suggestions from PR

* clarifying use of mappings for baggage and field access

* make lint

---------




* Add locality to proxy metadata (#6780)

* Add locality to proxy metadata



* Clang-tidy



* Buildifier format



* Rebase and fix some bugs



---------



* Drop app labels from baggage and propagate principal (#6791)

* Drop app labels from baggage and propagate principal

I think I confused folks a bit when I mentioned that app field is
missing from the baggage - it wasn't. In fact, canonical name of the
workload and app in ambient are the same thing, that's why baggage does
not actually need an app label - it already has service.name that
encodes what we need.

I updated the design document, but it happened after I mentioned here
and there that we need to add a missing field to the baggage.

This change corrects implementation and that makes istio stats populate
the app label correctly.

The other field that has not been populated is principal.
WorkloadMetadataObject contained that identity field that contained
principle in principle, but the methods used to conver
WorkloadMetadataObject to a protobuf Struct and back ignored that field
and never populated it, so it got lost and istio stats never used it.

We haven't noticed that before because in ambient we used xDS-based
peer metadata discovery by default and it triggers a different code
path that does not rely on the methods that convert protobuf Struct
to WorkloadMetadataObject, and the code path used there didn't have the
same issue.



* Keep backwards compatibility for app.service and app.version baggage fields



---------





* Fix some test compilation errors



* Merge upstream/master and resolve merge conflicts



* Missed one



* Fixed a wrong one



* Merge master branch and resolve merge conflicts properly (#6795)

* Automator: update envoy@ in istio/proxy@master (#6777)

* Automator: update envoy@ in istio/proxy@master (#6778)

* Don't do workload discovery for cross-network traffic (#6767)

* Get the implementation compiling

* Add tests for cross-network peer metadata



* clang-tidy



* One more tidy



* Switch to debug for logging



---------



* Automator: update envoy@ in istio/proxy@master (#6782)

* Automator: update envoy@ in istio/proxy@master (#6784)

* Automator: update go-control-plane in istio/proxy@master (#6786)

* Automator: update envoy@ in istio/proxy@master (#6787)

* Automator: update envoy@ in istio/proxy@master (#6788)

* update x-network header key (#6790)



* Automator: update envoy@ in istio/proxy@master (#6794)

* Merge upstream/master and resolve merge conflicts



* Missed one



* Fixed a wrong one



---------








* Add e2e test for proxy baggage-based metadata discovery + fixes

This adds an e2e test for new proxy filters that verifies both baggage
propagation as well as metrics that stats filter will generate.

I also made some changes to how we parse and generate baggage header.
Basically, WorkloadMetadataObject supports cases where app and service
might have different values. In xDS-based metadata discovery
implementation however app is always derived from the service name, at
least in ztunnel.

So there is a bit of a mismatch there. In practice this mismatch should
not matter, but purely hypothetically, if I didn't change the logic, we
could end up in a situation where waypoint node metadata is configured
in such a way that app is set, but service is not. And if that happens,
waypoint will generate a baggage, that ztunnels cannot interpret
correctly yet and it will result in metrics with unknown values.

I figured that I can rewrite code in a way that accounts for all corner
cases like that by making sure that:

1. When we parse baggage we set both app and service, and if any of
   those is not provided in the baggage, we use the other to backfill
2. When we generate baggage, we always generate service (because ztunnel
   needs it), and we generate app, if it's different from the service.

All-in-all, under normal circumstances in the baggage we will only have
service; if app is different from the service - we will add it to the
baggage as well; and when parsing baggage we will use either service or
app, depending on what is provided.



* Fix formatting



---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Ian Rudie <ian.rudie@solo.io>
Co-authored-by: Keith Mattix II <keithmattix@microsoft.com>
Co-authored-by: Gustavo Meira <grnmeira@users.noreply.github.com>
Co-authored-by: Istio Automation <istio-testing-bot@google.com>
Co-authored-by: Ian Rudie <ilrudie@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants