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

Add overload manager to bootstrap config #4038

Merged
merged 4 commits into from
Aug 7, 2018

Conversation

eziskind
Copy link
Contributor

@eziskind eziskind commented Aug 2, 2018

Initialize on startup and add documentation (issue #373)

Risk Level: low
Testing: unit tests
Docs Changes: add docs for overload manager

Signed-off-by: Elisha Ziskind eziskind@google.com

…dd documentation

Signed-off-by: Elisha Ziskind <eziskind@google.com>
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks great, just some minor comments.

// resource monitor type.
// resource monitor type. The built-in resource monitors are:
//
// clang-format off
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this clang-format suppression, it complains that the line is too long but fix-format splits the line like this:
// * :ref:envoy.resource_monitors.fixed_heap // <envoy_api_msg_config.resource_monitor.fixed_heap.v2alpha.FixedHeapConfig>

which breaks documentation:
/source/generated/rst/api-v2/config/overload/v2alpha/overload.proto.rst:32:Inline interpreted text or phrase reference start-string without end-string.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused how clang-format is running on RST or proto; I think we run our fix-format script on the protos, but I don't think Clang has any proto knowledge to contribute..

Copy link
Member

Choose a reason for hiding this comment

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

We run clang-format on protos. It has a proto mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed - realized I just needed to add a couple spaces to the ref comment so it could be parsed correctly by the docs generator.

string name = 1 [(validate.rules).string.min_bytes = 1];

// Configuration for the resource monitor being instantiated.
google.protobuf.Struct config = 2;
}

// Convenience protobuf for resource monitors that do not require any configuration.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Can't we just use google.protobuf.Empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, added a helper EmptyConfigFactoryBase class for resources monitors with no configs that uses google.protobuf.Empty.

// The fixed heap resource monitor reports the Envoy process memory pressure, computed as a
// fraction of currently reserved heap memory divided by a statically configured maximum
// specified in the FixedHeapConfig.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: remove blank line.

Overload manager
================

The overload manager is configured in the Boostrap
Copy link
Member

Choose a reason for hiding this comment

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

Maybe link "overload manager" back to the architecture overview intro.

// Initialize the overload manager early so other modules can register for actions.
overload_manager_.reset(new OverloadManagerImpl(
dispatcher(), stats(),
bootstrap_.has_overload_manager() ? bootstrap_.overload_manager()
Copy link
Member

Choose a reason for hiding this comment

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

Nit: you don't need the conditional here; if you write bootstrap_.overload_manager(), it will give you the empty proto if it hasn't been defined in the config.

@@ -403,6 +409,8 @@ RunHelper::RunHelper(Event::Dispatcher& dispatcher, Upstream::ClusterManager& cm
}

void InstanceImpl::run() {
overload_manager_->start();
Copy link
Member

Choose a reason for hiding this comment

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

If there's an easy way to validate this in the server tests with the mocked overload manager, that could be nice to check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I moved this call to the RunHelper class so it can be tested.

@htuch htuch self-assigned this Aug 5, 2018
Signed-off-by: Elisha Ziskind <eziskind@google.com>
/**
* Factory for resource monitors that have empty configuration blocks.
*/
class EmptyConfigFactoryBase : public Server::Configuration::ResourceMonitorFactory {
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this and FactoryBase<Envoy::ProtobufWkt::Empty>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Envoy::ProtobufWkt::Empty doesn't have a "Validate" method so the call to MessageUtil::downcastAndValidate here (https://github.com/envoyproxy/envoy/blob/master/source/extensions/resource_monitors/common/factory_base.h#L19) doesn't compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fwiw, there is an http filter config factory that does something similar - https://github.com/envoyproxy/envoy/blob/master/source/extensions/filters/http/common/empty_http_filter_config.h

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Rad, thanks.

@htuch htuch merged commit 14140ad into envoyproxy:master Aug 7, 2018
@eziskind eziskind deleted the overloadhookup branch August 7, 2018 16:34
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