-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
server: warn on admin mutations, GET requests, add mocking of messages #2912
Conversation
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
… initialization. Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
…a test to be more intuitive. Signed-off-by: Joshua Marantz <[email protected]>
source/common/common/logger.cc
Outdated
// | ||
// TODO(jmarantz): filesystem file write should take string_view. Adding that requires | ||
// finding a way to make that work for mocked filesystem writes. | ||
log_file_->write(std::string(msg)); |
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.
This is resolved in #2916 -- the second PR to go in should eliminate this conversion.
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.
cleaned up now.
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.
TWIMC: I am looking at the coverage compile failure now. But this should mostly be reviewable.
…he gmock types. Note: clang worked, but g++ is needed for coverage. Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Signed-off-by: Joshua Marantz <[email protected]>
Demonstrates common code across multiple filters. Signed-off-by: Matt Klein <[email protected]>
…oxy#2878) This removes the need to package a config file with the Envoy binary. Signed-off-by: Nicolas Thiebaud <[email protected]>
per discussion with @htuch I added a snippet to the style guide about testing log warnings. |
@jmarantz Would you please break this into 2 separate PRs, one for the logging changes, and one for the admin change? |
@ggreenway sure -- I was thinking the logging changes would be dead code without the admin change, but I guess it's a pretty significant refactor on its own. Will do. |
… post-admin-mutations Signed-off-by: Joshua Marantz <[email protected]>
Filesystem::FileSharedPtr log_file_; | ||
friend class SinkDelegate; | ||
|
||
DelegatingLogSink() {} |
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.
DelegatingLogSink() = default;
@@ -80,7 +81,7 @@ InstanceImpl::~InstanceImpl() { | |||
|
|||
// Stop logging to file before all the AccessLogManager and its dependencies are | |||
// destructed to avoid crashing at shutdown. | |||
Logger::Registry::getSink()->logToStdErr(); | |||
file_logger_.reset(nullptr); |
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.
nullptr is the default value; envoy convention is to omit it as an arg at the callsite.
*/ | ||
static void initialize(uint64_t log_level, const std::string& log_format, | ||
Thread::BasicLockable& lock); | ||
Thread::BasicLockable& lock) { |
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 have a minor preference for putting this in the .cc file because nearly every file has to parse this header.
Side note: Is the DCO bot complaining about a commit that you merged in from master? If so, I have no idea how to fix that... |
egads -- I don't know how to solve that DCO either without erasing your comments by rebasing. Actually i don't really know how to solve this with rebasing either :) In any event, I have started #2930, with just the log infrastructure changes and new tests. I will close this PR, at least temporarily, until that one is merged. |
…e log-sinks (#2930) This is a fork of #2912, including only the logs mocking, and new tests for existing logging behavior in admin. Risk Level: Low Testing: //test/... Docs Changes: N/A Release Notes: N/A Signed-off-by: Joshua Marantz <[email protected]>
Description:
When a mutating admin-console endpoint is reached, verify that it's a POST. For now, the operation succeeds but a warning log is printed.
To test this, log-mocking needed to be added, which was more involved than just checking the POST. The logging sink sent to spdlog::logger now delegates to another sink, which can be changed during tests, and mocked.
This is a step toward fixing #2763
Risk Level: Low
Testing: //test/...
Docs Changes:
Release Notes: [in progress, will update]
[Optional Fixes #Issue]
[Optional API Changes:]
Deprecated:
Deprecates supporting admin mutations with a GET.