-
Notifications
You must be signed in to change notification settings - Fork 84
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
CLI - cancel execution upon signal reception #367
Conversation
In preparation of sharing functionality for signal handling, extract what we have right now into SignalHandler. Status: draft For fixing envoyproxy#280 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…ndler Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…ndler Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…ation Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…ation Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@eric846 please review and assign to me once ready. |
…ation Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
cluster_manager_ = cluster_manager_factory_->clusterManagerFromProto(bootstrap); | ||
maybeCreateTracingDriver(bootstrap.tracing()); | ||
cluster_manager_->setInitializedCb([this]() -> void { init_manager_.initialize(init_watcher_); }); | ||
{ |
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.
Note to reviewers: The "hide whitespace" toggle in Github makes this a lot more fun to review.
(The scope introduced for the lock guard introduces a lot of whitespace noise).
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Thanks @eric846 for the review. Just marked this as ready for another pass |
source/client/client.cc
Outdated
@@ -73,7 +74,12 @@ bool Main::run() { | |||
} | |||
OutputFormatterFactoryImpl output_formatter_factory; | |||
OutputCollectorImpl output_collector(time_system, *options_); | |||
const bool res = process->run(output_collector); | |||
bool res; |
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.
(nit) If we can, we should try to avoid abbreviations in variable names (res).
source/client/remote_process_impl.cc
Outdated
@@ -54,5 +54,11 @@ bool RemoteProcessImpl::run(OutputCollector& collector) { | |||
return false; | |||
} | |||
|
|||
bool RemoteProcessImpl::requestExecutionCancellation() { | |||
ENVOY_LOG(error, "Remote process cancellation not supported yet"); | |||
// TODO(XXX): Send a cancel request to the gRPC service. |
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.
Did we want to replace XXX with a value?
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 filed #380 (and updated XXX
to #380
) in the changes I'm about to push.
@@ -99,7 +101,7 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger | |||
void maybeCreateTracingDriver(const envoy::config::trace::v3::Tracing& configuration); | |||
|
|||
void configureComponentLogLevels(spdlog::level::level_enum level); | |||
const std::vector<ClientWorkerPtr>& createWorkers(const uint32_t concurrency); | |||
void createWorkers(const uint32_t concurrency); |
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.
(optional) Is this a good time to document the method?
@@ -654,6 +658,34 @@ def test_http_request_release_timing(http_test_server_fixture, qps_parameterizat | |||
assertCounterEqual(counters, "benchmark.http_2xx", (total_requests)) | |||
|
|||
|
|||
def send_sigterm(p): | |||
# Sleep for a while, under tsan the client needs a lot of time |
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.
Can we add a Python style docstring, since the function is public.
@@ -654,6 +658,34 @@ def test_http_request_release_timing(http_test_server_fixture, qps_parameterizat | |||
assertCounterEqual(counters, "benchmark.http_2xx", (total_requests)) | |||
|
|||
|
|||
def send_sigterm(p): |
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.
Can we choose a more readable name than "p".
stdout, stderr = client_process.communicate() | ||
client_process.wait() | ||
output = stdout.decode('utf-8') | ||
assert (client_process.returncode == 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.
Can we add a custom error message giving some context?
Or should this be a regular test assertion like below?
if (do_cancel) { | ||
cancel_thread = std::thread([&process, terminate_right_away] { | ||
if (!terminate_right_away) { | ||
sleep(5); |
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.
Should we add a comment explaining the sleep and the choice of 5?
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Teach the CLI to handle SIGTERM/SIGINT, and handle those as a request to gracefully cancel execution. Partially resolves envoyproxy#280
Teach the CLI to handle SIGTERM/SIGINT, and handle those as a request to
gracefully cancel execution.
Partially resolves #280