Skip to content

Commit

Permalink
fix WDS test
Browse files Browse the repository at this point in the history
  • Loading branch information
zirain committed Jan 1, 2025
1 parent 91a931e commit b4a377d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,21 @@ void MetadataExchangeFilter::tryReadProxyData(Buffer::Instance& data) {
}

void MetadataExchangeFilter::updatePeer(const Istio::Common::WorkloadMetadataObject& value) {
ENVOY_LOG(trace, "updatePeer for {}",
config_->filter_direction_ == FilterDirection::Downstream ? "Downstream" : "Upstream");
updatePeer(value, config_->filter_direction_);
}

void MetadataExchangeFilter::updatePeer(const Istio::Common::WorkloadMetadataObject& value,
FilterDirection direction) {
auto filter_state_key = direction == FilterDirection::Downstream ? Istio::Common::DownstreamPeer
: Istio::Common::UpstreamPeer;
ENVOY_LOG(trace, "updatePeer for {}", filter_state_key);

auto peer_info = std::make_unique<CelState>(MetadataExchangeConfig::peerInfoPrototype());
auto pb = value.serializeAsProto();
peer_info->setValue(pb->SerializeAsString());

read_callbacks_->connection().streamInfo().filterState()->setData(
config_->filter_direction_ == FilterDirection::Downstream ? Istio::Common::DownstreamPeer
: Istio::Common::UpstreamPeer,
std::move(peer_info), StreamInfo::FilterState::StateType::Mutable,
filter_state_key, std::move(peer_info), StreamInfo::FilterState::StateType::Mutable,
StreamInfo::FilterState::LifeSpan::Connection);
}

Expand Down Expand Up @@ -326,11 +330,7 @@ void MetadataExchangeFilter::setMetadataNotFoundFilterState() {
if (metadata_object) {
ENVOY_LOG(debug, "Metadata found for upstream peer address {}",
upstream_peer->asString());
read_callbacks_->connection().streamInfo().filterState()->setData(
Istio::Common::UpstreamPeer,
std::make_shared<Istio::Common::WorkloadMetadataObject>(metadata_object.value()),
StreamInfo::FilterState::StateType::Mutable,
StreamInfo::FilterState::LifeSpan::Connection);
updatePeer(metadata_object.value(), FilterDirection::Upstream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class MetadataExchangeFilter : public Network::Filter,
void tryReadProxyData(Buffer::Instance& data);

// Helper function to share the metadata with other filters.
void updatePeer(const Istio::Common::WorkloadMetadataObject& obj, FilterDirection direction);
void updatePeer(const Istio::Common::WorkloadMetadataObject& obj);

// Helper function to get metadata id.
Expand Down

0 comments on commit b4a377d

Please sign in to comment.