From b9e155379cc8e34c416d453fde70449f664c56d5 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Mon, 31 Jul 2017 15:50:40 -0700 Subject: [PATCH 1/9] hot restart: conditionally remove hot restart based on build time flag/architecture Use --define=hotrestart=disabled to disable hot restart in a build. Hot restart is permanently disabled for OS X. --- bazel/BUILD | 5 ++++ bazel/README.md | 6 ++++- bazel/envoy_build_system.bzl | 4 +++ source/exe/BUILD | 14 +++++++++-- source/exe/hot_restart_nop.h | 39 +++++++++++++++++++++++++++++ source/exe/main.cc | 24 +++++++++--------- source/exe/main_common.cc | 33 ++++++++++++++++++++---- source/exe/main_common.h | 5 +--- test/integration/BUILD | 12 ++++++++- test/integration/hotrestart_test.sh | 5 ++++ 10 files changed, 122 insertions(+), 25 deletions(-) create mode 100644 source/exe/hot_restart_nop.h diff --git a/bazel/BUILD b/bazel/BUILD index dcaf8989ebfd7..2bb8d27e56d11 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -31,3 +31,8 @@ config_setting( name = "disable_signal_trace", values = {"define": "signal_trace=disabled"}, ) + +config_setting( + name = "disable_hot_restart", + values = {"define": "hot_restart=disabled"}, +) diff --git a/bazel/README.md b/bazel/README.md index 64da2a871fd98..da90ccb8779ec 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -195,7 +195,6 @@ You can use the `-c ` flag to control this, e.g. bazel build -c opt //source/exe:envoy-static ``` - ## Sanitizers To build and run tests with the gcc compiler's [address sanitizer @@ -230,6 +229,11 @@ remove log statements of lower importance during compilation to enhance performa bazel build --copt=-DNVLOG //source/exe:envoy-static ``` +## Hot Restart + +Hot restart can be disabled in any build by specifying `--define=hot_restart=disabled` +on the Bazel command line. + # Release builds diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index 6c213d329e623..f7b688b2e6f47 100644 --- a/bazel/envoy_build_system.bzl +++ b/bazel/envoy_build_system.bzl @@ -24,6 +24,10 @@ def envoy_copts(repository, test = False): }) + select({ repository + "//bazel:disable_signal_trace": [], "//conditions:default": ["-DENVOY_HANDLE_SIGNALS"], + }) + select({ + repository + "//bazel:disable_hot_restart": [], + "@bazel_tools//tools/osx:darwin": [], + "//conditions:default": ["-DENVOY_HOT_RESTART"], }) # Compute the final linkopts based on various options. diff --git a/source/exe/BUILD b/source/exe/BUILD index d6cc85d41c8b4..1482cea379f34 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -81,8 +81,18 @@ envoy_cc_library( envoy_cc_library( name = "hot_restart_lib", - srcs = ["hot_restart.cc"], - hdrs = ["hot_restart.h"], + srcs = select({ + "//bazel:disable_hot_restart": [], + "@bazel_tools//tools/osx:darwin": [], + "//conditions:default": ["hot_restart.cc"], + }), + hdrs = [ + "hot_restart_nop.h", + ] + select({ + "//bazel:disable_hot_restart": [], + "@bazel_tools//tools/osx:darwin": [], + "//conditions:default": ["hot_restart.h"], + }), deps = [ "//include/envoy/event:dispatcher_interface", "//include/envoy/event:file_event_interface", diff --git a/source/exe/hot_restart_nop.h b/source/exe/hot_restart_nop.h new file mode 100644 index 0000000000000..7db7f45202a50 --- /dev/null +++ b/source/exe/hot_restart_nop.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include + +#include "envoy/server/hot_restart.h" +#include "envoy/server/options.h" + +#include "common/common/assert.h" +#include "common/stats/stats_impl.h" + + +namespace Envoy { +namespace Server { + +/** + * No-op implementation of HotRestart. + */ +class HotRestartNopImpl : public HotRestart { +public: + HotRestartNopImpl() { }; + + void drainParentListeners() override {} + int duplicateParentListenSocket(const std::string&) override { return -1; } + void getParentStats(GetParentStatsInfo& info) override { memset(&info, 0, sizeof(info)); } + void initialize(Event::Dispatcher&, Server::Instance&) override {} + void shutdownParentAdmin(ShutdownParentAdminInfo&) override {} + void terminateParent() override {} + void shutdown() override {} + std::string version() override { return "disabled"; } +}; + +} // namespace Server +} // namespace Envoy diff --git a/source/exe/main.cc b/source/exe/main.cc index 90dc80fc236a5..7e602f80f3b18 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -1,13 +1,16 @@ #include #include -#include "exe/hot_restart.h" #include "exe/main_common.h" #ifdef ENVOY_HANDLE_SIGNALS #include "exe/signal_action.h" #endif +#ifdef ENVOY_HOT_RESTART +#include "exe/hot_restart.h" +#endif + #include "server/options_impl.h" #include "spdlog/spdlog.h" @@ -19,7 +22,7 @@ * * This should be used to do setup tasks specific to a particular site's * deployment such as initializing signal handling. It calls main_common - * after setting up command line options and the hot restarter. + * after setting up command line options. */ int main(int argc, char** argv) { #ifdef ENVOY_HANDLE_SIGNALS @@ -27,16 +30,13 @@ int main(int argc, char** argv) { Envoy::SignalAction handle_sigs; #endif - Envoy::OptionsImpl options(argc, argv, Envoy::Server::SharedMemory::version(), - spdlog::level::warn); +#ifdef ENVOY_HOT_RESTART + const std::string& shared_mem_version = Envoy::Server::SharedMemory::version(); +#else + const std::string& shared_mem_version = "disabled"; +#endif - std::unique_ptr restarter; - try { - restarter.reset(new Envoy::Server::HotRestartImpl(options)); - } catch (Envoy::EnvoyException& e) { - std::cerr << "unable to initialize hot restart: " << e.what() << std::endl; - return 1; - } + Envoy::OptionsImpl options(argc, argv, shared_mem_version, spdlog::level::warn); - return Envoy::main_common(options, *restarter); + return Envoy::main_common(options); } diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 95d5515233e3d..8e3f9b874ac9e 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -8,7 +8,10 @@ #include "common/stats/stats_impl.h" #include "common/stats/thread_local_store.h" +#ifdef ENVOY_HOT_RESTART #include "exe/hot_restart.h" +#endif +#include "exe/hot_restart_nop.h" #include "server/config_validation/server.h" #include "server/drain_manager_impl.h" @@ -36,7 +39,27 @@ class ProdComponentFactory : public ComponentFactory { } // namespace Server -int main_common(OptionsImpl& options, Server::HotRestartImpl& restarter) { +int main_common(OptionsImpl& options) { +#ifdef ENVOY_HOT_RESTART + std::unique_ptr restarter; + try { + restarter.reset(new Server::HotRestartImpl(options)); + } catch (Envoy::EnvoyException& e) { + std::cerr << "unable to initialize hot restart: " << e.what() << std::endl; + return 1; + } + + Thread::BasicLockable& log_lock = restarter->logLock(); + Thread::BasicLockable& access_log_lock = restarter->accessLogLock(); + Stats::RawStatDataAllocator &stats_allocator = *restarter; +#else + std::unique_ptr restarter; + restarter.reset(new Server::HotRestartNopImpl()); + + Thread::MutexBasicLockable log_lock, access_log_lock; + Stats::HeapRawStatDataAllocator stats_allocator; +#endif + Event::Libevent::Global::initialize(); Server::ProdComponentFactory component_factory; LocalInfo::LocalInfoImpl local_info( @@ -54,12 +77,12 @@ int main_common(OptionsImpl& options, Server::HotRestartImpl& restarter) { ares_library_init(ARES_LIB_INIT_ALL); - Logger::Registry::initialize(options.logLevel(), restarter.logLock()); + Logger::Registry::initialize(options.logLevel(), log_lock); DefaultTestHooks default_test_hooks; ThreadLocal::InstanceImpl tls; - Stats::ThreadLocalStoreImpl stats_store(restarter); - Server::InstanceImpl server(options, default_test_hooks, restarter, stats_store, - restarter.accessLogLock(), component_factory, local_info, tls); + Stats::ThreadLocalStoreImpl stats_store(stats_allocator); + Server::InstanceImpl server(options, default_test_hooks, *restarter, stats_store, + access_log_lock, component_factory, local_info, tls); server.run(); ares_library_cleanup(); return 0; diff --git a/source/exe/main_common.h b/source/exe/main_common.h index 9b7c27a09275c..89f576ffba6e6 100644 --- a/source/exe/main_common.h +++ b/source/exe/main_common.h @@ -1,7 +1,5 @@ #pragma once -#include "exe/hot_restart.h" - #include "server/options_impl.h" namespace Envoy { @@ -10,9 +8,8 @@ namespace Envoy { * main() runs. * * @param options Options object initialized by site-specific code - * @param restarter HotRestart object initialized in site-specific code. * @return int Return code that should be returned from the actual main() */ -int main_common(Envoy::OptionsImpl& options, Envoy::Server::HotRestartImpl& restarter); +int main_common(Envoy::OptionsImpl& options); } // namespace Envoy diff --git a/test/integration/BUILD b/test/integration/BUILD index 72cda1be4019d..0fe6a0a770eeb 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -10,6 +10,12 @@ load( envoy_package() +native.genrule( + name = "hotrestart_test_disabled", + outs = ["hotrestart_disabled"], + cmd = "touch $@", +) + envoy_sh_test( name = "hotrestart_test", srcs = ["hotrestart_test.sh"], @@ -19,7 +25,11 @@ envoy_sh_test( "//test/common/runtime:filesystem_test_data", "//test/config/integration:server_config_files", "//tools:socket_passing", - ], + ] + select({ + "//bazel:disable_hot_restart": [":hotrestart_test_disabled"], + "@bazel_tools//tools/osx:darwin": [":hotrestart_test_disabled"], + "//conditions:default": [], + }), # Need to disable test execution sandboxing for this test, since it uses shmem. # TODO(htuch): When most folks are using a Bazel with the recent # https://github.com/bazelbuild/bazel/commit/8d739f2fad3fd0135b940170691b0119c5baca1e, diff --git a/test/integration/hotrestart_test.sh b/test/integration/hotrestart_test.sh index 8f96977aa4d10..5059d82f22535 100755 --- a/test/integration/hotrestart_test.sh +++ b/test/integration/hotrestart_test.sh @@ -2,6 +2,11 @@ set -e +if [[ -f "test/integration/hotrestart_disabled" ]]; then + echo "SKIP: hot restart disabled in this build" + exit 0 +fi + [[ -z "${ENVOY_BIN}" ]] && ENVOY_BIN="${TEST_RUNDIR}"/source/exe/envoy-static # TODO(htuch): In this test script, we are duplicating work done in test_environment.cc via sed. From 9b8bc5b24078be18b243d20b344c2f086016cc12 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Tue, 1 Aug 2017 16:01:26 -0700 Subject: [PATCH 2/9] cleanup conditional exec of hotrestart_test --- bazel/envoy_build_system.bzl | 18 +++++++++++------- bazel/sh_test_wrapper.sh | 2 ++ source/common/hot_restart/BUILD | 17 +++++++++++++++++ .../hot_restart}/hot_restart_nop.h | 13 +------------ source/exe/BUILD | 16 ++++------------ source/exe/main.cc | 4 ++-- source/exe/main_common.cc | 2 +- test/integration/BUILD | 10 ++++------ test/integration/hotrestart_test.sh | 5 ----- test/integration/server.cc | 19 ++----------------- 10 files changed, 44 insertions(+), 62 deletions(-) create mode 100644 source/common/hot_restart/BUILD rename source/{exe => common/hot_restart}/hot_restart_nop.h (76%) diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl index f7b688b2e6f47..6107c3327aabf 100644 --- a/bazel/envoy_build_system.bzl +++ b/bazel/envoy_build_system.bzl @@ -24,11 +24,7 @@ def envoy_copts(repository, test = False): }) + select({ repository + "//bazel:disable_signal_trace": [], "//conditions:default": ["-DENVOY_HANDLE_SIGNALS"], - }) + select({ - repository + "//bazel:disable_hot_restart": [], - "@bazel_tools//tools/osx:darwin": [], - "//conditions:default": ["-DENVOY_HOT_RESTART"], - }) + }) + envoy_select_hot_restart(["-DENVOY_HOT_RESTART"]) # Compute the final linkopts based on various options. def envoy_linkopts(): @@ -265,7 +261,7 @@ def envoy_sh_test(name, name = name + "_gen_test_runner", srcs = srcs, outs = [test_runner_cc], - cmd = "$(location //bazel:gen_sh_test_runner.sh) $(location " + srcs[0] + ") >> $@", + cmd = "$(location //bazel:gen_sh_test_runner.sh) $(SRCS) >> $@", tools = ["//bazel:gen_sh_test_runner.sh"], ) envoy_cc_test_library( @@ -279,7 +275,7 @@ def envoy_sh_test(name, name = name, srcs = ["//bazel:sh_test_wrapper.sh"], data = srcs + data, - args = ["$(location " + srcs[0] + ")"], + args = srcs, **kargs ) @@ -336,3 +332,11 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []): cmd = cmd, tools = ["//external:protoc"], ) + +# Selects the given values if hot restart is enabled in the current build. +def envoy_select_hot_restart(xs): + return select({ + "//bazel:disable_hot_restart": [], + "@bazel_tools//tools/osx:darwin": [], + "//conditions:default": xs, + }) diff --git a/bazel/sh_test_wrapper.sh b/bazel/sh_test_wrapper.sh index 17b357b308b53..80df983f9207e 100755 --- a/bazel/sh_test_wrapper.sh +++ b/bazel/sh_test_wrapper.sh @@ -3,4 +3,6 @@ # Where the runfiles are for tests. export TEST_RUNDIR="${TEST_SRCDIR}/${TEST_WORKSPACE}" +cd $(dirname "$0") + "$@" diff --git a/source/common/hot_restart/BUILD b/source/common/hot_restart/BUILD new file mode 100644 index 0000000000000..d93d416f68812 --- /dev/null +++ b/source/common/hot_restart/BUILD @@ -0,0 +1,17 @@ +licenses(["notice"]) # Apache 2 + +load( + "//bazel:envoy_build_system.bzl", + "envoy_cc_library", + "envoy_package", +) + +envoy_package() + +envoy_cc_library( + name = "hot_restart_nop_lib", + hdrs = ["hot_restart_nop.h"], + deps = [ + "//include/envoy/server:hot_restart_interface", + ], +) diff --git a/source/exe/hot_restart_nop.h b/source/common/hot_restart/hot_restart_nop.h similarity index 76% rename from source/exe/hot_restart_nop.h rename to source/common/hot_restart/hot_restart_nop.h index 7db7f45202a50..45a834614bb1d 100644 --- a/source/exe/hot_restart_nop.h +++ b/source/common/hot_restart/hot_restart_nop.h @@ -1,19 +1,8 @@ #pragma once -#include -#include - -#include -#include -#include #include #include "envoy/server/hot_restart.h" -#include "envoy/server/options.h" - -#include "common/common/assert.h" -#include "common/stats/stats_impl.h" - namespace Envoy { namespace Server { @@ -23,7 +12,7 @@ namespace Server { */ class HotRestartNopImpl : public HotRestart { public: - HotRestartNopImpl() { }; + HotRestartNopImpl(){}; void drainParentListeners() override {} int duplicateParentListenSocket(const std::string&) override { return -1; } diff --git a/source/exe/BUILD b/source/exe/BUILD index 1482cea379f34..d7e2464e1f797 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -5,6 +5,7 @@ load( "envoy_cc_binary", "envoy_cc_library", "envoy_package", + "envoy_select_hot_restart", ) envoy_package() @@ -75,24 +76,15 @@ envoy_cc_library( ":envoy_common_lib", ":hot_restart_lib", "//source/common/common:compiler_requirements_lib", + "//source/common/hot_restart:hot_restart_nop_lib", "//source/server/config_validation:server_lib", ], ) envoy_cc_library( name = "hot_restart_lib", - srcs = select({ - "//bazel:disable_hot_restart": [], - "@bazel_tools//tools/osx:darwin": [], - "//conditions:default": ["hot_restart.cc"], - }), - hdrs = [ - "hot_restart_nop.h", - ] + select({ - "//bazel:disable_hot_restart": [], - "@bazel_tools//tools/osx:darwin": [], - "//conditions:default": ["hot_restart.h"], - }), + srcs = envoy_select_hot_restart(["hot_restart.cc"]), + hdrs = envoy_select_hot_restart(["hot_restart.h"]), deps = [ "//include/envoy/event:dispatcher_interface", "//include/envoy/event:file_event_interface", diff --git a/source/exe/main.cc b/source/exe/main.cc index 7e602f80f3b18..b35b82dbb4ebd 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -31,9 +31,9 @@ int main(int argc, char** argv) { #endif #ifdef ENVOY_HOT_RESTART - const std::string& shared_mem_version = Envoy::Server::SharedMemory::version(); + const std::string shared_mem_version = Envoy::Server::SharedMemory::version(); #else - const std::string& shared_mem_version = "disabled"; + const std::string shared_mem_version = "disabled"; #endif Envoy::OptionsImpl options(argc, argv, shared_mem_version, spdlog::level::warn); diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 8e3f9b874ac9e..c6ae3b5e93cd0 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -3,6 +3,7 @@ #include "common/common/compiler_requirements.h" #include "common/event/libevent.h" +#include "common/hot_restart/hot_restart_nop.h" #include "common/local_info/local_info_impl.h" #include "common/network/utility.h" #include "common/stats/stats_impl.h" @@ -11,7 +12,6 @@ #ifdef ENVOY_HOT_RESTART #include "exe/hot_restart.h" #endif -#include "exe/hot_restart_nop.h" #include "server/config_validation/server.h" #include "server/drain_manager_impl.h" diff --git a/test/integration/BUILD b/test/integration/BUILD index 0fe6a0a770eeb..9bf8ac04fae45 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -6,6 +6,7 @@ load( "envoy_cc_test_library", "envoy_package", "envoy_sh_test", + "envoy_select_hot_restart", ) envoy_package() @@ -18,18 +19,14 @@ native.genrule( envoy_sh_test( name = "hotrestart_test", - srcs = ["hotrestart_test.sh"], + srcs = envoy_select_hot_restart(["hotrestart_test.sh"]), data = [ "//source/exe:envoy-static", "//test/common/runtime:filesystem_setup.sh", "//test/common/runtime:filesystem_test_data", "//test/config/integration:server_config_files", "//tools:socket_passing", - ] + select({ - "//bazel:disable_hot_restart": [":hotrestart_test_disabled"], - "@bazel_tools//tools/osx:darwin": [":hotrestart_test_disabled"], - "//conditions:default": [], - }), + ], # Need to disable test execution sandboxing for this test, since it uses shmem. # TODO(htuch): When most folks are using a Bazel with the recent # https://github.com/bazelbuild/bazel/commit/8d739f2fad3fd0135b940170691b0119c5baca1e, @@ -139,6 +136,7 @@ envoy_cc_test_library( "//source/common/common:assert_lib", "//source/common/common:logger_lib", "//source/common/common:thread_lib", + "//source/common/hot_restart:hot_restart_nop_lib", "//source/common/http:codec_client_lib", "//source/common/http:header_map_lib", "//source/common/http:headers_lib", diff --git a/test/integration/hotrestart_test.sh b/test/integration/hotrestart_test.sh index 5059d82f22535..8f96977aa4d10 100755 --- a/test/integration/hotrestart_test.sh +++ b/test/integration/hotrestart_test.sh @@ -2,11 +2,6 @@ set -e -if [[ -f "test/integration/hotrestart_disabled" ]]; then - echo "SKIP: hot restart disabled in this build" - exit 0 -fi - [[ -z "${ENVOY_BIN}" ]] && ENVOY_BIN="${TEST_RUNDIR}"/source/exe/envoy-static # TODO(htuch): In this test script, we are duplicating work done in test_environment.cc via sed. diff --git a/test/integration/server.cc b/test/integration/server.cc index cc97bb1450ef7..042d032dc1c6f 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -5,6 +5,7 @@ #include "envoy/http/header_map.h" #include "envoy/server/hot_restart.h" +#include "common/hot_restart/hot_restart_nop.h" #include "common/local_info/local_info_impl.h" #include "common/network/utility.h" #include "common/stats/thread_local_store.h" @@ -17,22 +18,6 @@ #include "gtest/gtest.h" namespace Envoy { -namespace Server { - -class TestHotRestart : public HotRestart { -public: - // Server::HotRestart - void drainParentListeners() override {} - int duplicateParentListenSocket(const std::string&) override { return -1; } - void getParentStats(GetParentStatsInfo& info) override { memset(&info, 0, sizeof(info)); } - void initialize(Event::Dispatcher&, Server::Instance&) override {} - void shutdownParentAdmin(ShutdownParentAdminInfo&) override {} - void terminateParent() override {} - void shutdown() override {} - std::string version() override { return "1"; } -}; - -} // namespace Server IntegrationTestServerPtr IntegrationTestServer::create(const std::string& config_path, const Network::Address::IpVersion version) { @@ -90,7 +75,7 @@ void IntegrationTestServer::onWorkerListenerRemoved() { void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion version) { Server::TestOptionsImpl options(config_path_); - Server::TestHotRestart restarter; + Server::HotRestartNopImpl restarter; Thread::MutexBasicLockable lock; LocalInfo::LocalInfoImpl local_info(Network::Utility::getLocalAddress(version), "zone_name", "cluster_name", "node_name"); From f594a5f942b2ce938f05ad10011c2edc692cde41 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Tue, 1 Aug 2017 16:43:50 -0700 Subject: [PATCH 3/9] remove unused rule --- test/integration/BUILD | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/integration/BUILD b/test/integration/BUILD index 9bf8ac04fae45..57ba87b437f00 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -11,12 +11,6 @@ load( envoy_package() -native.genrule( - name = "hotrestart_test_disabled", - outs = ["hotrestart_disabled"], - cmd = "touch $@", -) - envoy_sh_test( name = "hotrestart_test", srcs = envoy_select_hot_restart(["hotrestart_test.sh"]), From a1fc2eb4f2439cf8990fcbc5ea284dd23d5b237b Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Tue, 1 Aug 2017 19:45:06 -0700 Subject: [PATCH 4/9] fix file formatting --- source/exe/main_common.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index c6ae3b5e93cd0..c910f2bc3c829 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -51,7 +51,7 @@ int main_common(OptionsImpl& options) { Thread::BasicLockable& log_lock = restarter->logLock(); Thread::BasicLockable& access_log_lock = restarter->accessLogLock(); - Stats::RawStatDataAllocator &stats_allocator = *restarter; + Stats::RawStatDataAllocator& stats_allocator = *restarter; #else std::unique_ptr restarter; restarter.reset(new Server::HotRestartNopImpl()); @@ -81,8 +81,8 @@ int main_common(OptionsImpl& options) { DefaultTestHooks default_test_hooks; ThreadLocal::InstanceImpl tls; Stats::ThreadLocalStoreImpl stats_store(stats_allocator); - Server::InstanceImpl server(options, default_test_hooks, *restarter, stats_store, - access_log_lock, component_factory, local_info, tls); + Server::InstanceImpl server(options, default_test_hooks, *restarter, stats_store, access_log_lock, + component_factory, local_info, tls); server.run(); ares_library_cleanup(); return 0; From 06a7976097a5ec172efd684517b8c75bf8d38578 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Thu, 3 Aug 2017 11:27:08 -0700 Subject: [PATCH 5/9] move HotRestartImpl to source/common/hot_restart --- source/common/hot_restart/BUILD | 18 +++++++++++++++ .../hot_restart}/hot_restart.cc | 2 +- .../{exe => common/hot_restart}/hot_restart.h | 0 source/exe/BUILD | 22 ++----------------- source/exe/main.cc | 3 ++- source/exe/main_common.cc | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) rename source/{exe => common/hot_restart}/hot_restart.cc (99%) rename source/{exe => common/hot_restart}/hot_restart.h (100%) diff --git a/source/common/hot_restart/BUILD b/source/common/hot_restart/BUILD index d93d416f68812..fd8e18bf624ec 100644 --- a/source/common/hot_restart/BUILD +++ b/source/common/hot_restart/BUILD @@ -4,10 +4,28 @@ load( "//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package", + "envoy_select_hot_restart", ) envoy_package() +envoy_cc_library( + name = "hot_restart_lib", + srcs = envoy_select_hot_restart(["hot_restart.cc"]), + hdrs = envoy_select_hot_restart(["hot_restart.h"]), + deps = [ + "//include/envoy/event:dispatcher_interface", + "//include/envoy/event:file_event_interface", + "//include/envoy/server:hot_restart_interface", + "//include/envoy/server:instance_interface", + "//include/envoy/server:options_interface", + "//source/common/common:assert_lib", + "//source/common/common:utility_lib", + "//source/common/network:utility_lib", + "//source/common/stats:stats_lib", + ], +) + envoy_cc_library( name = "hot_restart_nop_lib", hdrs = ["hot_restart_nop.h"], diff --git a/source/exe/hot_restart.cc b/source/common/hot_restart/hot_restart.cc similarity index 99% rename from source/exe/hot_restart.cc rename to source/common/hot_restart/hot_restart.cc index 0f8516fd41764..4a725a30d9aa9 100644 --- a/source/exe/hot_restart.cc +++ b/source/common/hot_restart/hot_restart.cc @@ -1,4 +1,4 @@ -#include "exe/hot_restart.h" +#include "common/hot_restart/hot_restart.h" #include #include diff --git a/source/exe/hot_restart.h b/source/common/hot_restart/hot_restart.h similarity index 100% rename from source/exe/hot_restart.h rename to source/common/hot_restart/hot_restart.h diff --git a/source/exe/BUILD b/source/exe/BUILD index d7e2464e1f797..4d042e9abb459 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -5,7 +5,6 @@ load( "envoy_cc_binary", "envoy_cc_library", "envoy_package", - "envoy_select_hot_restart", ) envoy_package() @@ -58,8 +57,8 @@ envoy_cc_library( srcs = ["main.cc"], deps = [ ":envoy_main_common_lib", - ":hot_restart_lib", "//source/server:options_lib", + "//source/common/hot_restart:hot_restart_lib", "//source/server/config/http:lightstep_lib", "//source/server/config/http:zipkin_lib", ] + select({ @@ -74,30 +73,13 @@ envoy_cc_library( hdrs = ["main_common.h"], deps = [ ":envoy_common_lib", - ":hot_restart_lib", "//source/common/common:compiler_requirements_lib", + "//source/common/hot_restart:hot_restart_lib", "//source/common/hot_restart:hot_restart_nop_lib", "//source/server/config_validation:server_lib", ], ) -envoy_cc_library( - name = "hot_restart_lib", - srcs = envoy_select_hot_restart(["hot_restart.cc"]), - hdrs = envoy_select_hot_restart(["hot_restart.h"]), - deps = [ - "//include/envoy/event:dispatcher_interface", - "//include/envoy/event:file_event_interface", - "//include/envoy/server:hot_restart_interface", - "//include/envoy/server:instance_interface", - "//include/envoy/server:options_interface", - "//source/common/common:assert_lib", - "//source/common/common:utility_lib", - "//source/common/network:utility_lib", - "//source/common/stats:stats_lib", - ], -) - envoy_cc_library( name = "sigaction_lib", srcs = ["signal_action.cc"], diff --git a/source/exe/main.cc b/source/exe/main.cc index b35b82dbb4ebd..5555d712314ba 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -8,7 +8,7 @@ #endif #ifdef ENVOY_HOT_RESTART -#include "exe/hot_restart.h" +#include "common/hot_restart/hot_restart.h" #endif #include "server/options_impl.h" @@ -31,6 +31,7 @@ int main(int argc, char** argv) { #endif #ifdef ENVOY_HOT_RESTART + // Enabled by default, except on OS X. Control with "bazel --define=hot_restart=disabled" const std::string shared_mem_version = Envoy::Server::SharedMemory::version(); #else const std::string shared_mem_version = "disabled"; diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index c910f2bc3c829..637f49a2975f1 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -10,7 +10,7 @@ #include "common/stats/thread_local_store.h" #ifdef ENVOY_HOT_RESTART -#include "exe/hot_restart.h" +#include "common/hot_restart/hot_restart.h" #endif #include "server/config_validation/server.h" From 21867526a6c24103b637022cb56ed3af497113cb Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Thu, 3 Aug 2017 11:59:04 -0700 Subject: [PATCH 6/9] cleanup namespaces --- source/common/hot_restart/hot_restart.cc | 8 ++++---- source/common/hot_restart/hot_restart.h | 12 ++++++------ source/common/hot_restart/hot_restart_nop.h | 6 +++--- source/exe/main.cc | 2 +- source/exe/main_common.cc | 8 ++++---- test/integration/server.cc | 3 +-- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/source/common/hot_restart/hot_restart.cc b/source/common/hot_restart/hot_restart.cc index 4a725a30d9aa9..aa7f1e02e5204 100644 --- a/source/common/hot_restart/hot_restart.cc +++ b/source/common/hot_restart/hot_restart.cc @@ -21,13 +21,13 @@ #include "spdlog/spdlog.h" namespace Envoy { -namespace Server { +namespace HotRestart { // Increment this whenever there is a shared memory / RPC change that will prevent a hot restart // from working. Operations code can then cope with this and do a full restart. const uint64_t SharedMemory::VERSION = 8; -SharedMemory& SharedMemory::initialize(Options& options) { + SharedMemory& SharedMemory::initialize(Server::Options& options) { int flags = O_RDWR; std::string shmem_name = fmt::format("/envoy_shared_memory_{}", options.baseId()); if (options.restartEpoch() == 0) { @@ -88,7 +88,7 @@ void SharedMemory::initializeMutex(pthread_mutex_t& mutex) { std::string SharedMemory::version() { return fmt::format("{}.{}", VERSION, sizeof(SharedMemory)); } -HotRestartImpl::HotRestartImpl(Options& options) +HotRestartImpl::HotRestartImpl(Server::Options& options) : options_(options), shmem_(SharedMemory::initialize(options)), log_lock_(shmem_.log_lock_), access_log_lock_(shmem_.access_log_lock_), stat_lock_(shmem_.stat_lock_), init_lock_(shmem_.init_lock_) { @@ -435,5 +435,5 @@ void HotRestartImpl::shutdown() { socket_event_.reset(); } std::string HotRestartImpl::version() { return SharedMemory::version(); } -} // namespace Server +} // namespace HotRestart } // namespace Envoy diff --git a/source/common/hot_restart/hot_restart.h b/source/common/hot_restart/hot_restart.h index a653928fff8ef..216ef5565ea45 100644 --- a/source/common/hot_restart/hot_restart.h +++ b/source/common/hot_restart/hot_restart.h @@ -15,7 +15,7 @@ #include "common/stats/stats_impl.h" namespace Envoy { -namespace Server { +namespace HotRestart { /** * Shared memory segment. This structure is laid directly into shared memory and is used amongst @@ -36,7 +36,7 @@ class SharedMemory { * Initialize the shared memory segment, depending on whether we should be the first running * envoy, or a host restarted envoy process. */ - static SharedMemory& initialize(Options& options); + static SharedMemory& initialize(Server::Options& options); /** * Initialize a pthread mutex for process shared locking. @@ -102,11 +102,11 @@ class ProcessSharedMutex : public Thread::BasicLockable { /** * Implementation of HotRestart built for Linux. */ -class HotRestartImpl : public HotRestart, +class HotRestartImpl : public Server::HotRestart, public Stats::RawStatDataAllocator, Logger::Loggable { public: - HotRestartImpl(Options& options); + HotRestartImpl(Server::Options& options); Thread::BasicLockable& logLock() { return log_lock_; } Thread::BasicLockable& accessLogLock() { return access_log_lock_; } @@ -186,7 +186,7 @@ class HotRestartImpl : public HotRestart, RpcBase* receiveRpc(bool block); void sendMessage(sockaddr_un& address, RpcBase& rpc); - Options& options_; + Server::Options& options_; SharedMemory& shmem_; ProcessSharedMutex log_lock_; ProcessSharedMutex access_log_lock_; @@ -201,5 +201,5 @@ class HotRestartImpl : public HotRestart, bool parent_terminated_{}; }; -} // namespace Server +} // namespace HotRestart } // namespace Envoy diff --git a/source/common/hot_restart/hot_restart_nop.h b/source/common/hot_restart/hot_restart_nop.h index 45a834614bb1d..37373b1ede6a9 100644 --- a/source/common/hot_restart/hot_restart_nop.h +++ b/source/common/hot_restart/hot_restart_nop.h @@ -5,12 +5,12 @@ #include "envoy/server/hot_restart.h" namespace Envoy { -namespace Server { +namespace HotRestart { /** * No-op implementation of HotRestart. */ -class HotRestartNopImpl : public HotRestart { +class HotRestartNopImpl : public Server::HotRestart { public: HotRestartNopImpl(){}; @@ -24,5 +24,5 @@ class HotRestartNopImpl : public HotRestart { std::string version() override { return "disabled"; } }; -} // namespace Server +} // namespace HotRestart } // namespace Envoy diff --git a/source/exe/main.cc b/source/exe/main.cc index 5555d712314ba..292a71d148757 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -32,7 +32,7 @@ int main(int argc, char** argv) { #ifdef ENVOY_HOT_RESTART // Enabled by default, except on OS X. Control with "bazel --define=hot_restart=disabled" - const std::string shared_mem_version = Envoy::Server::SharedMemory::version(); + const std::string shared_mem_version = Envoy::HotRestart::SharedMemory::version(); #else const std::string shared_mem_version = "disabled"; #endif diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 637f49a2975f1..e8570372bc770 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -41,9 +41,9 @@ class ProdComponentFactory : public ComponentFactory { int main_common(OptionsImpl& options) { #ifdef ENVOY_HOT_RESTART - std::unique_ptr restarter; + std::unique_ptr restarter; try { - restarter.reset(new Server::HotRestartImpl(options)); + restarter.reset(new HotRestart::HotRestartImpl(options)); } catch (Envoy::EnvoyException& e) { std::cerr << "unable to initialize hot restart: " << e.what() << std::endl; return 1; @@ -53,8 +53,8 @@ int main_common(OptionsImpl& options) { Thread::BasicLockable& access_log_lock = restarter->accessLogLock(); Stats::RawStatDataAllocator& stats_allocator = *restarter; #else - std::unique_ptr restarter; - restarter.reset(new Server::HotRestartNopImpl()); + std::unique_ptr restarter; + restarter.reset(new HotRestart::HotRestartNopImpl()); Thread::MutexBasicLockable log_lock, access_log_lock; Stats::HeapRawStatDataAllocator stats_allocator; diff --git a/test/integration/server.cc b/test/integration/server.cc index 042d032dc1c6f..918b0ba71bd2e 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -3,7 +3,6 @@ #include #include "envoy/http/header_map.h" -#include "envoy/server/hot_restart.h" #include "common/hot_restart/hot_restart_nop.h" #include "common/local_info/local_info_impl.h" @@ -75,7 +74,7 @@ void IntegrationTestServer::onWorkerListenerRemoved() { void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion version) { Server::TestOptionsImpl options(config_path_); - Server::HotRestartNopImpl restarter; + HotRestart::HotRestartNopImpl restarter; Thread::MutexBasicLockable lock; LocalInfo::LocalInfoImpl local_info(Network::Utility::getLocalAddress(version), "zone_name", "cluster_name", "node_name"); From b6cd328386c2cc9d887347710d77c1e83cff9e57 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Thu, 3 Aug 2017 12:11:59 -0700 Subject: [PATCH 7/9] fix format --- source/common/hot_restart/hot_restart.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/hot_restart/hot_restart.cc b/source/common/hot_restart/hot_restart.cc index aa7f1e02e5204..64be2ca57f4e8 100644 --- a/source/common/hot_restart/hot_restart.cc +++ b/source/common/hot_restart/hot_restart.cc @@ -27,7 +27,7 @@ namespace HotRestart { // from working. Operations code can then cope with this and do a full restart. const uint64_t SharedMemory::VERSION = 8; - SharedMemory& SharedMemory::initialize(Server::Options& options) { +SharedMemory& SharedMemory::initialize(Server::Options& options) { int flags = O_RDWR; std::string shmem_name = fmt::format("/envoy_shared_memory_{}", options.baseId()); if (options.restartEpoch() == 0) { From 81f84d5abfcae0c79140814ed3ad2e8089149c51 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Fri, 4 Aug 2017 09:29:09 -0700 Subject: [PATCH 8/9] move HotRestart[Nop]Impl to Envoy::Server --- source/common/hot_restart/BUILD | 35 ------------------- source/exe/BUILD | 6 ++-- source/exe/main.cc | 4 +-- source/exe/main_common.cc | 18 +++++----- source/server/BUILD | 26 ++++++++++++++ .../hot_restart_impl.cc} | 6 ++-- .../hot_restart_impl.h} | 4 +-- .../hot_restart_nop_impl.h} | 4 +-- test/integration/BUILD | 2 +- test/integration/server.cc | 5 +-- 10 files changed, 51 insertions(+), 59 deletions(-) delete mode 100644 source/common/hot_restart/BUILD rename source/{common/hot_restart/hot_restart.cc => server/hot_restart_impl.cc} (99%) rename source/{common/hot_restart/hot_restart.h => server/hot_restart_impl.h} (99%) rename source/{common/hot_restart/hot_restart_nop.h => server/hot_restart_nop_impl.h} (93%) diff --git a/source/common/hot_restart/BUILD b/source/common/hot_restart/BUILD deleted file mode 100644 index fd8e18bf624ec..0000000000000 --- a/source/common/hot_restart/BUILD +++ /dev/null @@ -1,35 +0,0 @@ -licenses(["notice"]) # Apache 2 - -load( - "//bazel:envoy_build_system.bzl", - "envoy_cc_library", - "envoy_package", - "envoy_select_hot_restart", -) - -envoy_package() - -envoy_cc_library( - name = "hot_restart_lib", - srcs = envoy_select_hot_restart(["hot_restart.cc"]), - hdrs = envoy_select_hot_restart(["hot_restart.h"]), - deps = [ - "//include/envoy/event:dispatcher_interface", - "//include/envoy/event:file_event_interface", - "//include/envoy/server:hot_restart_interface", - "//include/envoy/server:instance_interface", - "//include/envoy/server:options_interface", - "//source/common/common:assert_lib", - "//source/common/common:utility_lib", - "//source/common/network:utility_lib", - "//source/common/stats:stats_lib", - ], -) - -envoy_cc_library( - name = "hot_restart_nop_lib", - hdrs = ["hot_restart_nop.h"], - deps = [ - "//include/envoy/server:hot_restart_interface", - ], -) diff --git a/source/exe/BUILD b/source/exe/BUILD index 4d042e9abb459..cc6a084fb599e 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -57,8 +57,8 @@ envoy_cc_library( srcs = ["main.cc"], deps = [ ":envoy_main_common_lib", + "//source/server:hot_restart_lib", "//source/server:options_lib", - "//source/common/hot_restart:hot_restart_lib", "//source/server/config/http:lightstep_lib", "//source/server/config/http:zipkin_lib", ] + select({ @@ -74,8 +74,8 @@ envoy_cc_library( deps = [ ":envoy_common_lib", "//source/common/common:compiler_requirements_lib", - "//source/common/hot_restart:hot_restart_lib", - "//source/common/hot_restart:hot_restart_nop_lib", + "//source/server:hot_restart_lib", + "//source/server:hot_restart_nop_lib", "//source/server/config_validation:server_lib", ], ) diff --git a/source/exe/main.cc b/source/exe/main.cc index 292a71d148757..4b9dc0fa7fc52 100644 --- a/source/exe/main.cc +++ b/source/exe/main.cc @@ -8,7 +8,7 @@ #endif #ifdef ENVOY_HOT_RESTART -#include "common/hot_restart/hot_restart.h" +#include "server/hot_restart_impl.h" #endif #include "server/options_impl.h" @@ -32,7 +32,7 @@ int main(int argc, char** argv) { #ifdef ENVOY_HOT_RESTART // Enabled by default, except on OS X. Control with "bazel --define=hot_restart=disabled" - const std::string shared_mem_version = Envoy::HotRestart::SharedMemory::version(); + const std::string shared_mem_version = Envoy::Server::SharedMemory::version(); #else const std::string shared_mem_version = "disabled"; #endif diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index e8570372bc770..ece0e31f40ffc 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -3,22 +3,22 @@ #include "common/common/compiler_requirements.h" #include "common/event/libevent.h" -#include "common/hot_restart/hot_restart_nop.h" #include "common/local_info/local_info_impl.h" #include "common/network/utility.h" #include "common/stats/stats_impl.h" #include "common/stats/thread_local_store.h" -#ifdef ENVOY_HOT_RESTART -#include "common/hot_restart/hot_restart.h" -#endif - #include "server/config_validation/server.h" #include "server/drain_manager_impl.h" +#include "server/hot_restart_nop_impl.h" #include "server/options_impl.h" #include "server/server.h" #include "server/test_hooks.h" +#ifdef ENVOY_HOT_RESTART +#include "server/hot_restart_impl.h" +#endif + #include "ares.h" namespace Envoy { @@ -41,9 +41,9 @@ class ProdComponentFactory : public ComponentFactory { int main_common(OptionsImpl& options) { #ifdef ENVOY_HOT_RESTART - std::unique_ptr restarter; + std::unique_ptr restarter; try { - restarter.reset(new HotRestart::HotRestartImpl(options)); + restarter.reset(new Server::HotRestartImpl(options)); } catch (Envoy::EnvoyException& e) { std::cerr << "unable to initialize hot restart: " << e.what() << std::endl; return 1; @@ -53,8 +53,8 @@ int main_common(OptionsImpl& options) { Thread::BasicLockable& access_log_lock = restarter->accessLogLock(); Stats::RawStatDataAllocator& stats_allocator = *restarter; #else - std::unique_ptr restarter; - restarter.reset(new HotRestart::HotRestartNopImpl()); + std::unique_ptr restarter; + restarter.reset(new Server::HotRestartNopImpl()); Thread::MutexBasicLockable log_lock, access_log_lock; Stats::HeapRawStatDataAllocator stats_allocator; diff --git a/source/server/BUILD b/source/server/BUILD index 9f688fd5fc738..3156b9c3d61a5 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -4,6 +4,7 @@ load( "//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package", + "envoy_select_hot_restart", ) envoy_package() @@ -94,6 +95,31 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "hot_restart_lib", + srcs = envoy_select_hot_restart(["hot_restart_impl.cc"]), + hdrs = envoy_select_hot_restart(["hot_restart_impl.h"]), + deps = [ + "//include/envoy/event:dispatcher_interface", + "//include/envoy/event:file_event_interface", + "//include/envoy/server:hot_restart_interface", + "//include/envoy/server:instance_interface", + "//include/envoy/server:options_interface", + "//source/common/common:assert_lib", + "//source/common/common:utility_lib", + "//source/common/network:utility_lib", + "//source/common/stats:stats_lib", + ], +) + +envoy_cc_library( + name = "hot_restart_nop_lib", + hdrs = ["hot_restart_nop_impl.h"], + deps = [ + "//include/envoy/server:hot_restart_interface", + ], +) + envoy_cc_library( name = "init_manager_lib", srcs = ["init_manager_impl.cc"], diff --git a/source/common/hot_restart/hot_restart.cc b/source/server/hot_restart_impl.cc similarity index 99% rename from source/common/hot_restart/hot_restart.cc rename to source/server/hot_restart_impl.cc index 64be2ca57f4e8..a47cd0089d5b8 100644 --- a/source/common/hot_restart/hot_restart.cc +++ b/source/server/hot_restart_impl.cc @@ -1,4 +1,4 @@ -#include "common/hot_restart/hot_restart.h" +#include "server/hot_restart_impl.h" #include #include @@ -21,7 +21,7 @@ #include "spdlog/spdlog.h" namespace Envoy { -namespace HotRestart { +namespace Server { // Increment this whenever there is a shared memory / RPC change that will prevent a hot restart // from working. Operations code can then cope with this and do a full restart. @@ -435,5 +435,5 @@ void HotRestartImpl::shutdown() { socket_event_.reset(); } std::string HotRestartImpl::version() { return SharedMemory::version(); } -} // namespace HotRestart +} // namespace Server } // namespace Envoy diff --git a/source/common/hot_restart/hot_restart.h b/source/server/hot_restart_impl.h similarity index 99% rename from source/common/hot_restart/hot_restart.h rename to source/server/hot_restart_impl.h index 216ef5565ea45..a9b9dbacd6972 100644 --- a/source/common/hot_restart/hot_restart.h +++ b/source/server/hot_restart_impl.h @@ -15,7 +15,7 @@ #include "common/stats/stats_impl.h" namespace Envoy { -namespace HotRestart { +namespace Server { /** * Shared memory segment. This structure is laid directly into shared memory and is used amongst @@ -201,5 +201,5 @@ class HotRestartImpl : public Server::HotRestart, bool parent_terminated_{}; }; -} // namespace HotRestart +} // namespace Server } // namespace Envoy diff --git a/source/common/hot_restart/hot_restart_nop.h b/source/server/hot_restart_nop_impl.h similarity index 93% rename from source/common/hot_restart/hot_restart_nop.h rename to source/server/hot_restart_nop_impl.h index 37373b1ede6a9..bbf479733ab99 100644 --- a/source/common/hot_restart/hot_restart_nop.h +++ b/source/server/hot_restart_nop_impl.h @@ -5,7 +5,7 @@ #include "envoy/server/hot_restart.h" namespace Envoy { -namespace HotRestart { +namespace Server { /** * No-op implementation of HotRestart. @@ -24,5 +24,5 @@ class HotRestartNopImpl : public Server::HotRestart { std::string version() override { return "disabled"; } }; -} // namespace HotRestart +} // namespace Server } // namespace Envoy diff --git a/test/integration/BUILD b/test/integration/BUILD index 57ba87b437f00..fb4228c6086dc 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -130,7 +130,6 @@ envoy_cc_test_library( "//source/common/common:assert_lib", "//source/common/common:logger_lib", "//source/common/common:thread_lib", - "//source/common/hot_restart:hot_restart_nop_lib", "//source/common/http:codec_client_lib", "//source/common/http:header_map_lib", "//source/common/http:headers_lib", @@ -145,6 +144,7 @@ envoy_cc_test_library( "//source/common/upstream:upstream_includes", "//source/common/upstream:upstream_lib", "//source/server:connection_handler_lib", + "//source/server:hot_restart_nop_lib", "//source/server:server_lib", "//source/server:test_hooks_lib", "//source/server/config/http:buffer_lib", diff --git a/test/integration/server.cc b/test/integration/server.cc index 918b0ba71bd2e..c9a7c311ab9c3 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -4,12 +4,13 @@ #include "envoy/http/header_map.h" -#include "common/hot_restart/hot_restart_nop.h" #include "common/local_info/local_info_impl.h" #include "common/network/utility.h" #include "common/stats/thread_local_store.h" #include "common/thread_local/thread_local_impl.h" +#include "server/hot_restart_nop_impl.h" + #include "test/integration/integration.h" #include "test/integration/utility.h" #include "test/test_common/environment.h" @@ -74,7 +75,7 @@ void IntegrationTestServer::onWorkerListenerRemoved() { void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion version) { Server::TestOptionsImpl options(config_path_); - HotRestart::HotRestartNopImpl restarter; + Server::HotRestartNopImpl restarter; Thread::MutexBasicLockable lock; LocalInfo::LocalInfoImpl local_info(Network::Utility::getLocalAddress(version), "zone_name", "cluster_name", "node_name"); From f6484ae3d3200bd2b05a022435f5ef7e814171a4 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Fri, 4 Aug 2017 16:59:40 -0700 Subject: [PATCH 9/9] remove stray namespaces --- source/server/hot_restart_impl.cc | 4 ++-- source/server/hot_restart_impl.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/server/hot_restart_impl.cc b/source/server/hot_restart_impl.cc index a47cd0089d5b8..cf0bd601491dd 100644 --- a/source/server/hot_restart_impl.cc +++ b/source/server/hot_restart_impl.cc @@ -27,7 +27,7 @@ namespace Server { // from working. Operations code can then cope with this and do a full restart. const uint64_t SharedMemory::VERSION = 8; -SharedMemory& SharedMemory::initialize(Server::Options& options) { +SharedMemory& SharedMemory::initialize(Options& options) { int flags = O_RDWR; std::string shmem_name = fmt::format("/envoy_shared_memory_{}", options.baseId()); if (options.restartEpoch() == 0) { @@ -88,7 +88,7 @@ void SharedMemory::initializeMutex(pthread_mutex_t& mutex) { std::string SharedMemory::version() { return fmt::format("{}.{}", VERSION, sizeof(SharedMemory)); } -HotRestartImpl::HotRestartImpl(Server::Options& options) +HotRestartImpl::HotRestartImpl(Options& options) : options_(options), shmem_(SharedMemory::initialize(options)), log_lock_(shmem_.log_lock_), access_log_lock_(shmem_.access_log_lock_), stat_lock_(shmem_.stat_lock_), init_lock_(shmem_.init_lock_) { diff --git a/source/server/hot_restart_impl.h b/source/server/hot_restart_impl.h index a9b9dbacd6972..a653928fff8ef 100644 --- a/source/server/hot_restart_impl.h +++ b/source/server/hot_restart_impl.h @@ -36,7 +36,7 @@ class SharedMemory { * Initialize the shared memory segment, depending on whether we should be the first running * envoy, or a host restarted envoy process. */ - static SharedMemory& initialize(Server::Options& options); + static SharedMemory& initialize(Options& options); /** * Initialize a pthread mutex for process shared locking. @@ -102,11 +102,11 @@ class ProcessSharedMutex : public Thread::BasicLockable { /** * Implementation of HotRestart built for Linux. */ -class HotRestartImpl : public Server::HotRestart, +class HotRestartImpl : public HotRestart, public Stats::RawStatDataAllocator, Logger::Loggable { public: - HotRestartImpl(Server::Options& options); + HotRestartImpl(Options& options); Thread::BasicLockable& logLock() { return log_lock_; } Thread::BasicLockable& accessLogLock() { return access_log_lock_; } @@ -186,7 +186,7 @@ class HotRestartImpl : public Server::HotRestart, RpcBase* receiveRpc(bool block); void sendMessage(sockaddr_un& address, RpcBase& rpc); - Server::Options& options_; + Options& options_; SharedMemory& shmem_; ProcessSharedMutex log_lock_; ProcessSharedMutex access_log_lock_;