Skip to content

Commit

Permalink
Removes exception from vhds.cc (envoyproxy#38267)
Browse files Browse the repository at this point in the history
Commit Message: Removes exception from vhds.cc
Additional Description:
Risk Level: low
Testing: existing ones
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

---------

Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Jan 30, 2025
1 parent 54936e1 commit 107b7e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions source/common/router/vhds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ absl::StatusOr<VhdsSubscriptionPtr> VhdsSubscription::createVhdsSubscription(
return absl::InvalidArgumentError("vhds: only 'DELTA_GRPC' is supported as an api_type.");
}

return std::unique_ptr<VhdsSubscription>(new VhdsSubscription(
config_update_info, factory_context, stat_prefix, route_config_provider));
auto status = absl::OkStatus();
auto ret = std::unique_ptr<VhdsSubscription>(new VhdsSubscription(
config_update_info, factory_context, stat_prefix, route_config_provider, status));
RETURN_IF_ERROR(status);
return ret;
}

// Implements callbacks to handle DeltaDiscovery protocol for VirtualHostDiscoveryService
VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info,
Server::Configuration::ServerFactoryContext& factory_context,
const std::string& stat_prefix,
Rds::RouteConfigProvider* route_config_provider)
Rds::RouteConfigProvider* route_config_provider,
absl::Status& status)
: Envoy::Config::SubscriptionBase<envoy::config::route::v3::VirtualHost>(
factory_context.messageValidationContext().dynamicValidationVisitor(), "name"),
config_update_info_(config_update_info),
Expand All @@ -58,11 +62,12 @@ VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info,
const auto resource_name = getResourceName();
Envoy::Config::SubscriptionOptions options;
options.use_namespace_matching_ = true;
subscription_ = THROW_OR_RETURN_VALUE(
absl::StatusOr<Envoy::Config::SubscriptionPtr> status_or =
factory_context.clusterManager().subscriptionFactory().subscriptionFromConfigSource(
config_update_info_->protobufConfigurationCast().vhds().config_source(),
Grpc::Common::typeUrl(resource_name), *scope_, *this, resource_decoder_, options),
Envoy::Config::SubscriptionPtr);
Grpc::Common::typeUrl(resource_name), *scope_, *this, resource_decoder_, options);
SET_AND_RETURN_IF_NOT_OK(status_or.status(), status);
subscription_ = std::move(status_or.value());
}

void VhdsSubscription::updateOnDemand(const std::string& with_route_config_name_prefix) {
Expand Down
3 changes: 2 additions & 1 deletion source/common/router/vhds.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class VhdsSubscription : Envoy::Config::SubscriptionBase<envoy::config::route::v
private:
VhdsSubscription(RouteConfigUpdatePtr& config_update_info,
Server::Configuration::ServerFactoryContext& factory_context,
const std::string& stat_prefix, Rds::RouteConfigProvider* route_config_provider);
const std::string& stat_prefix, Rds::RouteConfigProvider* route_config_provider,
absl::Status& creation_status);

// Config::SubscriptionCallbacks
absl::Status onConfigUpdate(const std::vector<Envoy::Config::DecodedResourceRef>&,
Expand Down
1 change: 0 additions & 1 deletion tools/code_format/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ paths:
- source/common/listener_manager/lds_api.cc
- source/common/upstream/od_cds_api_impl.cc
- source/common/upstream/cds_api_impl.cc
- source/common/router/vhds.cc
- source/common/rds/common/route_config_provider_manager_impl.h
- source/common/rds/route_config_provider_manager.h
- source/common/filter/config_discovery_impl.cc
Expand Down

0 comments on commit 107b7e1

Please sign in to comment.