-
Notifications
You must be signed in to change notification settings - Fork 83
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
gRPC service logging bugfix #363
Conversation
This makes the gRPC service log more then one ExecutionStream requests. The log level used will be controlled by the options associated to ExecutionStream requests. This change also incorporates a change to avoid creating multiple instances of Envoy::ProcessWide in the Nighthawk gRPC service flow. This doesn't seem to address any know issues, but it seems to be more along the way Envoy::ProcessWide was intended to be used. Fixes envoyproxy#289 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@@ -33,11 +33,7 @@ void ServiceImpl::handleExecutionRequest(const nighthawk::client::ExecutionReque | |||
return; | |||
} | |||
|
|||
ProcessImpl process(*options, time_system_); |
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 fix is to not do this here. We do this once now at construction time, and hold on to the logging context throughout the lifetime of the ServiceImpl
.
Note that ProcessImpl
instantiations will change the log level per inbound configured options. We only allow one ProcessImpl
instantiation at a time today, so this might be allright for now.
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
: time_system_(time_system), stats_allocator_(symbol_table_), store_root_(stats_allocator_), | ||
ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system, | ||
const std::shared_ptr<Envoy::ProcessWide>& process_wide) | ||
: process_wide_(process_wide == nullptr ? std::make_shared<Envoy::ProcessWide>() |
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.
Unsure about the context - do we need to worry about thread safety here or is ProcessImpl guaranteed to be constructed from a single thread?
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.
All ProcessImpl
clients should ensure there's only a single active instance at any given time. We don't have to worry about it.
@@ -92,8 +92,11 @@ class ClusterManagerFactory : public Envoy::Upstream::ProdClusterManagerFactory | |||
bool prefetch_connections_{}; | |||
}; | |||
|
|||
ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system) | |||
: time_system_(time_system), stats_allocator_(symbol_table_), store_root_(stats_allocator_), | |||
ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system, |
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.
Is there any way how we can add test coverage for this change to keep the fixed functionality working?
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.
Actually, yes. Lacking C++ mocks for the logging, we can't easily unit-test this issue.
But I could add an end-to-end integration test for this, see 619c05e
@@ -46,7 +46,8 @@ class ClusterManagerFactory; | |||
*/ | |||
class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger::Id::main> { | |||
public: | |||
ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system); | |||
ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system, |
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 doc comment? We could also explain the optional process_wide argument and say what happens if it isn't provided.
@@ -26,6 +28,10 @@ class ServiceImpl final : public nighthawk::client::NighthawkService::Service, | |||
public Envoy::Logger::Loggable<Envoy::Logger::Id::main> { | |||
|
|||
public: | |||
ServiceImpl() : process_wide_(std::make_shared<Envoy::ProcessWide>()) { |
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 doc comment for the public constructor?
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@mum4k thanks for the review; comments addressed! |
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.
Thank you. One remaining nit.
@@ -39,6 +39,7 @@ def __init__(self, | |||
assert ip_version != IpVersion.UNKNOWN | |||
self.server_port = 0 | |||
self.server_ip = server_ip | |||
self.log_lines = None |
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) Does this need to be public or would self._log_lines do? If public, can we document it above in the Attributes: section of the class docstring?
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.
Well, it gets consumed over at https://github.com/envoyproxy/nighthawk/pull/363/files#diff-9620177d1b84e578a841abdc925dcdf4R33. So it needs to be public, and documented. I'll add that.
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.
Done in 593fe3c (also moved the line that resets the log to None
to a better place).
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
This makes the gRPC service log more then one ExecutionStream requests.
The log level used will be controlled by the options associated to
ExecutionStream requests (possible candidate for improvement later on).
This change also incorporates a change to avoid creating multiple instances
of Envoy::ProcessWide in the Nighthawk gRPC service flow.
This doesn't seem to address any know issues, but it seems to be more along
the way Envoy::ProcessWide was intended to be used.
Fixes #289
Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com