Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hds: not including for E-M #37043

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions envoy/server/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,11 @@ class Instance {
virtual Config::XdsManager& xdsManager() PURE;
};

// Pick a class HdsDelegate inherits from
class HdsDelegateApi : public Logger::Loggable<Logger::Id::upstream> {
public:
virtual ~HdsDelegateApi() = default;
};

} // namespace Server
} // namespace Envoy
1 change: 1 addition & 0 deletions mobile/library/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ envoy_cc_library(
"@envoy_api//envoy/extensions/filters/http/alternate_protocols_cache/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/http/decompressor/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/http/dynamic_forward_proxy/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/http/router/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/http/header_formatters/preserve_case/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/network/dns_resolver/apple/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/network/dns_resolver/getaddrinfo/v3:pkg_cc_proto",
Expand Down
1 change: 1 addition & 0 deletions mobile/library/cc/engine_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "envoy/extensions/filters/http/alternate_protocols_cache/v3/alternate_protocols_cache.pb.h"
#include "envoy/extensions/filters/http/decompressor/v3/decompressor.pb.h"
#include "envoy/extensions/filters/http/dynamic_forward_proxy/v3/dynamic_forward_proxy.pb.h"
#include "envoy/extensions/filters/http/router/v3/router.pb.h"
#include "envoy/extensions/http/header_formatters/preserve_case/v3/preserve_case.pb.h"

#if defined(__APPLE__)
Expand Down
6 changes: 6 additions & 0 deletions mobile/library/common/engine_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ class ServerLite : public Server::InstanceBase {
std::unique_ptr<Server::GuardDog> maybeCreateGuardDog(absl::string_view) override {
return nullptr;
}
std::unique_ptr<Server::HdsDelegateApi>
maybeCreateHdsDelegate(Server::Configuration::ServerFactoryContext&, Stats::Scope&,
Grpc::RawAsyncClientPtr&&, Envoy::Stats::Store&, Ssl::ContextManager&,
Upstream::ClusterInfoFactory&) override {
return nullptr;
}
};

EngineCommon::EngineCommon(std::shared_ptr<Envoy::OptionsImplBase> options) : options_(options) {
Expand Down
1 change: 1 addition & 0 deletions mobile/test/common/integration/test_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "envoy/extensions/clusters/dynamic_forward_proxy/v3/cluster.pb.h"
#include "envoy/extensions/filters/http/dynamic_forward_proxy/v3/dynamic_forward_proxy.pb.h"
#include "envoy/extensions/filters/http/router/v3/router.pb.h"
#include "envoy/extensions/network/dns_resolver/getaddrinfo/v3/getaddrinfo_dns_resolver.pb.h"

#include "source/common/listener_manager/connection_handler_impl.h"
Expand Down
1 change: 1 addition & 0 deletions mobile/test/performance/files_em_does_not_use
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source/common/network/tcp_listener_impl.h
source/server/guarddog_impl.h
source/server/watchdog_impl.h
source/server/options_impl.cc
source/common/upstream/health_discovery_service.h
source/extensions/access_loggers/common/file_access_log_impl.h
source/common/router/scoped_rds.h
source/extensions/load_balancing_policies/subset/subset_lb.h
Expand Down
9 changes: 9 additions & 0 deletions source/common/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "prod_cluster_info_factory_lib",
srcs = ["prod_cluster_info_factory.cc"],
hdrs = ["prod_cluster_info_factory.h"],
deps = [
":upstream_includes",
],
)

envoy_cc_library(
name = "health_discovery_service_lib",
srcs = ["health_discovery_service.cc"],
Expand Down
26 changes: 0 additions & 26 deletions source/common/upstream/health_discovery_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,32 +534,6 @@ void HdsCluster::updateHosts(

ClusterSharedPtr HdsCluster::create() { return nullptr; }

ClusterInfoConstSharedPtr
ProdClusterInfoFactory::createClusterInfo(const CreateClusterInfoParams& params) {
Envoy::Stats::ScopeSharedPtr scope =
params.stats_.createScope(fmt::format("cluster.{}.", params.cluster_.name()));

Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context(
params.server_context_, params.ssl_context_manager_, *scope,
params.server_context_.clusterManager(), params.server_context_.messageValidationVisitor());

// TODO(JimmyCYJ): Support SDS for HDS cluster.
Network::UpstreamTransportSocketFactoryPtr socket_factory = THROW_OR_RETURN_VALUE(
Upstream::createTransportSocketFactory(params.cluster_, factory_context),
Network::UpstreamTransportSocketFactoryPtr);
auto socket_matcher = THROW_OR_RETURN_VALUE(
TransportSocketMatcherImpl::create(params.cluster_.transport_socket_matches(),
factory_context, socket_factory, *scope),
std::unique_ptr<TransportSocketMatcherImpl>);

return THROW_OR_RETURN_VALUE(
ClusterInfoImpl::create(params.server_context_.initManager(), params.server_context_,
params.cluster_, params.bind_config_,
params.server_context_.runtime(), std::move(socket_matcher),
std::move(scope), params.added_via_api_, factory_context),
std::unique_ptr<ClusterInfoImpl>);
}

void HdsCluster::initHealthchecks() {
for (auto& health_check : cluster_.health_checks()) {
auto health_checker_or_error =
Expand Down
8 changes: 2 additions & 6 deletions source/common/upstream/health_discovery_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "envoy/config/cluster/v3/cluster.pb.h"
#include "envoy/config/core/v3/address.pb.h"
#include "envoy/event/dispatcher.h"
#include "envoy/server/instance.h"
#include "envoy/server/transport_socket_config.h"
#include "envoy/service/health/v3/hds.pb.h"
#include "envoy/ssl/context_manager.h"
Expand Down Expand Up @@ -33,11 +34,6 @@ using HealthCheckerMap =
absl::flat_hash_map<envoy::config::core::v3::HealthCheck, Upstream::HealthCheckerSharedPtr,
HealthCheckerHash, HealthCheckerEqualTo>;

class ProdClusterInfoFactory : public ClusterInfoFactory, Logger::Loggable<Logger::Id::upstream> {
public:
ClusterInfoConstSharedPtr createClusterInfo(const CreateClusterInfoParams& params) override;
};

// TODO(lilika): Add HdsClusters to the /clusters endpoint to get detailed stats about each HC host.

/**
Expand Down Expand Up @@ -138,7 +134,7 @@ struct HdsDelegateStats {
* back the results.
*/
class HdsDelegate : Grpc::AsyncStreamCallbacks<envoy::service::health::v3::HealthCheckSpecifier>,
Logger::Loggable<Logger::Id::upstream> {
public Server::HdsDelegateApi {
public:
HdsDelegate(Server::Configuration::ServerFactoryContext& server_context, Stats::Scope& scope,
Grpc::RawAsyncClientPtr async_client, Envoy::Stats::Store& stats,
Expand Down
40 changes: 40 additions & 0 deletions source/common/upstream/prod_cluster_info_factory.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "source/common/upstream/prod_cluster_info_factory.h"

#include "envoy/stats/scope.h"

#include "source/common/protobuf/message_validator_impl.h"
#include "source/common/protobuf/protobuf.h"
#include "source/common/protobuf/utility.h"
#include "source/common/upstream/upstream_impl.h"

namespace Envoy {
namespace Upstream {

ClusterInfoConstSharedPtr
ProdClusterInfoFactory::createClusterInfo(const CreateClusterInfoParams& params) {
Envoy::Stats::ScopeSharedPtr scope =
params.stats_.createScope(fmt::format("cluster.{}.", params.cluster_.name()));

Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context(
params.server_context_, params.ssl_context_manager_, *scope,
params.server_context_.clusterManager(), params.server_context_.messageValidationVisitor());

// TODO(JimmyCYJ): Support SDS for HDS cluster.
Network::UpstreamTransportSocketFactoryPtr socket_factory = THROW_OR_RETURN_VALUE(
Upstream::createTransportSocketFactory(params.cluster_, factory_context),
Network::UpstreamTransportSocketFactoryPtr);
auto socket_matcher = THROW_OR_RETURN_VALUE(
TransportSocketMatcherImpl::create(params.cluster_.transport_socket_matches(),
factory_context, socket_factory, *scope),
std::unique_ptr<TransportSocketMatcherImpl>);

return THROW_OR_RETURN_VALUE(
ClusterInfoImpl::create(params.server_context_.initManager(), params.server_context_,
params.cluster_, params.bind_config_,
params.server_context_.runtime(), std::move(socket_matcher),
std::move(scope), params.added_via_api_, factory_context),
std::unique_ptr<ClusterInfoImpl>);
}

} // namespace Upstream
} // namespace Envoy
16 changes: 16 additions & 0 deletions source/common/upstream/prod_cluster_info_factory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "envoy/api/api.h"
#include "envoy/upstream/cluster_manager.h"
#include "envoy/upstream/upstream.h"

namespace Envoy {
namespace Upstream {

class ProdClusterInfoFactory : public ClusterInfoFactory, Logger::Loggable<Logger::Id::upstream> {
public:
ClusterInfoConstSharedPtr createClusterInfo(const CreateClusterInfoParams& params) override;
};

} // namespace Upstream
} // namespace Envoy
3 changes: 2 additions & 1 deletion source/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ envoy_cc_library(
"//source/common/stats:thread_local_store_lib",
"//source/common/tls:context_lib",
"//source/common/upstream:cluster_manager_lib",
"//source/common/upstream:health_discovery_service_lib",
"//source/common/upstream:prod_cluster_info_factory_lib",
"//source/common/version:version_lib",
"//source/server/admin:admin_lib",
"@com_google_absl//absl/container:node_hash_map",
Expand All @@ -479,6 +479,7 @@ envoy_cc_library(
":guarddog_lib",
":server_base_lib",
"//source/common/memory:heap_shrinker_lib",
"//source/common/upstream:health_discovery_service_lib",
"//source/server:null_overload_manager_lib",
"//source/server:overload_manager_lib",
],
Expand Down
9 changes: 9 additions & 0 deletions source/server/instance_impl.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "source/server/instance_impl.h"

#include "source/common/upstream/health_discovery_service.h"
#include "source/server/guarddog_impl.h"
#include "source/server/null_overload_manager.h"
#include "source/server/overload_manager_impl.h"
Expand All @@ -26,5 +27,13 @@ std::unique_ptr<Server::GuardDog> InstanceImpl::maybeCreateGuardDog(absl::string
config().mainThreadWatchdogConfig(), api(), name);
}

std::unique_ptr<HdsDelegateApi> InstanceImpl::maybeCreateHdsDelegate(
Configuration::ServerFactoryContext& server_context, Stats::Scope& scope,
Grpc::RawAsyncClientPtr&& async_client, Envoy::Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager, Upstream::ClusterInfoFactory& info_factory) {
return std::make_unique<Upstream::HdsDelegate>(server_context, scope, std::move(async_client),
stats, ssl_context_manager, info_factory);
}

} // namespace Server
} // namespace Envoy
5 changes: 5 additions & 0 deletions source/server/instance_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class InstanceImpl : public InstanceBase {
absl::StatusOr<std::unique_ptr<OverloadManager>> createOverloadManager() override;
std::unique_ptr<OverloadManager> createNullOverloadManager() override;
std::unique_ptr<Server::GuardDog> maybeCreateGuardDog(absl::string_view name) override;
std::unique_ptr<HdsDelegateApi>
maybeCreateHdsDelegate(Configuration::ServerFactoryContext& server_context, Stats::Scope& scope,
Grpc::RawAsyncClientPtr&& async_client, Envoy::Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
Upstream::ClusterInfoFactory& info_factory) override;

private:
std::unique_ptr<Memory::HeapShrinker> heap_shrinker_;
Expand Down
15 changes: 8 additions & 7 deletions source/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,16 +837,17 @@ void InstanceBase::onRuntimeReady() {
auto factory_or_error = Config::Utility::factoryForGrpcApiConfigSource(
*async_client_manager_, hds_config, *stats_store_.rootScope(), false, 0);
THROW_IF_NOT_OK_REF(factory_or_error.status());
hds_delegate_ = std::make_unique<Upstream::HdsDelegate>(
serverFactoryContext(), *stats_store_.rootScope(),
factory_or_error.value()->createUncachedRawAsyncClient(), stats_store_,
*ssl_context_manager_, info_factory_);
hds_delegate_ =
maybeCreateHdsDelegate(serverFactoryContext(), *stats_store_.rootScope(),
factory_or_error.value()->createUncachedRawAsyncClient(),
stats_store_, *ssl_context_manager_, info_factory_);
}
END_TRY
CATCH(const EnvoyException& e, {
ENVOY_LOG(warn, "Skipping initialization of HDS cluster: {}", e.what());
CATCH(const EnvoyException& e,
{ ENVOY_LOG(warn, "Skipping initialization of HDS cluster: {}", e.what()); });
if (!hds_delegate_) {
shutdown();
});
}
}

// TODO (nezdolik): Fully deprecate this runtime key in the next release.
Expand Down
10 changes: 8 additions & 2 deletions source/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <string>

#include "envoy/common/regex.h"
#include "envoy/config/bootstrap/v3/bootstrap.pb.h"
#include "envoy/event/timer.h"
#include "envoy/server/bootstrap_extension_config.h"
Expand Down Expand Up @@ -39,7 +40,7 @@
#include "source/common/runtime/runtime_impl.h"
#include "source/common/secret/secret_manager_impl.h"
#include "source/common/singleton/manager_impl.h"
#include "source/common/upstream/health_discovery_service.h"
#include "source/common/upstream/prod_cluster_info_factory.h"

#ifdef ENVOY_ADMIN_FUNCTIONALITY
#include "source/server/admin/admin.h"
Expand Down Expand Up @@ -259,6 +260,11 @@ class InstanceBase : Logger::Loggable<Logger::Id::main>,
virtual absl::StatusOr<std::unique_ptr<OverloadManager>> createOverloadManager() PURE;
virtual std::unique_ptr<OverloadManager> createNullOverloadManager() PURE;
virtual std::unique_ptr<Server::GuardDog> maybeCreateGuardDog(absl::string_view name) PURE;
virtual std::unique_ptr<HdsDelegateApi>
maybeCreateHdsDelegate(Configuration::ServerFactoryContext& server_context, Stats::Scope& scope,
Grpc::RawAsyncClientPtr&& async_client, Envoy::Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
Upstream::ClusterInfoFactory& info_factory) PURE;

void run() override;

Expand Down Expand Up @@ -412,7 +418,7 @@ class InstanceBase : Logger::Loggable<Logger::Id::main>,
Grpc::AsyncClientManagerPtr async_client_manager_;
Config::XdsManagerPtr xds_manager_;
Upstream::ProdClusterInfoFactory info_factory_;
Upstream::HdsDelegatePtr hds_delegate_;
std::unique_ptr<HdsDelegateApi> hds_delegate_;
std::unique_ptr<OverloadManager> overload_manager_;
std::unique_ptr<OverloadManager> null_overload_manager_;
std::vector<BootstrapExtensionPtr> bootstrap_extensions_;
Expand Down
1 change: 1 addition & 0 deletions test/common/router/config_impl_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "source/common/common/base64.h"
#include "source/common/http/utility.h"
#include "source/common/protobuf/protobuf.h"
#include "source/common/router/config_impl.h"

#include "test/integration/http_integration.h"
#include "test/test_common/registry.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source/common/common/fmt.h"
#include "source/common/http/message_impl.h"
#include "source/extensions/common/aws/utility.h"

#include "test/integration/integration.h"
Expand Down
1 change: 1 addition & 0 deletions test/extensions/retry/host/previous_hosts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ envoy_extension_cc_test(
"//source/extensions/retry/host/previous_hosts:config",
"//test/integration:http_integration_lib",
"//test/integration:integration_lib",
"@envoy_api//envoy/config/route/v3:pkg_cc_proto",
],
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "envoy/config/route/v3/route_components.pb.h"
#include "envoy/config/route/v3/route_components.pb.validate.h"

#include "source/common/protobuf/message_validator_impl.h"
#include "source/common/protobuf/utility.h"

Expand Down
5 changes: 5 additions & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ envoy_cc_test(
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/access_loggers/file/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/http/router/v3:pkg_cc_proto",
],
)

Expand Down Expand Up @@ -995,6 +996,10 @@ envoy_cc_test_library(
"//test/test_common:registry_lib",
"//test/test_common:utility_lib",
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/early_data/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/early_data/v3:pkg_cc_proto_descriptor",
"@envoy_api//envoy/extensions/filters/http/router/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/http/upstream_codec/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/http_connection_manager/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/transport_sockets/quic/v3:pkg_cc_proto",
],
Expand Down
1 change: 1 addition & 0 deletions test/integration/admin_html/test_server.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source/common/filesystem/filesystem_impl.h"
#include "source/common/http/headers.h"
#include "source/exe/main_common.h"
#include "source/server/admin/admin_html_util.h"

Expand Down
2 changes: 2 additions & 0 deletions test/integration/health_check_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "envoy/config/core/v3/health_check.pb.h"
#include "envoy/type/v3/range.pb.h"

#include "source/common/upstream/health_discovery_service.h"

#include "test/common/grpc/grpc_client_integration.h"
#include "test/common/http/http2/http2_frame.h"
#include "test/common/upstream/utility.h"
Expand Down
5 changes: 5 additions & 0 deletions test/integration/http_integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#include <memory>
#include <string>

#include "envoy/extensions/early_data/v3/default_early_data_policy_descriptor.pb.h"
#include "envoy/extensions/filters/http/router/v3/router.pb.h"
#include "envoy/extensions/filters/http/upstream_codec/v3/upstream_codec.pb.h"

#include "source/common/http/codec_client.h"
#include "source/common/network/filter_impl.h"
#include "source/extensions/early_data/default_early_data_policy.h"

#include "test/common/http/http2/http2_frame.h"
#include "test/integration/integration.h"
Expand Down
3 changes: 3 additions & 0 deletions test/integration/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "source/common/common/logger.h"
#include "source/common/common/thread.h"
#include "source/common/stats/allocator_impl.h"
#include "source/common/stats/isolated_store_impl.h"
#include "source/common/stats/null_counter.h"
#include "source/common/stats/null_gauge.h"
#include "source/server/drain_manager_impl.h"
#include "source/server/listener_hooks.h"
#include "source/server/options_impl_base.h"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/typed_metadata_integration_test.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "envoy/access_log/access_log_config.h"

#include "source/common/protobuf/protobuf.h"

#include "test/integration/http_protocol_integration.h"
Expand Down
Loading
Loading