server: make the --disable-hot-restart flag functional#2679
server: make the --disable-hot-restart flag functional#2679htuch merged 11 commits intoenvoyproxy:masterfrom
Conversation
…n class. Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
ccaraman
left a comment
There was a problem hiding this comment.
LGTM - This is a really nice clean up!
test/exe/main_common_test.cc
Outdated
| @@ -25,14 +25,25 @@ | |||
|
|
|||
There was a problem hiding this comment.
Can't comment on line 22. The ifdef for ENVOY_HOT_RESTART isn't needed anymore!
There was a problem hiding this comment.
See @mattklein123's comment in #2029
"@tonya11en I would probably leave the compile flag as some people want the ability to just compile out the functionality entirely. I think doing a CLI flag alongside would be pretty straightforward."
There was a problem hiding this comment.
I'm fine letting Matt's opinion stand, but we're not actually compiling out the functionality, we're compiling out the ability to configure the functionality. I think it's cleaner to just have people turn it off but I'll totally merge this as a huge improvement in readability as it stands :-)
There was a problem hiding this comment.
I thought in the old code we actually used the bazel switch to not compile the full hot restart implementation and only compile the NOP implementation. This might not be the case. I don't feel strongly about this either way. If people think it's better to get rid of the compile option we can do that. I suspect almost no one is using that option and as long as we have a clear release note (please check) it's probably OK. If we do that please remember to cleanup the bazel README docs about the option also.
There was a problem hiding this comment.
Ooh, indeed, I was grepping source/... only and missed it in bazel/envoy_build_system.bzl
There was a problem hiding this comment.
I was commenting on the lines 22-24 not being required in this file because the header "#include "server/hot_restart_impl.h"" isn't used in this file.
There was a problem hiding this comment.
Good catch Carmen! Done.
There was a problem hiding this comment.
RE removing the ifdef -- if no one thinks we need this ifdef anymore I'll remove it in a future PR. I think before we do that we just need to first make sure everyone who doesn't want hot-restart sets the new flag (after this is checked in).
test/exe/main_common_test.cc
Outdated
| "/test/config/integration/google_com_proxy_port_0.v2.yaml"; | ||
| const char* argv[] = {"envoy-static", "-c", config_file.c_str(), "--base-id", "2", | ||
| "--disable-hot-restart", nullptr}; | ||
| MainCommon main_common(ARRAY_SIZE(argv) - 1, const_cast<char**>(argv)); |
There was a problem hiding this comment.
nit/curious - would wrapping these in EXPECT_NO_THROW make the test clearer that it is expected that these construct with no issue? (Context for my question - I was doing a quick look for EXPECT_... and got lost for a few seconds. :) )
There was a problem hiding this comment.
seems reasonable. I guess if it threw otherwise it would stop all the tests in the file?
…cting MainCommon. Signed-off-by: Joshua Marantz <jmarantz@google.com>
…RESTART is disabled. Signed-off-by: Joshua Marantz <jmarantz@google.com>
…ild. Signed-off-by: Joshua Marantz <jmarantz@google.com>
alyssawilk
left a comment
There was a problem hiding this comment.
Code otherwise LGTM, once you have the tests fixed up
…throw in CI. Signed-off-by: Joshua Marantz <jmarantz@google.com>
…sts on the same machine. Signed-off-by: Joshua Marantz <jmarantz@google.com>
test/exe/main_common_test.cc
Outdated
| MainCommonTest() | ||
| : config_file_(Envoy::TestEnvironment::getCheckedEnvVar("TEST_RUNDIR") + | ||
| "/test/config/integration/google_com_proxy_port_0.v2.yaml"), | ||
| random_string_(fmt::format("{}", random_generator_.random() % 1024)), |
There was a problem hiding this comment.
It's probably worth pointing out here that (a) I refactored the test so it has a test-class, to share the argv prep code, which became more complex when I added randomized base-IDs.
I needed to add randomized base-IDs to get tests to pass consistently under CI; the theory being that CI was instantiating more than one test at a time on a machine, and things were conflicting. I wasn't sure what the range of 'base-id' was so I made it 0-1023. Comments welcome.
There was a problem hiding this comment.
I think this comment would be useful in the file itself.
There was a problem hiding this comment.
Indeed, good call. I added a class comment and also factored out the base-id string generation. Also after chatting with @htuch about why this was needed, I decided getpid() was the critical component of the ID, so I combined it in. Looking at the base-id impl, we have a full uint32_t to play with, but I decided to give more of the bits to the pid() in my choice of prime.
…e're doing it. Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
test/exe/main_common_test.cc
Outdated
|
|
||
| // Adds an argument, assuring that argv remains null-terminated. | ||
| void addArg(const char* arg) { | ||
| argv_[argv_.size() - 1] = arg; |
There was a problem hiding this comment.
nit: maybe comment that this doesn't lead to undefined behevior because it is replacing the nullptr?
There was a problem hiding this comment.
done; added some asserts too.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
htuch
left a comment
There was a problem hiding this comment.
LGTM with a couple of quick fix comments.
test/exe/main_common_test.cc
Outdated
| // Pick a prime number to give more of the 32-bits of entropy to the PID, and the | ||
| // remainder to the random number. | ||
| const uint32_t four_digit_prime = 7919; | ||
| return getpid() * four_digit_prime + random_generator_.random() % four_digit_prime; |
There was a problem hiding this comment.
This seems overkill; i would either just use the PID or random(), I don't think we're benefiting that much from combining.
| std::vector<const char*> argv_; | ||
| }; | ||
|
|
||
| TEST_F(MainCommonTest, ConstructDestructHotRestartEnabled) { |
There was a problem hiding this comment.
Please add a single line explanation of what the test is designed to do.
test/exe/main_common_test.cc
Outdated
| // Adds an argument, assuring that argv remains null-terminated. | ||
| void addArg(const char* arg) { | ||
| ASSERT(!argv_.empty()); | ||
| size_t last = argv_.size() - 1; |
…uniquification. Signed-off-by: Joshua Marantz <jmarantz@google.com>
While we figure out and fix envoyproxy/envoy-mobile#2678, this commit reduces the initial_fetch_timeout on the xDS config sources in the integration tests from 15s to 1s, preventing issues like test timeouts. Signed-off-by: Ali Beyad <abeyad@google.com> Signed-off-by: JP Simard <jp@jpsim.com>
While we figure out and fix envoyproxy/envoy-mobile#2678, this commit reduces the initial_fetch_timeout on the xDS config sources in the integration tests from 15s to 1s, preventing issues like test timeouts. Signed-off-by: Ali Beyad <abeyad@google.com> Signed-off-by: JP Simard <jp@jpsim.com>
Description:
The --disable-hot-restart flag was added to the binary in #2576 by @tonya11en but not hooked up (at my request). Now that the main_common refactor is in, it's easier to hook it up. This also offers the opportunity for some minor code simplifications.
Risk Level: Medium -- this affects the startup path.
Testing:
//test/...
added a new subtest to hotrestart_test.sh to cover --disable-hot-restart. I'd appreciate suggestions though on how to cover the functionality more thoroughly...how should I detect from a test that hot restart is disabled?
Release Notes: TBD: I'm not sure if release notes were added already in #2576 -- if not they can be added during this PR review.
*Fixes #2029 -- actually #2576 claims to fix that but I don't think it really does, since in that PR the switch is a no-op.