Skip to content
Closed
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
5 changes: 5 additions & 0 deletions include/envoy/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,14 @@ envoy_cc_library(
name = "transport_socket_config_interface",
hdrs = ["transport_socket_config.h"],
deps = [
"//include/envoy/event:dispatcher_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/network:transport_socket_interface",
"//include/envoy/runtime:runtime_interface",
"//include/envoy/secret:secret_manager_interface",
"//include/envoy/ssl:context_manager_interface",
"//include/envoy/stats:stats_interface",
"//include/envoy/upstream:cluster_manager_interface",
"//source/common/protobuf",
],
)
Expand Down
30 changes: 30 additions & 0 deletions include/envoy/server/transport_socket_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

#include <string>

#include "envoy/event/dispatcher.h"
#include "envoy/local_info/local_info.h"
#include "envoy/network/transport_socket.h"
#include "envoy/runtime/runtime.h"
#include "envoy/secret/secret_manager.h"
#include "envoy/ssl/context_manager.h"
#include "envoy/stats/stats.h"
#include "envoy/upstream/cluster_manager.h"

#include "common/protobuf/protobuf.h"

Expand Down Expand Up @@ -33,6 +38,31 @@ class TransportSocketFactoryContext {
* Return the instance of secret manager.
*/
virtual Secret::SecretManager& secretManager() PURE;

/**
* @return the instance of ClusterManager.
*/
virtual Upstream::ClusterManager& clusterManager() PURE;

/**
* @return information about the local environment the server is running in.
*/
virtual const LocalInfo::LocalInfo& localInfo() PURE;

/**
* @return Event::Dispatcher& the main thread's dispatcher.
*/
virtual Event::Dispatcher& dispatcher() PURE;

/**
* @return RandomGenerator& the random generator for the server.
*/
virtual Envoy::Runtime::RandomGenerator& random() PURE;

/**
* @return the server-wide stats store.
*/
virtual Stats::Store& stats() PURE;
};

