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
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ build:coverage --strategy=CoverageReport=sandboxed,local
build:coverage --experimental_use_llvm_covmap
build:coverage --collect_code_coverage
build:coverage --test_tag_filters=-nocoverage
build:coverage --instrumentation_filter="//source(?!/common/chromium_url|/common/quic/platform)[/:],//include[/:]"
build:coverage --instrumentation_filter="//source(?!/common/quic/platform)[/:],//include[/:]"
build:test-coverage --test_arg="-l trace"
build:fuzz-coverage --config=plain-fuzzer
build:fuzz-coverage --run_under=@envoy//bazel/coverage:fuzz_coverage_wrapper.sh
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.0
4.2.1
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

ENVOY_COMMIT = "9d476a1563ab8acc244bad3246d2b13368d5552a" # Oct 11, 2021
ENVOY_SHA = "05d52ba9660963d5d495227b2650979b38d3bb04322a614d689aa16b02b8a9f5"
ENVOY_COMMIT = "592868adfefacf1afae6e41c6ee25e4a059aa089" # Oct 18, 2021
ENVOY_SHA = "674a6d802d934596ac6373612c40398ce8e37ec91aa5cc1dd1873b780ef15f68"

HDR_HISTOGRAM_C_VERSION = "0.11.2" # October 12th, 2020
HDR_HISTOGRAM_C_SHA = "637f28b5f64de2e268131e4e34e6eef0b91cf5ff99167db447d9b2825eae6bad"
Expand Down
1 change: 0 additions & 1 deletion include/nighthawk/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ envoy_basic_cc_library(
"@envoy//source/common/api:api_lib_with_external_headers",
"@envoy//source/common/common:minimal_logger_lib_with_external_headers",
"@envoy//source/common/common:non_copyable_with_external_headers",
"@envoy//source/common/network:dns_lib_with_external_headers",
"@envoy//source/common/protobuf:protobuf_with_external_headers",
"@envoy//source/common/runtime:runtime_lib_with_external_headers",
"@envoy_api//envoy/api/v2:pkg_cc_proto",
Expand Down
5 changes: 3 additions & 2 deletions include/nighthawk/common/uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "nighthawk/common/exception.h"

#include "external/envoy/source/common/network/dns_impl.h"
#include "external/envoy/envoy/network/dns.h"
#include "external/envoy/source/common/network/utility.h"

#include "absl/strings/string_view.h"
Expand Down Expand Up @@ -58,12 +58,13 @@ class Uri {
/**
* Synchronously resolves the parsed host from the uri to an ip-address.
* @param dispatcher Dispatcher to use for resolving.
* @param dns_resolver DNS resolver to use for resolving.
* @param dns_lookup_family Allows specifying Ipv4, Ipv6, or Auto as the preferred returned
* address family.
* @return Envoy::Network::Address::InstanceConstSharedPtr the resolved address.
*/
virtual Envoy::Network::Address::InstanceConstSharedPtr
resolve(Envoy::Event::Dispatcher& dispatcher,
resolve(Envoy::Event::Dispatcher& dispatcher, Envoy::Network::DnsResolver& dns_resolver,
const Envoy::Network::DnsLookupFamily dns_lookup_family) PURE;

/**
Expand Down
1 change: 0 additions & 1 deletion source/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ envoy_cc_library(
"@envoy//source/common/http/http2:conn_pool_lib_with_external_headers",
"@envoy//source/common/init:manager_lib_with_external_headers",
"@envoy//source/common/local_info:local_info_lib_with_external_headers",
"@envoy//source/common/network:dns_lib_with_external_headers",
"@envoy//source/common/network:address_lib_with_external_headers",
"@envoy//source/common/protobuf:message_validator_lib_with_external_headers",
"@envoy//source/common/protobuf:utility_lib_with_external_headers",
Expand Down
7 changes: 5 additions & 2 deletions source/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ bool Main::run() {
stub = std::make_unique<nighthawk::client::NighthawkService::Stub>(channel);
process = std::make_unique<RemoteProcessImpl>(*options_, *stub);
} else {
absl::StatusOr<ProcessPtr> process_or_status =
ProcessImpl::CreateProcessImpl(*options_, time_system);
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config;
Envoy::Network::DnsResolverFactory& dns_resolver_factory =
Envoy::Network::createDefaultDnsResolverFactory(typed_dns_resolver_config);
absl::StatusOr<ProcessPtr> process_or_status = ProcessImpl::CreateProcessImpl(
*options_, dns_resolver_factory, std::move(typed_dns_resolver_config), time_system);
if (!process_or_status.ok()) {
ENVOY_LOG(error, "Unable to create ProcessImpl: {}", process_or_status.status().ToString());
return false;
Expand Down
21 changes: 14 additions & 7 deletions source/client/process_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Cluster createNighthawkClusterForWorker(const Client::Options& options,
// Resolves all the extracted URIs.
absl::Status extractAndResolveUrisFromOptions(Envoy::Event::Dispatcher& dispatcher,
const Client::Options& options,
Envoy::Network::DnsResolver& dns_resolver,
std::vector<UriPtr>* uris,
UriPtr* request_source_uri) {
try {
Expand All @@ -196,12 +197,14 @@ absl::Status extractAndResolveUrisFromOptions(Envoy::Event::Dispatcher& dispatch
}
}
for (const UriPtr& uri : *uris) {
uri->resolve(dispatcher, Utility::translateFamilyOptionString(options.addressFamily()));
uri->resolve(dispatcher, dns_resolver,
Utility::translateFamilyOptionString(options.addressFamily()));
}
if (options.requestSource() != "") {
*request_source_uri = std::make_unique<UriImpl>(options.requestSource());
(*request_source_uri)
->resolve(dispatcher, Utility::translateFamilyOptionString(options.addressFamily()));
->resolve(dispatcher, dns_resolver,
Utility::translateFamilyOptionString(options.addressFamily()));
}
} catch (const UriException& ex) {
return absl::InvalidArgumentError(
Expand All @@ -214,13 +217,17 @@ absl::Status extractAndResolveUrisFromOptions(Envoy::Event::Dispatcher& dispatch

} // namespace

absl::StatusOr<Bootstrap> createBootstrapConfiguration(Envoy::Event::Dispatcher& dispatcher,
const Client::Options& options,
int number_of_workers) {
absl::StatusOr<Bootstrap> createBootstrapConfiguration(
Envoy::Event::Dispatcher& dispatcher, Envoy::Api::Api& api, const Client::Options& options,
Envoy::Network::DnsResolverFactory& dns_resolver_factory,
const envoy::config::core::v3::TypedExtensionConfig& typed_dns_resolver_config,
int number_of_workers) {
Envoy::Network::DnsResolverSharedPtr dns_resolver =
dns_resolver_factory.createDnsResolver(dispatcher, api, typed_dns_resolver_config);
std::vector<UriPtr> uris;
UriPtr request_source_uri;
absl::Status uri_status =
extractAndResolveUrisFromOptions(dispatcher, options, &uris, &request_source_uri);
absl::Status uri_status = extractAndResolveUrisFromOptions(dispatcher, options, *dns_resolver,
&uris, &request_source_uri);
if (!uri_status.ok()) {
return uri_status;
}
Expand Down
15 changes: 11 additions & 4 deletions source/client/process_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "external/envoy/source/common/common/statusor.h"
#include "external/envoy/source/common/event/dispatcher_impl.h"
#include "external/envoy/source/common/network/dns_resolver/dns_factory.h"
#include "external/envoy_api/envoy/config/bootstrap/v3/bootstrap.pb.h"

namespace Nighthawk {
Expand All @@ -16,15 +17,21 @@ namespace Nighthawk {
* specified uris.
*
* @param dispatcher is used when resolving hostnames to IP addresses in the
bootstrap.
* bootstrap.
* @param options are the options this Nighthawk execution was triggered with.
* @param dns_resolver_factory used to create a DNS resolver to resolve hostnames
* in the bootstrap.
* @param typed_dns_resolver_config config used when creating dns_resolver_factory,
* also needed when creating the resolver.
* @param number_of_workers indicates how many Nighthawk workers will be
* upstreaming requests. A separate cluster is generated for each worker.
*
* @return the created bootstrap configuration.
*/
absl::StatusOr<envoy::config::bootstrap::v3::Bootstrap>
createBootstrapConfiguration(Envoy::Event::Dispatcher& dispatcher, const Client::Options& options,
int number_of_workers);
absl::StatusOr<envoy::config::bootstrap::v3::Bootstrap> createBootstrapConfiguration(
Envoy::Event::Dispatcher& dispatcher, Envoy::Api::Api& api, const Client::Options& options,
Envoy::Network::DnsResolverFactory& dns_resolver_factory,
const envoy::config::core::v3::TypedExtensionConfig& typed_dns_resolver_config,
int number_of_workers);

} // namespace Nighthawk
38 changes: 24 additions & 14 deletions source/client/process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "external/envoy/source/common/event/real_time_system.h"
#include "external/envoy/source/common/init/manager_impl.h"
#include "external/envoy/source/common/local_info/local_info_impl.h"
#include "external/envoy/source/common/network/dns_resolver/dns_factory.h"
#include "external/envoy/source/common/network/utility.h"
#include "external/envoy/source/common/runtime/runtime_impl.h"
#include "external/envoy/source/common/singleton/manager_impl.h"
Expand Down Expand Up @@ -160,6 +161,8 @@ class ClusterManagerFactory : public Envoy::Upstream::ProdClusterManagerFactory
};

ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system,
Envoy::Network::DnsResolverFactory& dns_resolver_factory,
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config,
const std::shared_ptr<Envoy::ProcessWide>& process_wide)
: options_(options), number_of_workers_(BootstrapFactory::determineConcurrency(options_)),
process_wide_(process_wide == nullptr ? std::make_shared<Envoy::ProcessWide>()
Expand All @@ -181,6 +184,8 @@ ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_
singleton_manager_(std::make_unique<Envoy::Singleton::ManagerImpl>(api_->threadFactory())),
access_log_manager_(std::chrono::milliseconds(1000), *api_, *dispatcher_, access_log_lock_,
store_root_),
dns_resolver_factory_(dns_resolver_factory),
typed_dns_resolver_config_(std::move(typed_dns_resolver_config)),
init_watcher_("Nighthawk", []() {}),
admin_(Envoy::Network::Address::InstanceConstSharedPtr()),
validation_context_(false, false, false), router_context_(store_root_.symbolTable()) {
Expand All @@ -191,13 +196,18 @@ ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_
configureComponentLogLevels(spdlog::level::from_str(lower));
}

absl::StatusOr<ProcessPtr>
ProcessImpl::CreateProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system,
const std::shared_ptr<Envoy::ProcessWide>& process_wide) {
std::unique_ptr<ProcessImpl> process(new ProcessImpl(options, time_system, process_wide));
absl::StatusOr<ProcessPtr> ProcessImpl::CreateProcessImpl(
const Options& options, Envoy::Network::DnsResolverFactory& dns_resolver_factory,
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config,
Envoy::Event::TimeSystem& time_system,
const std::shared_ptr<Envoy::ProcessWide>& process_wide) {
std::unique_ptr<ProcessImpl> process(new ProcessImpl(options, time_system, dns_resolver_factory,
std::move(typed_dns_resolver_config),
process_wide));

absl::StatusOr<Bootstrap> bootstrap = createBootstrapConfiguration(
*process->dispatcher_, process->options_, process->number_of_workers_);
*process->dispatcher_, *process->api_, process->options_, process->dns_resolver_factory_,
process->typed_dns_resolver_config_, process->number_of_workers_);
if (!bootstrap.ok()) {
ENVOY_LOG(error, "Failed to create bootstrap configuration: {}", bootstrap.status().message());
process->shutdown();
Expand Down Expand Up @@ -429,6 +439,7 @@ void ProcessImpl::setupStatsSinks(const envoy::config::bootstrap::v3::Bootstrap&
}

bool ProcessImpl::runInternal(OutputCollector& collector, const UriPtr& tracing_uri,
Envoy::Network::DnsResolverSharedPtr dns_resolver,
const absl::optional<Envoy::SystemTime>& scheduled_start) {
const Envoy::SystemTime now = time_system_.systemTime();
if (scheduled_start.value_or(now) < now) {
Expand Down Expand Up @@ -459,19 +470,16 @@ bool ProcessImpl::runInternal(OutputCollector& collector, const UriPtr& tracing_
std::make_unique<Envoy::Extensions::TransportSockets::Tls::ContextManagerImpl>(
time_system_);

::envoy::config::core::v3::DnsResolverOptions dns_options;
const Envoy::OptionsImpl::HotRestartVersionCb hot_restart_version_cb = [](bool) {
return "hot restart is disabled";
};
const Envoy::OptionsImpl envoy_options(
/* args = */ {"process_impl"}, hot_restart_version_cb, spdlog::level::info);
envoy::config::core::v3::DnsResolverOptions dns_resolver_options;
cluster_manager_factory_ = std::make_unique<ClusterManagerFactory>(
admin_, Envoy::Runtime::LoaderSingleton::get(), store_root_, tls_,
dispatcher_->createDnsResolver({}, dns_resolver_options), *ssl_context_manager_,
*dispatcher_, *local_info_, secret_manager_, validation_context_, *api_, http_context_,
grpc_context_, router_context_, access_log_manager_, *singleton_manager_, envoy_options,
quic_stat_names_);
admin_, Envoy::Runtime::LoaderSingleton::get(), store_root_, tls_, dns_resolver,
*ssl_context_manager_, *dispatcher_, *local_info_, secret_manager_, validation_context_,
*api_, http_context_, grpc_context_, router_context_, access_log_manager_,
*singleton_manager_, envoy_options, quic_stat_names_);
cluster_manager_factory_->setConnectionReuseStrategy(
options_.h1ConnectionReuseStrategy() == nighthawk::client::H1ConnectionReuseStrategy::LRU
? Http1PoolImpl::ConnectionReuseStrategy::LRU
Expand Down Expand Up @@ -575,10 +583,12 @@ bool ProcessImpl::runInternal(OutputCollector& collector, const UriPtr& tracing_
bool ProcessImpl::run(OutputCollector& collector) {
UriPtr tracing_uri;

Envoy::Network::DnsResolverSharedPtr dns_resolver =
dns_resolver_factory_.createDnsResolver(*dispatcher_, *api_, typed_dns_resolver_config_);
try {
if (options_.trace() != "") {
tracing_uri = std::make_unique<UriImpl>(options_.trace());
tracing_uri->resolve(*dispatcher_,
tracing_uri->resolve(*dispatcher_, *dns_resolver,
Utility::translateFamilyOptionString(options_.addressFamily()));
}
} catch (const UriException& ex) {
Expand All @@ -590,7 +600,7 @@ bool ProcessImpl::run(OutputCollector& collector) {
}

try {
return runInternal(collector, tracing_uri, options_.scheduled_start());
return runInternal(collector, tracing_uri, dns_resolver, options_.scheduled_start());
} catch (Envoy::EnvoyException& ex) {
ENVOY_LOG(error, "Fatal exception: {}", ex.what());
throw;
Expand Down
18 changes: 16 additions & 2 deletions source/client/process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "external/envoy/source/common/event/real_time_system.h"
#include "external/envoy/source/common/grpc/context_impl.h"
#include "external/envoy/source/common/http/context_impl.h"
#include "external/envoy/source/common/network/dns_resolver/dns_factory.h"
#include "external/envoy/source/common/protobuf/message_validator_impl.h"
#include "external/envoy/source/common/quic/quic_stat_names.h"
#include "external/envoy/source/common/router/context_impl.h"
Expand Down Expand Up @@ -55,6 +56,10 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
/**
* Creates a ProcessImpl.
* @param options provides the options configuration to be used.
* @param dns_resolver_factory provides a pluggable factory to create a DNS resolver to look up
* DNS names within the bootstrap.
* @param typed_dns_resolver_config the config used when creating dns_resolver_factory, to also
* be passed in when creating a resolver.
* @param time_system provides the Envoy::Event::TimeSystem implementation that will be used.
* @param process_wide optional parameter which can be used to pass a pre-setup reference to
* an active Envoy::ProcessWide instance. ProcessImpl will add a reference to this when passed,
Expand All @@ -63,7 +68,10 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
* instance.
*/
static absl::StatusOr<ProcessPtr>
CreateProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system,
CreateProcessImpl(const Options& options,
Envoy::Network::DnsResolverFactory& dns_resolver_factory,
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config,
Envoy::Event::TimeSystem& time_system,
const std::shared_ptr<Envoy::ProcessWide>& process_wide = nullptr);

~ProcessImpl() override;
Expand All @@ -87,6 +95,8 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
private:
// Use CreateProcessImpl to construct an instance of ProcessImpl.
ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system,
Envoy::Network::DnsResolverFactory& dns_resolver_factory,
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config,
const std::shared_ptr<Envoy::ProcessWide>& process_wide = nullptr);

void addTracingCluster(envoy::config::bootstrap::v3::Bootstrap& bootstrap, const Uri& uri) const;
Expand Down Expand Up @@ -115,6 +125,7 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
void setupStatsSinks(const envoy::config::bootstrap::v3::Bootstrap& bootstrap,
std::list<std::unique_ptr<Envoy::Stats::Sink>>& stats_sinks);
bool runInternal(OutputCollector& collector, const UriPtr& tracing_uri,
Envoy::Network::DnsResolverSharedPtr dns_resolver,
const absl::optional<Envoy::SystemTime>& schedule);

/**
Expand Down Expand Up @@ -169,7 +180,6 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
const TerminationPredicateFactoryImpl termination_predicate_factory_;
const SequencerFactoryImpl sequencer_factory_;
const RequestSourceFactoryImpl request_generator_factory_;

Envoy::Init::ManagerImpl init_manager_;
Envoy::LocalInfo::LocalInfoPtr local_info_;
Envoy::Random::RandomGeneratorImpl generator_;
Expand All @@ -180,6 +190,10 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
Envoy::Thread::MutexBasicLockable access_log_lock_;
Envoy::Singleton::ManagerPtr singleton_manager_;
Envoy::AccessLog::AccessLogManagerImpl access_log_manager_;
Envoy::Network::DnsResolverFactory& dns_resolver_factory_;
// Config that was used to create dns_resolver_factory_. Also must be provided when creating a
// resolver.
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config_;

std::unique_ptr<Envoy::Extensions::TransportSockets::Tls::ContextManagerImpl>
ssl_context_manager_;
Expand Down
8 changes: 6 additions & 2 deletions source/client/service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ void ServiceImpl::handleExecutionRequest(const nighthawk::client::ExecutionReque
writeResponse(response);
return;
}
envoy::config::core::v3::TypedExtensionConfig typed_dns_resolver_config;
Envoy::Network::DnsResolverFactory& dns_resolver_factory =
Envoy::Network::createDefaultDnsResolverFactory(typed_dns_resolver_config);

absl::StatusOr<ProcessPtr> process_or_status =
ProcessImpl::CreateProcessImpl(*options, time_system_, process_wide_);
absl::StatusOr<ProcessPtr> process_or_status = ProcessImpl::CreateProcessImpl(
*options, dns_resolver_factory, std::move(typed_dns_resolver_config), time_system_,
process_wide_);
if (!process_or_status.ok()) {
response.mutable_error_detail()->set_code(grpc::StatusCode::INTERNAL);
response.mutable_error_detail()->set_message(
Expand Down
Loading