Skip to content
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

Closed
wants to merge 17 commits into from

Conversation

jmarantz
Copy link
Contributor

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:

Link to Data Plane PR]
[in progress, will update]

Release Notes: [in progress, will update]

If this change is user impacting you must add a release note via a discrete PR to
version_history.rst.

[Optional Fixes #Issue]

[Optional API Changes:]

Link to Data Plane PR]

Deprecated:
Deprecates supporting admin mutations with a GET.

@alyssawilk alyssawilk requested a review from ggreenway March 27, 2018 21:21
…a test to be more intuitive.

Signed-off-by: Joshua Marantz <[email protected]>
//
// 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));
Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaned up now.

Copy link
Contributor Author

@jmarantz jmarantz left a 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]>
jmarantz and others added 6 commits March 28, 2018 09:50
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]>
@jmarantz
Copy link
Contributor Author

per discussion with @htuch I added a snippet to the style guide about testing log warnings.

@ggreenway
Copy link
Contributor

@jmarantz Would you please break this into 2 separate PRs, one for the logging changes, and one for the admin change?

@jmarantz
Copy link
Contributor Author

@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.

Filesystem::FileSharedPtr log_file_;
friend class SinkDelegate;

DelegatingLogSink() {}
Copy link
Contributor

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);
Copy link
Contributor

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) {
Copy link
Contributor

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.

@ggreenway
Copy link
Contributor

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...

@jmarantz
Copy link
Contributor Author

jmarantz commented Mar 29, 2018

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.

@jmarantz jmarantz closed this Mar 29, 2018
htuch pushed a commit that referenced this pull request Apr 2, 2018
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants