-
Notifications
You must be signed in to change notification settings - Fork 5.4k
hot restart: conditionally build hot restart #1365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mattklein123
merged 10 commits into
envoyproxy:master
from
turbinelabs:osx-2-hot_restart
Aug 5, 2017
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b9e1553
hot restart: conditionally remove hot restart based on build time fla…
zuercher 9b8bc5b
cleanup conditional exec of hotrestart_test
zuercher f594a5f
remove unused rule
zuercher a1fc2eb
fix file formatting
zuercher 06a7976
move HotRestartImpl to source/common/hot_restart
zuercher 2186752
cleanup namespaces
zuercher b6cd328
fix format
zuercher 81f84d5
move HotRestart[Nop]Impl to Envoy::Server
zuercher a758256
Merge branch 'master' into osx-2-hot_restart
zuercher f6484ae
remove stray namespaces
zuercher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,6 @@ | |
| # Where the runfiles are for tests. | ||
| export TEST_RUNDIR="${TEST_SRCDIR}/${TEST_WORKSPACE}" | ||
|
|
||
| cd $(dirname "$0") | ||
|
|
||
| "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #include "exe/hot_restart.h" | ||
| #include "server/hot_restart_impl.h" | ||
|
|
||
| #include <signal.h> | ||
| #include <sys/mman.h> | ||
|
|
||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "envoy/server/hot_restart.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Server { | ||
|
|
||
| /** | ||
| * No-op implementation of HotRestart. | ||
| */ | ||
| class HotRestartNopImpl : public Server::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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come
envoy_sh_testneeded modification in this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to pass the output of bazel
select()toenvoy_sh_test's srcs parameter to conditionally disable the the hot restart test. However,selectonly functions when it's passed to a rule.envoy_sh_testis 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 setsTEST_RUNDIRto"${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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, cc_configure.bzl defines a
repository_rule, which gets arepository_ctxobject that contains the os information.sh_test(which is the ruleenvoy_sh_testeventually creates) is a regular rule. Regular rules get actxobject, 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
ctxobject does have avarsdict 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_testwith the features available inctx. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zuercher thanks for trying so hard to figure this out, but I think you have done enough. If this causes issues for the Google import they have the expertise to fix if needed as @htuch said.