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

Cluster output circuit breaker #140

Merged
merged 8 commits into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions source/server/http/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,29 @@ bool AdminImpl::changeLogLevel(const Http::Utility::QueryParams& params) {
return true;
}

void AdminImpl::addCircuitSettings(const std::string& cluster_name, const std::string& priority_str,
Upstream::ResourceManager& resource_manager,
Buffer::Instance& response) {
response.add(fmt::format("{}::{}_priority::max_connections::{}\n", cluster_name, priority_str,
resource_manager.connections().max()));
response.add(fmt::format("{}::{}_priority::max_pending_requests::{}\n", cluster_name,
priority_str, resource_manager.pendingRequests().max()));
response.add(fmt::format("{}::{}_priority::max_requests::{}\n", cluster_name, priority_str,
resource_manager.requests().max()));
response.add(fmt::format("{}::{}_priority::max_retries::{}\n", cluster_name, priority_str,
resource_manager.retries().max()));
}

Http::Code AdminImpl::handlerClusters(const std::string&, Buffer::Instance& response) {
Copy link
Member

Choose a reason for hiding this comment

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

newline before this line

Copy link
Member Author

Choose a reason for hiding this comment

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

added

for (auto& cluster : server_.clusterManager().clusters()) {
response.add(fmt::format("=== {} ===\n", cluster.second->name()));

addCircuitSettings(cluster.second->name(), "default",
cluster.second->resourceManager(Upstream::ResourcePriority::Default),
response);
addCircuitSettings(cluster.second->name(), "high",
cluster.second->resourceManager(Upstream::ResourcePriority::High), response);

for (auto& host : cluster.second->hosts()) {
std::map<std::string, uint64_t> all_stats;
for (Stats::Counter& counter : host->counters()) {
Expand All @@ -128,6 +148,9 @@ Http::Code AdminImpl::handlerClusters(const std::string&, Buffer::Instance& resp
fmt::format("{}::{}::canary::{}\n", cluster.second->name(), host->url(), host->canary()));
response.add("\n");
}
if (cluster.second->hosts().empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

I would just remove this new code as well as the newline in the hosts case, as well as the === === thing above. The reality is that this is always used with grep so it's all pointless.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed all of it.

response.add("\n");
}
}

return Http::Code::OK;
Expand Down
5 changes: 4 additions & 1 deletion source/server/http/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "envoy/http/filter.h"
#include "envoy/network/listen_socket.h"
#include "envoy/server/admin.h"
#include "envoy/upstream/resource_manager.h"

#include "common/common/logger.h"
#include "common/http/conn_manager_impl.h"
Expand Down Expand Up @@ -72,6 +73,8 @@ class AdminImpl : public Admin,
* @return TRUE if level change succeeded, FALSE otherwise.
*/
bool changeLogLevel(const Http::Utility::QueryParams& params);
void addCircuitSettings(const std::string& cluster_name, const std::string& priority_str,
Upstream::ResourceManager& resource_manager, Buffer::Instance& response);

/**
* URL handlers.
Expand Down Expand Up @@ -99,7 +102,7 @@ class AdminImpl : public Admin,
};

/**
* A terminal HTTP filter that implements server admin functioanlity.
* A terminal HTTP filter that implements server admin functionality.
*/
class AdminFilter : public Http::StreamDecoderFilter, Logger::Loggable<Logger::Id::admin> {
public:
Expand Down