class TransportSocketConfigFactory {
Expand Down
1 change: 1 addition & 0 deletions source/common/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ envoy_cc_library(
"//source/common/protobuf",
"//source/common/protobuf:utility_lib",
"//source/extensions/transport_sockets:well_known_names",
"//source/server:transport_socket_config_lib",
"@envoy_api//envoy/api/v2/core:base_cc",
],
)
Expand Down
22 changes: 12 additions & 10 deletions source/common/upstream/eds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@
namespace Envoy {
namespace Upstream {

EdsClusterImpl::EdsClusterImpl(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime,
Stats::Store& stats, Ssl::ContextManager& ssl_context_manager,
const LocalInfo::LocalInfo& local_info, ClusterManager& cm,
Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random,
bool added_via_api)
: BaseDynamicClusterImpl(cluster, cm.bindConfig(), runtime, stats, ssl_context_manager,
cm.clusterManagerFactory().secretManager(), added_via_api),
cm_(cm), local_info_(local_info),
EdsClusterImpl::EdsClusterImpl(
const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime,
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api)
: BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope),
added_via_api),
cm_(factory_context.clusterManager()), local_info_(factory_context.localInfo()),
cluster_name_(cluster.eds_cluster_config().service_name().empty()
? cluster.name()
: cluster.eds_cluster_config().service_name()) {
Config::Utility::checkLocalInfo("eds", local_info);
Config::Utility::checkLocalInfo("eds", local_info_);

const auto& eds_config = cluster.eds_cluster_config().eds_config();
Event::Dispatcher& dispatcher = factory_context.dispatcher();
Runtime::RandomGenerator& random = factory_context.random();
Upstream::ClusterManager& cm = factory_context.clusterManager();
subscription_ = Config::SubscriptionFactory::subscriptionFromConfigSource<
envoy::api::v2::ClusterLoadAssignment>(
eds_config, local_info.node(), dispatcher, cm, random, info_->statsScope(),
eds_config, local_info_.node(), dispatcher, cm, random, info_->statsScope(),
[this, &eds_config, &cm, &dispatcher,
&random]() -> Config::Subscription<envoy::api::v2::ClusterLoadAssignment>* {
return new SdsSubscription(info_->stats(), eds_config, cm, dispatcher, random);
Expand Down
6 changes: 2 additions & 4 deletions source/common/upstream/eds.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ class EdsClusterImpl : public BaseDynamicClusterImpl,
Config::SubscriptionCallbacks<envoy::api::v2::ClusterLoadAssignment> {
public:
EdsClusterImpl(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime,
Stats::Store& stats, Ssl::ContextManager& ssl_context_manager,
const LocalInfo::LocalInfo& local_info, ClusterManager& cm,
Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random,
bool added_via_api);
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api);

// Upstream::Cluster
InitializePhase initializePhase() const override { return InitializePhase::Secondary; }
Expand Down
21 changes: 9 additions & 12 deletions source/common/upstream/logical_dns_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@
namespace Envoy {
namespace Upstream {

LogicalDnsCluster::LogicalDnsCluster(const envoy::api::v2::Cluster& cluster,
Runtime::Loader& runtime, Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager,
const LocalInfo::LocalInfo& local_info,
Network::DnsResolverSharedPtr dns_resolver,
ThreadLocal::SlotAllocator& tls, ClusterManager& cm,
Event::Dispatcher& dispatcher, bool added_via_api)
: ClusterImplBase(cluster, cm.bindConfig(), runtime, stats, ssl_context_manager,
cm.clusterManagerFactory().secretManager(), added_via_api),
LogicalDnsCluster::LogicalDnsCluster(
const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime,
Network::DnsResolverSharedPtr dns_resolver, ThreadLocal::SlotAllocator& tls,
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api)
: ClusterImplBase(cluster, runtime, factory_context, std::move(stats_scope), added_via_api),
dns_resolver_(dns_resolver),
dns_refresh_rate_ms_(
std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(cluster, dns_refresh_rate, 5000))),
tls_(tls.allocateSlot()),
resolve_timer_(dispatcher.createTimer([this]() -> void { startResolve(); })),
local_info_(local_info),
tls_(tls.allocateSlot()), resolve_timer_(factory_context.dispatcher().createTimer(
[this]() -> void { startResolve(); })),
local_info_(factory_context.localInfo()),
load_assignment_(cluster.has_load_assignment()
? cluster.load_assignment()
: Config::Utility::translateClusterHosts(cluster.hosts())) {
Expand Down
5 changes: 2 additions & 3 deletions source/common/upstream/logical_dns_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ namespace Upstream {
class LogicalDnsCluster : public ClusterImplBase {
public:
LogicalDnsCluster(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime,
Stats::Store& stats, Ssl::ContextManager& ssl_context_manager,
const LocalInfo::LocalInfo& local_info,
Network::DnsResolverSharedPtr dns_resolver, ThreadLocal::SlotAllocator& tls,
ClusterManager& cm, Event::Dispatcher& dispatcher, bool added_via_api);
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api);

~LogicalDnsCluster();

Expand Down
18 changes: 9 additions & 9 deletions source/common/upstream/original_dst_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ OriginalDstCluster::LoadBalancer::requestOverrideHost(LoadBalancerContext* conte
return request_host;
}

OriginalDstCluster::OriginalDstCluster(const envoy::api::v2::Cluster& config,
Runtime::Loader& runtime, Stats::Store& stats,
Ssl::ContextManager& ssl_context_manager, ClusterManager& cm,
Event::Dispatcher& dispatcher, bool added_via_api)
: ClusterImplBase(config, cm.bindConfig(), runtime, stats, ssl_context_manager,
cm.clusterManagerFactory().secretManager(), added_via_api),
dispatcher_(dispatcher), cleanup_interval_ms_(std::chrono::milliseconds(
PROTOBUF_GET_MS_OR_DEFAULT(config, cleanup_interval, 5000))),
cleanup_timer_(dispatcher.createTimer([this]() -> void { cleanup(); })) {
OriginalDstCluster::OriginalDstCluster(
const envoy::api::v2::Cluster& config, Runtime::Loader& runtime,
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api)
: ClusterImplBase(config, runtime, factory_context, std::move(stats_scope), added_via_api),
dispatcher_(factory_context.dispatcher()),
cleanup_interval_ms_(
std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(config, cleanup_interval, 5000))),
cleanup_timer_(dispatcher_.createTimer([this]() -> void { cleanup(); })) {

cleanup_timer_->enableTimer(cleanup_interval_ms_);
}
Expand Down
5 changes: 3 additions & 2 deletions source/common/upstream/original_dst_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <unordered_map>

#include "envoy/secret/secret_manager.h"
#include "envoy/server/transport_socket_config.h"
#include "envoy/thread_local/thread_local.h"

#include "common/common/empty_string.h"
Expand All @@ -24,8 +25,8 @@ namespace Upstream {
class OriginalDstCluster : public ClusterImplBase {
public:
OriginalDstCluster(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime,
Stats::Store& stats, Ssl::ContextManager& ssl_context_manager,
ClusterManager& cm, Event::Dispatcher& dispatcher, bool added_via_api);
Server::Configuration::TransportSocketFactoryContext& factory_context,
Stats::ScopePtr&& stats_scope, bool added_via_api);

// Upstream::Cluster
InitializePhase initializePhase() const override { return InitializePhase::Primary; }
Expand Down
Loading