hot restart: conditionally build hot restart#1365
hot restart: conditionally build hot restart#1365mattklein123 merged 10 commits intoenvoyproxy:masterfrom
Conversation
…g/architecture Use --define=hotrestart=disabled to disable hot restart in a build. Hot restart is permanently disabled for OS X.
mattklein123
left a comment
There was a problem hiding this comment.
Again thanks for splitting out. Generally LGTM, a few small comments.
source/exe/hot_restart_nop.h
Outdated
| @@ -0,0 +1,39 @@ | |||
| #pragma once | |||
|
|
|||
| #include <fcntl.h> | |||
There was a problem hiding this comment.
I think many/all of these includes are not needed?
| @@ -0,0 +1,39 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
in an optimal world, this hot_restart_nop.h would also be used by the test code which does the same thing. You would need to rejigger slightly and maybe put this in source/common/hot_restart/hot_restart_nop.h. It's not a huge deal but if you feel like it.
source/exe/main.cc
Outdated
| #ifdef ENVOY_HOT_RESTART | ||
| const std::string& shared_mem_version = Envoy::Server::SharedMemory::version(); | ||
| #else | ||
| const std::string& shared_mem_version = "disabled"; |
There was a problem hiding this comment.
technically you are taking a reference to a temporary here. I would probably just define on the previous line and then take a reference to it.
source/exe/main_common.cc
Outdated
|
|
||
| #ifdef ENVOY_HOT_RESTART | ||
| #include "exe/hot_restart.h" | ||
| #endif |
There was a problem hiding this comment.
I left it in now that it's under common. I could add an #ifndef ENVOY_HOT_RESTART, but I don't think it hurts anything to leave it.
test/integration/hotrestart_test.sh
Outdated
|
|
||
| set -e | ||
|
|
||
| if [[ -f "test/integration/hotrestart_disabled" ]]; then |
There was a problem hiding this comment.
See my comments on the use of test tags and interpretation in envoy_build_system.bzl as one possible option.
htuch
left a comment
There was a problem hiding this comment.
Thanks for splitting this out and generalizing to non-OS X.
test/integration/hotrestart_test.sh
Outdated
|
|
||
| set -e | ||
|
|
||
| if [[ -f "test/integration/hotrestart_disabled" ]]; then |
There was a problem hiding this comment.
This should probably be "${TEST_RUNDIR}"/test/integration/hotrestart_disabled
test/integration/BUILD
Outdated
| name = "hotrestart_test_disabled", | ||
| outs = ["hotrestart_disabled"], | ||
| cmd = "touch $@", | ||
| ) |
There was a problem hiding this comment.
I think a possibly more elegant way to handle this might be to use Bazel tags. If you had tags = ["hot_restart"] on the hotrestart_test, you could have the rules in envoy_build_system.bzl pick up on this and completely skip defining the test on OS X. That's provided there is some way in Skylark to figure out which platform you are on.
There was a problem hiding this comment.
I can't figure out how to do this with tags.
The closest I've gotten is to rewrite envoy_sh_test to not access srcs in a way that prevents select from working. I'll push it in a bit.
source/exe/BUILD
Outdated
| name = "hot_restart_lib", | ||
| srcs = ["hot_restart.cc"], | ||
| hdrs = ["hot_restart.h"], | ||
| srcs = select({ |
There was a problem hiding this comment.
Can you define a function in envoy_build_system.bzl which is basically something like:
def select_hotrestart(xs):
return select({
"//bazel:disable_hot_restart": [],
"@bazel_tools//tools/osx:darwin": [],
"//conditions:default": xs,
})
This might make the various sites this appears at cleaner.
| # Where the runfiles are for tests. | ||
| export TEST_RUNDIR="${TEST_SRCDIR}/${TEST_WORKSPACE}" | ||
|
|
||
| cd $(dirname "$0") |
There was a problem hiding this comment.
Because the envoy_sh_test srcs don't get run through $(location) anymore, I did this. There's probably a better way.
There was a problem hiding this comment.
How come envoy_sh_test needed modification in this PR?
There was a problem hiding this comment.
I wanted to pass the output of bazel select() to envoy_sh_test's srcs parameter to conditionally disable the the hot restart test. However, select only functions when it's passed to a rule. envoy_sh_test is a macro and was trying to inspect srcs (something like "$(location " + srcs[0] + ")"), which doesn't work.
I switched those lines to use "$(SRCS)" or to just pass srcs directly, but the different is the absence of the relative path on the front of the filenames.
There was a problem hiding this comment.
So, a few of things:
-
This might break the Google import, as this is making an assumption about file layout relative to where the source file is. Does something like
cd "${TEST_RUNDIR}"work instead? -
There should be a cleaner way to disable the test than totally removing its sources. I still think tags is one way to manage this, if there's a way in
envoy_sh_testto figure out if we're on OS X or not. https://github.com/lyft/envoy/blob/master/bazel/cc_configure.bzl#L30 does this basically, but does so in a repository rule context. So it's possible in Bazel.. -
Nit: `cd "$(dirname "$0")"
There was a problem hiding this comment.
I can rewrite the cd command as cd "$(dirname "${TEST_RUNDIR}"/${TEST_BINARY}")".
Ultimately, the files specified in srcs end up in "${TEST_SRCDIR}"/"${TEST_WORKSPACE}"/path/to/file (see https://docs.bazel.build/versions/master/build-ref.html#data). The script sets TEST_RUNDIR to "${TEST_SRCDIR}"/"${TEST_WORKSPACE}". The path/to/file here is test/integration. But envoy_sh_test is also used for //test/tools/router_check/test:router_tool_test, which will use a different path.
I've no doubt bazel is capable of doing what you want, I just don't understand how to do it. I've spent quite a bit of time reading Bazel docs. The only way to access the repository context, that I know of, is to write a custom rule, so I guess I'll try that again.
There was a problem hiding this comment.
Let's go with what you have there right now and then we can try and figure this out during the Google import, fix upstream if necessary.
There was a problem hiding this comment.
So, cc_configure.bzl defines a repository_rule, which gets a repository_ctx object that contains the os information.
sh_test (which is the rule envoy_sh_test eventually creates) is a regular rule. Regular rules get a ctx object, which does not contain os information. In any event, it's not really OS that we want to key on but whether or not hot restart has been disabled for the build.
The ctx object does have a vars dict which contains "hot_restart": "disabled" when building hot restart is disabled, but entry that won't exist on OS X, since I'm trying to disable hot restart there by default (as it won't even compile). I suppose we could say that building on OS X requires explicitly disabling the feature with a command line flag.
At that point, I'm left writing a rule that duplicates the functionality of sh_test with the features available in ctx. And at that point I'm stuck. I can get it to run the wrapper script and am left concatenating strings to try to reproduce the TEST_XXX environment variables that the test depends on. In particular, a value for TEST_TMPDIR just doesn't seem to be available.
In the end, even if I got that to work, it's not at all clear to me that it's better.
There was a problem hiding this comment.
I tried one other way, which is to use the fact that a test with tags = ["manual"] will not be included when running tests with wildcards (e.g. bazel test //test/...).
My idea was to pass a select() to tags and add the manual tag when hot restart is disabled. But that's not supported either:
/Users/stephan/workspace/turbinelabs-envoy/test/integration/BUILD:14:1: //test/integration:hotrestart_test: attribute "tags" is not configurable.
source/exe/BUILD
Outdated
| ) | ||
|
|
||
| envoy_cc_library( | ||
| name = "hot_restart_lib", |
There was a problem hiding this comment.
Could also move this to source/common/hot_restart.
| #include "envoy/server/hot_restart.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Server { |
There was a problem hiding this comment.
nit: can we change namespace to HotRestart here and in the other moved file?
source/common/hot_restart/BUILD
Outdated
| @@ -0,0 +1,35 @@ | |||
| licenses(["notice"]) # Apache 2 | |||
There was a problem hiding this comment.
@zuercher I feel really, really bad asking this, and I should have noticed before, but IMO the hot restart files should actually go in source/server, with namespace moved back to Server. This is so that we don't reach from common code back into server which we have been not doing so far (like for options). If you don't want to do this I can clean it up later. Sorry.
source/server/hot_restart_impl.cc
Outdated
| const uint64_t SharedMemory::VERSION = 8; | ||
|
|
||
| SharedMemory& SharedMemory::initialize(Options& options) { | ||
| SharedMemory& SharedMemory::initialize(Server::Options& options) { |
There was a problem hiding this comment.
nit: you should be able to revert all of the Server:: changes from these two moved files (h/cc).
|
+1 on thanks for doing the investigative leg work here. @zuercher what you say makes sense, I agree that the complexity is unwarranted. We'll deal with this as needed. I've filed bazelbuild/bazel#3510 to track this with the Bazel team, as it seems something they should support to make life easier for the rest of the world that just want a solution that works out of the box. |
) Automatic merge from submit-queue. Add the support of the allow_tls option for Istio authn **What this PR does / why we need it**: This PR adds the support of the allow_tls option for Istio authn. When allow_tls is true, the client certificate does not have to be present. If it is present, it will be extracted after the authentication. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes envoyproxy#1365 **Special notes for your reviewer**: **Release note**: ```release-note ```
(Split out of #1348, part of fixes for #128).
hot restart: conditionally build hot restart based on flag/architecture
Use
--define=hot_restart=disabledto disable hot restart in a build.Hot restart is always disabled for OS X.