Skip to content

Commit

Permalink
Update ito stio 1.20.0
Browse files Browse the repository at this point in the history
Signed-off-by: CTakanashiRikka <[email protected]>
  • Loading branch information
Chenrujie-85 committed Sep 20, 2024
1 parent bee421c commit 5f2cb77
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 29 deletions.
64 changes: 37 additions & 27 deletions src/meta_protocol_proxy/route/rds_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,43 +80,51 @@ RdsRouteConfigSubscription::~RdsRouteConfigSubscription() {
route_config_provider_manager_.dynamic_route_config_providers_.erase(manager_identifier_);
}

void RdsRouteConfigSubscription::onConfigUpdate(
absl::Status RdsRouteConfigSubscription::onConfigUpdate(
const std::vector<Envoy::Config::DecodedResourceRef>& resources,
const std::string& version_info) {
if (!validateUpdateSize(resources.size())) {
return;
return absl::Status(absl::StatusCode::kInvalidArgument, "Invalid update size");
}
const auto& http_route_config = dynamic_cast<const envoy::config::route::v3::RouteConfiguration&>(
resources[0].get().resource());

auto meta_protocol_route_config =
aeraki::meta_protocol_proxy::config::route::v1alpha::RouteConfiguration();
httpRouteConfig2MetaProtocolRouteConfig(http_route_config, meta_protocol_route_config);
try {
const auto& http_route_config = dynamic_cast<const envoy::config::route::v3::RouteConfiguration&>(
resources[0].get().resource());

ENVOY_LOG(info, "meta protocol rds update: route_config_name: {} ",
meta_protocol_route_config.name());
aeraki::meta_protocol_proxy::config::route::v1alpha::RouteConfiguration meta_protocol_route_config;
httpRouteConfig2MetaProtocolRouteConfig(http_route_config, meta_protocol_route_config);

if (meta_protocol_route_config.name() != route_config_name_) {
throw EnvoyException(fmt::format("Unexpected RDS configuration (expecting {}): {}",
route_config_name_, meta_protocol_route_config.name()));
}
if (route_config_provider_opt_.has_value()) {
route_config_provider_opt_.value()->validateConfig(meta_protocol_route_config);
}
std::unique_ptr<Init::ManagerImpl> noop_init_manager;
std::unique_ptr<Cleanup> resume_rds;
if (config_update_info_->onRdsUpdate(meta_protocol_route_config, version_info)) {
stats_.config_reload_.inc();
stats_.config_reload_time_ms_.set(DateUtil::nowToMilliseconds(factory_context_.timeSource()));
ENVOY_LOG(debug, "rds: loading new configuration: config_name={} hash={}", route_config_name_,
config_update_info_->configHash());
ENVOY_LOG(info, "meta protocol rds update: route_config_name: {}", meta_protocol_route_config.name());

if (meta_protocol_route_config.name() != route_config_name_) {
return absl::Status(absl::StatusCode::kInternal,
absl::StrFormat("Unexpected RDS configuration (expecting %s): %s",
route_config_name_, meta_protocol_route_config.name()));
}

if (route_config_provider_opt_.has_value()) {
route_config_provider_opt_.value()->onConfigUpdate();
route_config_provider_opt_.value()->validateConfig(meta_protocol_route_config);
}
}

local_init_target_.ready();
std::unique_ptr<Init::ManagerImpl> noop_init_manager;
std::unique_ptr<Cleanup> resume_rds;
if (config_update_info_->onRdsUpdate(meta_protocol_route_config, version_info)) {
stats_.config_reload_.inc();
stats_.config_reload_time_ms_.set(
DateUtil::nowToMilliseconds(factory_context_.timeSource()));
ENVOY_LOG(debug, "rds: loading new configuration: config_name={} hash={}", route_config_name_,
config_update_info_->configHash());

if (route_config_provider_opt_.has_value()) {
route_config_provider_opt_.value()->onConfigUpdate();
}
}

local_init_target_.ready();
return absl::OkStatus();
} catch (const EnvoyException& e) {
return absl::Status(absl::StatusCode::kInternal, e.what());
}
}

// We use the Envoy RDS(HTTP RouteConfiguration) to transmit MetaProtocol RouteConfiguration between
Expand Down Expand Up @@ -197,7 +205,7 @@ void RdsRouteConfigSubscription::httpRouteConfig2MetaProtocolRouteConfig(
}
}

void RdsRouteConfigSubscription::onConfigUpdate(
absl::Status RdsRouteConfigSubscription::onConfigUpdate(
const std::vector<Envoy::Config::DecodedResourceRef>& added_resources,
const Protobuf::RepeatedPtrField<std::string>& removed_resources, const std::string&) {
if (!removed_resources.empty()) {
Expand All @@ -207,10 +215,12 @@ void RdsRouteConfigSubscription::onConfigUpdate(
error,
"Server sent a delta RDS update attempting to remove a resource (name: {}). Ignoring.",
removed_resources[0]);
return absl::OkStatus();
}
if (!added_resources.empty()) {
onConfigUpdate(added_resources, added_resources[0].get().version());
}
return absl::OkStatus();
}

void RdsRouteConfigSubscription::onConfigUpdateFailed(
Expand Down
5 changes: 3 additions & 2 deletions src/meta_protocol_proxy/route/rds_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "absl/container/node_hash_map.h"
#include "absl/container/node_hash_set.h"
#include "absl/status/status.h"

#include "api/meta_protocol_proxy/admin/v1alpha/config_dump.pb.h"
#include "api/meta_protocol_proxy/config/route/v1alpha/route.pb.h"
Expand Down Expand Up @@ -115,9 +116,9 @@ class RdsRouteConfigSubscription

private:
// Config::SubscriptionCallbacks
void onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>& resources,
absl::Status onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>& resources,
const std::string& version_info) override;
void onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>& added_resources,
absl::Status onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>& added_resources,
const Protobuf::RepeatedPtrField<std::string>& removed_resources,
const std::string& system_version_info) override;
void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason reason,
Expand Down
1 change: 1 addition & 0 deletions src/meta_protocol_proxy/tracing/tracer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class TracingConfigImpl : public Tracing::TracingConfig {
custom_tags_ = std::make_unique<Envoy::Tracing::CustomTagMap>();
}
Envoy::Tracing::OperationName operationName() const override { return operation_name_; };
bool spawnUpstreamSpan() const override { return true; };
const Envoy::Tracing::CustomTagMap* customTags() const override { return custom_tags_.get(); };
bool verbose() const override { return verbose_; };
uint32_t maxPathTagLength() const override { return max_tag_length_; };
Expand Down

0 comments on commit 5f2cb77

Please sign in to comment.