diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 8ff28587b283..4ec35dca4b30 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -290,13 +290,12 @@ HttpConnectionManagerFilterConfigFactory::createFilterFactoryFromProtoAndHopByHo Server::Configuration::FactoryContext& context, bool clear_hop_by_hop_headers) { Utility::Singletons singletons = Utility::createSingletons(context); - auto filter_config = THROW_OR_RETURN_VALUE( - Utility::createConfig(proto_config, context, *singletons.date_provider_, - *singletons.route_config_provider_manager_, - singletons.scoped_routes_config_provider_manager_.get(), - *singletons.tracer_manager_, - *singletons.filter_config_provider_manager_), - std::shared_ptr); + auto config_or_error = Utility::createConfig( + proto_config, context, *singletons.date_provider_, *singletons.route_config_provider_manager_, + singletons.scoped_routes_config_provider_manager_.get(), *singletons.tracer_manager_, + *singletons.filter_config_provider_manager_); + RETURN_IF_NOT_OK_REF(config_or_error.status()); + auto filter_config = std::move(*config_or_error); // This lambda captures the shared_ptrs created above, thus preserving the // reference count. @@ -867,20 +866,19 @@ HttpConnectionManagerConfig::getHeaderValidatorStats([[maybe_unused]] Http::Prot } #endif -std::function +absl::StatusOr> HttpConnectionManagerFactory::createHttpConnectionManagerFactoryFromProto( const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& proto_config, Server::Configuration::FactoryContext& context, bool clear_hop_by_hop_headers) { Utility::Singletons singletons = Utility::createSingletons(context); - auto filter_config = THROW_OR_RETURN_VALUE( - Utility::createConfig(proto_config, context, *singletons.date_provider_, - *singletons.route_config_provider_manager_, - singletons.scoped_routes_config_provider_manager_.get(), - *singletons.tracer_manager_, - *singletons.filter_config_provider_manager_), - std::shared_ptr); + auto config_or_error = Utility::createConfig( + proto_config, context, *singletons.date_provider_, *singletons.route_config_provider_manager_, + singletons.scoped_routes_config_provider_manager_.get(), *singletons.tracer_manager_, + *singletons.filter_config_provider_manager_); + RETURN_IF_NOT_OK_REF(config_or_error.status()); + auto filter_config = std::move(*config_or_error); // This lambda captures the shared_ptrs created above, thus preserving the // reference count. diff --git a/source/extensions/filters/network/http_connection_manager/config.h b/source/extensions/filters/network/http_connection_manager/config.h index 75cbdceb33f1..067685cc6ac7 100644 --- a/source/extensions/filters/network/http_connection_manager/config.h +++ b/source/extensions/filters/network/http_connection_manager/config.h @@ -377,7 +377,7 @@ class HttpConnectionManagerConfig : Logger::Loggable, */ class HttpConnectionManagerFactory { public: - static std::function + static absl::StatusOr> createHttpConnectionManagerFactoryFromProto( const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& proto_config, diff --git a/source/server/api_listener_impl.cc b/source/server/api_listener_impl.cc index 7f5d4e8fe9ad..ead221d06f72 100644 --- a/source/server/api_listener_impl.cc +++ b/source/server/api_listener_impl.cc @@ -46,13 +46,17 @@ HttpApiListener::create(const envoy::config::listener::v3::Listener& config, Server::Instance& server, const std::string& name) { auto address_or_error = Network::Address::resolveProtoAddress(config.address()); RETURN_IF_NOT_OK_REF(address_or_error.status()); - return std::unique_ptr( - new HttpApiListener(std::move(address_or_error.value()), config, server, name)); + absl::Status creation_status = absl::OkStatus(); + auto ret = std::unique_ptr(new HttpApiListener( + std::move(address_or_error.value()), config, server, name, creation_status)); + RETURN_IF_NOT_OK_REF(creation_status); + return ret; } HttpApiListener::HttpApiListener(Network::Address::InstanceConstSharedPtr&& address, const envoy::config::listener::v3::Listener& config, - Server::Instance& server, const std::string& name) + Server::Instance& server, const std::string& name, + absl::Status& creation_status) : ApiListenerImplBase(std::move(address), config, server, name) { if (config.api_listener().api_listener().type_url() == absl::StrCat( @@ -66,17 +70,21 @@ HttpApiListener::HttpApiListener(Network::Address::InstanceConstSharedPtr&& addr EnvoyMobileHttpConnectionManager>(config.api_listener().api_listener(), factory_context_.messageValidationVisitor()); - http_connection_manager_factory_ = Envoy::Extensions::NetworkFilters::HttpConnectionManager:: + auto factory_or_error = Envoy::Extensions::NetworkFilters::HttpConnectionManager:: HttpConnectionManagerFactory::createHttpConnectionManagerFactoryFromProto( typed_config.config(), factory_context_, false); + SET_AND_RETURN_IF_NOT_OK(factory_or_error.status(), creation_status); + http_connection_manager_factory_ = std::move(*factory_or_error); } else { auto typed_config = MessageUtil::anyConvertAndValidate< envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager>( config.api_listener().api_listener(), factory_context_.messageValidationVisitor()); - http_connection_manager_factory_ = + auto factory_or_error = Envoy::Extensions::NetworkFilters::HttpConnectionManager::HttpConnectionManagerFactory:: createHttpConnectionManagerFactoryFromProto(typed_config, factory_context_, true); + SET_AND_RETURN_IF_NOT_OK(factory_or_error.status(), creation_status); + http_connection_manager_factory_ = std::move(*factory_or_error); } } diff --git a/source/server/api_listener_impl.h b/source/server/api_listener_impl.h index 74b98e8f0c12..a5d03747e716 100644 --- a/source/server/api_listener_impl.h +++ b/source/server/api_listener_impl.h @@ -228,7 +228,7 @@ class HttpApiListener : public ApiListenerImplBase { private: HttpApiListener(Network::Address::InstanceConstSharedPtr&& address, const envoy::config::listener::v3::Listener& config, Server::Instance& server, - const std::string& name); + const std::string& name, absl::Status& creation_status); // Need to store the factory due to the shared_ptrs that need to be kept alive: date provider, // route config manager, scoped route config manager. diff --git a/tools/code_format/config.yaml b/tools/code_format/config.yaml index 81eae247e7c7..3d24f45547bf 100644 --- a/tools/code_format/config.yaml +++ b/tools/code_format/config.yaml @@ -202,7 +202,18 @@ paths: - source/extensions/filters/http/ratelimit - source/extensions/filters/http/oauth2 - source/extensions/filters/http/wasm - - source/extensions/filters/network + - source/extensions/filters/network/dubbo_proxy + - source/extensions/filters/network/rbac + - source/extensions/filters/network/sni_dynamic_forward_proxy + - source/extensions/filters/network/common + - source/extensions/filters/network/redis_proxy + - source/extensions/filters/network/zookeeper_proxy + - source/extensions/filters/network/ext_authz + - source/extensions/filters/network/mongo_proxy + - source/extensions/filters/network/thrift_proxy + - source/extensions/filters/network/direct_response + - source/extensions/filters/network/generic_proxy + - source/extensions/filters/network/ratelimit - source/extensions/filters/common - source/extensions/filters/udp - source/extensions/filters/listener