From 8562c4f65282befe7f64f3358965e23f32b9617a Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Tue, 7 Feb 2017 18:43:08 -0800 Subject: [PATCH] Remove mixer_client from api_manager. --- WORKSPACE | 10 +- contrib/endpoints/repositories.bzl | 12 - .../endpoints/src/api_manager/context/BUILD | 1 - .../api_manager/context/service_context.cc | 15 +- contrib/endpoints/src/api_manager/mixer/BUILD | 42 - .../endpoints/src/api_manager/mixer/mixer.cc | 204 ----- .../endpoints/src/api_manager/mixer/mixer.h | 77 -- .../src/api_manager/proto/server_config.proto | 9 - .../api_manager/server_config_proto_test.cc | 6 - .../BUILD => mixer/repositories.bzl} | 29 +- src/envoy/prototype/README.md | 73 -- src/envoy/prototype/api_manager_env.cc | 219 ------ src/envoy/prototype/api_manager_env.h | 33 - src/envoy/prototype/api_manager_filter.cc | 346 -------- .../prototype/dummy_api_manager_cluster.py | 91 --- src/envoy/prototype/envoy-esp.conf | 89 --- .../prototype/generic_service_config.json | 736 ------------------ src/envoy/prototype/server_config.pb.txt | 6 - 18 files changed, 22 insertions(+), 1976 deletions(-) delete mode 100644 contrib/endpoints/src/api_manager/mixer/BUILD delete mode 100644 contrib/endpoints/src/api_manager/mixer/mixer.cc delete mode 100644 contrib/endpoints/src/api_manager/mixer/mixer.h rename src/envoy/{prototype/BUILD => mixer/repositories.bzl} (57%) delete mode 100644 src/envoy/prototype/README.md delete mode 100644 src/envoy/prototype/api_manager_env.cc delete mode 100644 src/envoy/prototype/api_manager_env.h delete mode 100644 src/envoy/prototype/api_manager_filter.cc delete mode 100644 src/envoy/prototype/dummy_api_manager_cluster.py delete mode 100644 src/envoy/prototype/envoy-esp.conf delete mode 100644 src/envoy/prototype/generic_service_config.json delete mode 100644 src/envoy/prototype/server_config.pb.txt diff --git a/WORKSPACE b/WORKSPACE index 95dcdde5cdc..e152300d73d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -31,16 +31,20 @@ googletest_repositories() load( "//contrib/endpoints:repositories.bzl", "grpc_repositories", - "mixer_client_repositories", "servicecontrol_client_repositories", ) grpc_repositories() -mixer_client_repositories() - servicecontrol_client_repositories() +load( + "//src/envoy/mixer:repositories.bzl", + "mixer_client_repositories", +) + +mixer_client_repositories() + # Workaround for Bazel > 0.4.0 since it needs newer protobuf.bzl from: # https://github.com/google/protobuf/pull/2246 # Do not use this git_repository for anything else than protobuf.bzl diff --git a/contrib/endpoints/repositories.bzl b/contrib/endpoints/repositories.bzl index b1f14aae8b5..e3363cc86d2 100644 --- a/contrib/endpoints/repositories.bzl +++ b/contrib/endpoints/repositories.bzl @@ -334,15 +334,3 @@ def servicecontrol_client_repositories(bind=True): actual = "@servicecontrol_client_git//:service_control_client_lib", ) -def mixer_client_repositories(bind=True): - native.git_repository( - name = "mixerclient_git", - commit = "80e450a5126960e8e6337c3631cf2ef984038eab", - remote = "https://github.com/istio/mixerclient.git", - ) - - if bind: - native.bind( - name = "mixer_client_lib", - actual = "@mixerclient_git//:mixer_client_lib", - ) diff --git a/contrib/endpoints/src/api_manager/context/BUILD b/contrib/endpoints/src/api_manager/context/BUILD index e158c13fc92..59365102318 100644 --- a/contrib/endpoints/src/api_manager/context/BUILD +++ b/contrib/endpoints/src/api_manager/context/BUILD @@ -39,7 +39,6 @@ cc_library( "//contrib/endpoints/src/api_manager/auth", "//contrib/endpoints/src/api_manager/auth:service_account_token", "//contrib/endpoints/src/api_manager/cloud_trace", - "//contrib/endpoints/src/api_manager/mixer", "//contrib/endpoints/src/api_manager/service_control", "//contrib/endpoints/src/api_manager/utils", "//external:cc_wkt_protos", diff --git a/contrib/endpoints/src/api_manager/context/service_context.cc b/contrib/endpoints/src/api_manager/context/service_context.cc index d8fc9dfc409..e9598a05814 100644 --- a/contrib/endpoints/src/api_manager/context/service_context.cc +++ b/contrib/endpoints/src/api_manager/context/service_context.cc @@ -15,7 +15,6 @@ //////////////////////////////////////////////////////////////////////////////// // #include "contrib/endpoints/src/api_manager/context/service_context.h" -#include "contrib/endpoints/src/api_manager/mixer/mixer.h" #include "contrib/endpoints/src/api_manager/service_control/aggregated.h" @@ -97,16 +96,10 @@ const std::string& ServiceContext::project_id() const { } std::unique_ptr ServiceContext::CreateInterface() { - if (config_->server_config() && - config_->server_config()->has_mixer_options()) { - return std::unique_ptr( - mixer::Mixer::Create(env_.get(), config_.get())); - } else { - return std::unique_ptr( - service_control::Aggregated::Create( - config_->service(), config_->server_config(), env_.get(), - &service_account_token_)); - } + return std::unique_ptr( + service_control::Aggregated::Create(config_->service(), + config_->server_config(), env_.get(), + &service_account_token_)); } std::unique_ptr diff --git a/contrib/endpoints/src/api_manager/mixer/BUILD b/contrib/endpoints/src/api_manager/mixer/BUILD deleted file mode 100644 index affe09c7ddd..00000000000 --- a/contrib/endpoints/src/api_manager/mixer/BUILD +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ -# -package(default_visibility = ["//contrib/endpoints/src/api_manager:__subpackages__"]) - -cc_library( - name = "mixer", - srcs = [ - "mixer.cc", - ], - hdrs = [ - "mixer.h", - ], - linkopts = select({ - "//:darwin": [], - "//conditions:default": [ - "-lm", - "-luuid", - ], - }), - deps = [ - "//contrib/endpoints/src/api_manager:impl_headers", - "//contrib/endpoints/src/api_manager/service_control", - "//contrib/endpoints/src/api_manager/utils", - "//external:grpc++", - "//external:mixer_client_lib", - "//external:protobuf", - ], -) diff --git a/contrib/endpoints/src/api_manager/mixer/mixer.cc b/contrib/endpoints/src/api_manager/mixer/mixer.cc deleted file mode 100644 index 53837edaf67..00000000000 --- a/contrib/endpoints/src/api_manager/mixer/mixer.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "contrib/endpoints/src/api_manager/mixer/mixer.h" - -using ::google::api_manager::utils::Status; -using ::istio::mixer_client::Attributes; - -namespace google { -namespace api_manager { -namespace mixer { -namespace { - -const std::string kProxyPeerID = "Istio/Proxy"; -const std::string kEnvNameTargetService = "TARGET_SERVICE"; - -const std::string kAttrNameServiceName = "serviceName"; -const std::string kAttrNamePeerId = "peerId"; -const std::string kAttrNameOperationId = "operationId"; -const std::string kAttrNameOperationName = "operationName"; -const std::string kAttrNameApiKey = "apiKey"; -const std::string kAttrNameResponseCode = "responseCode"; -const std::string kAttrNameURL = "url"; -const std::string kAttrNameLocation = "location"; -const std::string kAttrNameApiName = "apiName"; -const std::string kAttrNameApiVersion = "apiVersion"; -const std::string kAttrNameApiMethod = "apiMethod"; -const std::string kAttrNameRequestSize = "requestSize"; -const std::string kAttrNameResponseSize = "responseSize"; -const std::string kAttrNameLogMessage = "logMessage"; -const std::string kAttrNameResponseTime = "responseTime"; -const std::string kAttrNameOriginIp = "originIp"; -const std::string kAttrNameOriginHost = "originHost"; -const std::string kAttrNameTargetService = "targetService"; - -Attributes::Value StringValue(const std::string& str) { - Attributes::Value v; - v.type = Attributes::Value::STRING; - v.str_v = str; - return v; -} - -Attributes::Value Int64Value(int64_t value) { - Attributes::Value v; - v.type = Attributes::Value::INT64; - v.value.int64_v = value; - return v; -} - -} // namespace - -Mixer::Mixer(ApiManagerEnvInterface* env, const Config* config) - : env_(env), config_(config) {} - -Mixer::~Mixer() {} - -Status Mixer::Init() { - ::istio::mixer_client::MixerClientOptions options; - options.mixer_server = - config_->server_config()->mixer_options().mixer_server(); - mixer_client_ = ::istio::mixer_client::CreateMixerClient(options); - auto target_service = getenv(kEnvNameTargetService.c_str()); - if (target_service) { - target_service_ = target_service; - } - return Status::OK; -} - -Status Mixer::Close() { return Status::OK; } - -void Mixer::FillCommonAttributes(const service_control::OperationInfo& info, - ::istio::mixer_client::Attributes* attr) { - attr->attributes[kAttrNameServiceName] = StringValue(config_->service_name()); - attr->attributes[kAttrNamePeerId] = StringValue(kProxyPeerID); - - if (!info.operation_id.empty()) { - attr->attributes[kAttrNameOperationId] = StringValue(info.operation_id); - } - if (!info.operation_name.empty()) { - attr->attributes[kAttrNameOperationName] = StringValue(info.operation_name); - } - if (!info.api_key.empty()) { - attr->attributes[kAttrNameApiKey] = StringValue(info.api_key); - } - if (!info.client_ip.empty()) { - attr->attributes[kAttrNameOriginIp] = StringValue(info.client_ip); - } - if (!info.client_host.empty()) { - attr->attributes[kAttrNameOriginHost] = StringValue(info.client_host); - } - if (!target_service_.empty()) { - attr->attributes[kAttrNameTargetService] = StringValue(target_service_); - } -} - -void Mixer::FillCheckAttributes(const service_control::CheckRequestInfo& info, - ::istio::mixer_client::Attributes* attr) { - FillCommonAttributes(info, attr); -} - -void Mixer::FillReportAttributes(const service_control::ReportRequestInfo& info, - ::istio::mixer_client::Attributes* attr) { - FillCommonAttributes(info, attr); - - if (!info.url.empty()) { - attr->attributes[kAttrNameURL] = StringValue(info.url); - } - if (!info.location.empty()) { - attr->attributes[kAttrNameLocation] = StringValue(info.location); - } - - if (!info.api_name.empty()) { - attr->attributes[kAttrNameApiName] = StringValue(info.api_name); - } - if (!info.api_version.empty()) { - attr->attributes[kAttrNameApiVersion] = StringValue(info.api_version); - } - if (!info.api_method.empty()) { - attr->attributes[kAttrNameApiMethod] = StringValue(info.api_method); - } - - if (!info.log_message.empty()) { - attr->attributes[kAttrNameLogMessage] = StringValue(info.log_message); - } - - attr->attributes[kAttrNameResponseCode] = Int64Value(info.response_code); - if (info.request_size >= 0) { - attr->attributes[kAttrNameRequestSize] = Int64Value(info.request_size); - } - if (info.response_size >= 0) { - attr->attributes[kAttrNameResponseSize] = Int64Value(info.response_size); - } - - if (info.latency.request_time_ms >= 0) { - attr->attributes[kAttrNameResponseTime] = - Int64Value(info.latency.request_time_ms); - } -} - -Status Mixer::Report(const service_control::ReportRequestInfo& info) { - ::istio::mixer_client::Attributes attributes; - FillReportAttributes(info, &attributes); - env_->LogInfo("Send Report: "); - env_->LogInfo(attributes.DebugString()); - mixer_client_->Report( - attributes, [this](const ::google::protobuf::util::Status& status) { - if (status.ok()) { - env_->LogInfo("Report response: OK"); - } else { - env_->LogError(std::string("Failed to call Mixer::report, Error: ") + - status.ToString()); - } - }); - return Status::OK; -} - -void Mixer::Check( - const service_control::CheckRequestInfo& info, - cloud_trace::CloudTraceSpan* parent_span, - std::function - on_done) { - ::istio::mixer_client::Attributes attributes; - FillCheckAttributes(info, &attributes); - env_->LogInfo("Send Check: "); - env_->LogInfo(attributes.DebugString()); - mixer_client_->Check( - attributes, - [this, on_done](const ::google::protobuf::util::Status& status) { - if (status.ok()) { - env_->LogInfo("Check response: OK"); - } else { - env_->LogError(std::string("Failed to call Mixer::check, Error: ") + - status.ToString()); - } - service_control::CheckResponseInfo info; - on_done(Status(status.error_code(), status.error_message(), - Status::SERVICE_CONTROL), - info); - }); -} - -Status Mixer::GetStatistics(service_control::Statistics* esp_stat) const { - return Status::OK; -} - -service_control::Interface* Mixer::Create(ApiManagerEnvInterface* env, - const Config* config) { - return new Mixer(env, config); -} - -} // namespace mixer -} // namespace api_manager -} // namespace google diff --git a/contrib/endpoints/src/api_manager/mixer/mixer.h b/contrib/endpoints/src/api_manager/mixer/mixer.h deleted file mode 100644 index 81276e1227d..00000000000 --- a/contrib/endpoints/src/api_manager/mixer/mixer.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef API_MANAGER_MIXER_MIXER_H_ -#define API_MANAGER_MIXER_MIXER_H_ - -#include "contrib/endpoints/include/api_manager/env_interface.h" -#include "contrib/endpoints/src/api_manager/config.h" -#include "contrib/endpoints/src/api_manager/service_control/interface.h" -#include "include/client.h" - -namespace google { -namespace api_manager { -namespace mixer { - -// This implementation uses service-control-client-cxx module. -class Mixer : public service_control::Interface { - public: - static service_control::Interface* Create(ApiManagerEnvInterface* env, - const Config* config); - - virtual ~Mixer(); - - virtual utils::Status Report(const service_control::ReportRequestInfo& info); - - virtual void Check( - const service_control::CheckRequestInfo& info, - cloud_trace::CloudTraceSpan* parent_span, - std::function - on_done); - - virtual utils::Status Init(); - virtual utils::Status Close(); - - virtual utils::Status GetStatistics(service_control::Statistics* stat) const; - - private: - // The constructor. - Mixer(ApiManagerEnvInterface* env, const Config* config); - - // Fill common attributes for both check and report. - void FillCommonAttributes(const service_control::OperationInfo& info, - ::istio::mixer_client::Attributes* attr); - // Fill attributes for check. - void FillCheckAttributes(const service_control::CheckRequestInfo& info, - ::istio::mixer_client::Attributes* attr); - // Fill attributes for report. - void FillReportAttributes(const service_control::ReportRequestInfo& info, - ::istio::mixer_client::Attributes* attr); - - // The Api Manager environment interface. - ApiManagerEnvInterface* env_; - // The config. - const Config* config_; - // The mixer client - std::unique_ptr<::istio::mixer_client::MixerClient> mixer_client_; - // Target service - std::string target_service_; -}; - -} // namespace mixer -} // namespace api_manager -} // namespace google - -#endif // API_MANAGER_MIXER_MIXER_H_ diff --git a/contrib/endpoints/src/api_manager/proto/server_config.proto b/contrib/endpoints/src/api_manager/proto/server_config.proto index 343414aceae..1fe04af6d07 100644 --- a/contrib/endpoints/src/api_manager/proto/server_config.proto +++ b/contrib/endpoints/src/api_manager/proto/server_config.proto @@ -35,10 +35,6 @@ message ServerConfig { // Server config used for API authentication ApiAuthenticationConfig api_authentication_config = 5; - // Mixer option flag. If not present, default to use service_control. When - // Envoy/esp talks to Mixer, has to specify this field. - MixerOptions mixer_options = 6; - // Experimental flags Experimental experimental = 999; } @@ -143,11 +139,6 @@ message ApiAuthenticationConfig { bool force_disable = 1; } -message MixerOptions { - // For envoy, it is the cluster name for mixer server. - string mixer_server = 1; -} - message Experimental { // Disable timed printouts of ESP status to the error log. bool disable_log_status = 1; diff --git a/contrib/endpoints/src/api_manager/server_config_proto_test.cc b/contrib/endpoints/src/api_manager/server_config_proto_test.cc index b39309727f1..80c62e05471 100644 --- a/contrib/endpoints/src/api_manager/server_config_proto_test.cc +++ b/contrib/endpoints/src/api_manager/server_config_proto_test.cc @@ -76,9 +76,6 @@ experimental { disable_log_status: false } -mixer_options { - mixer_server: "mixer_server" -} )"; TEST(ServerConfigProto, ServerConfigFromString) { @@ -125,9 +122,6 @@ TEST(ServerConfigProto, ServerConfigFromString) { // Check disable_log_status EXPECT_EQ(false, server_config.experimental().disable_log_status()); - - // Check mixer options - EXPECT_EQ("mixer_server", server_config.mixer_options().mixer_server()); } TEST(ServerConfigProto, ValidateSampleServerConfig) { diff --git a/src/envoy/prototype/BUILD b/src/envoy/mixer/repositories.bzl similarity index 57% rename from src/envoy/prototype/BUILD rename to src/envoy/mixer/repositories.bzl index 258f2046cd7..d9888fb0daf 100644 --- a/src/envoy/prototype/BUILD +++ b/src/envoy/mixer/repositories.bzl @@ -15,22 +15,15 @@ ################################################################################ # -package(default_visibility = ["//visibility:public"]) +def mixer_client_repositories(bind=True): + native.git_repository( + name = "mixerclient_git", + commit = "80e450a5126960e8e6337c3631cf2ef984038eab", + remote = "https://github.com/istio/mixerclient.git", + ) -cc_binary( - name = "envoy_esp", - srcs = [ - "api_manager_filter.cc", - "api_manager_env.cc", - "api_manager_env.h", - ], - deps = [ - "//external:protobuf", - "//contrib/endpoints/include:api_manager", - "//contrib/endpoints/src/grpc/transcoding:transcoding", - "//external:servicecontrol", - "@envoy_git//:envoy-common", - "@envoy_git//:envoy-main" - ], - linkstatic=1, -) + if bind: + native.bind( + name = "mixer_client_lib", + actual = "@mixerclient_git//:mixer_client_lib", + ) diff --git a/src/envoy/prototype/README.md b/src/envoy/prototype/README.md deleted file mode 100644 index dc73f63f6c9..00000000000 --- a/src/envoy/prototype/README.md +++ /dev/null @@ -1,73 +0,0 @@ - -This Proxy will use Envoy and talk to Mixer server. - -## Install dependencies - -``` - apt-get install uuid-dev -``` - -## Build Mixer server - -* Follow https://github.com/istio/mixer/blob/master/doc/devel/development.md to set up environment, and build via: - -``` - cd $(ISTIO)/mixer - bazel build ...:all -``` - -## Build Envoy proxy - -* Build target envoy_esp: - -``` - bazel build //src/envoy/prototype:envoy_esp -``` - -## How to run it - -* Start mixer server. In mixer folder run: - -``` - bazel-bin/cmd/server/mixs server -``` - - The server will run at port 9091 - -* Start backend Echo server. - -``` - cd test/backend/echo - go run echo.go -``` - -* Modify your iptables: - -``` - sudo iptables -t nat -A OUTPUT -p tcp --dport 9090 -j REDIRECT --to-port 9092 -``` - -Once you are done, you should remove this rule: - -``` - sudo iptables -t nat -D OUTPUT -p tcp --dport 9090 -j REDIRECT --to-port 9092 -``` - - -* Start Envoy proxy, run - -``` - bazel-bin/src/envoy/prototype/envoy_esp -c src/envoy/prototype/envoy-esp.conf -``` - -* Then issue HTTP request to proxy. - -``` - curl http://localhost:9090/echo?key=API-KEY -d "hello world" -``` - -## How to add attributes or facts - -Now only some of attributes are passed to mixer. If you want to add more attributes, you can -modify this -[file](https://github.com/istio/proxy/blob/master/contrib/endpoints/src/api_manager/mixer/mixer.cc). diff --git a/src/envoy/prototype/api_manager_env.cc b/src/envoy/prototype/api_manager_env.cc deleted file mode 100644 index f8536bcc10a..00000000000 --- a/src/envoy/prototype/api_manager_env.cc +++ /dev/null @@ -1,219 +0,0 @@ -#include "api_manager_env.h" - -#include "common/http/headers.h" -#include "common/http/message_impl.h" -#include "envoy/event/timer.h" -#include "google/protobuf/stubs/status.h" -#include "source/common/grpc/common.h" - -using ::google::api_manager::utils::Status; -using ::google::protobuf::util::error::Code; - -namespace Http { -namespace ApiManager { - -void Http::ApiManager::Env::Log(LogLevel level, const char *message) { - switch (level) { - case LogLevel::DEBUG: - log().debug("{}", message); - break; - case LogLevel::INFO: - log().info("{}", message); - break; - case LogLevel::WARNING: - log().warn("{}", message); - break; - case LogLevel::ERROR: - log().error("{}", message); - break; - } -} - -class PeriodicTimer : public google::api_manager::PeriodicTimer, - public Logger::Loggable { - private: - Server::Instance &server_; - Event::TimerPtr timer_; - - public: - PeriodicTimer(Server::Instance &server) : server_(server) {} - ~PeriodicTimer() { Stop(); } - void Stop() { - if (timer_) { - timer_->disableTimer(); - timer_ = nullptr; - } - } - void Schedule(std::chrono::milliseconds interval, - std::function continuation) { - Stop(); - timer_ = server_.dispatcher().createTimer([this, continuation, interval]() { - continuation(); - Schedule(interval, continuation); - }); - timer_->enableTimer(interval); - } -}; - -std::unique_ptr Env::StartPeriodicTimer( - std::chrono::milliseconds interval, std::function continuation) { - log().debug("start periodic timer"); - auto single = new PeriodicTimer(server); - single->Schedule(interval, continuation); - std::unique_ptr timer(single); - return timer; -} - -static const LowerCaseString kApiManagerUrl("x-api-manager-url"); -static const LowerCaseString kGrpcTEKey("te"); -static const std::string kGrpcTEValue("trailers"); - -class HTTPRequest : public Http::Message { - private: - HeaderMapImpl header_map_; - Buffer::OwnedImpl body_; - - public: - HTTPRequest(google::api_manager::HTTPRequest *request) - : body_(request->body()) { - header_map_.addStaticKey(Headers::get().Method, request->method()); - - size_t path_pos = request->url().find('/', 8); - if (path_pos == std::string::npos) { - header_map_.addStaticKey(Headers::get().Path, "/"); - } else { - header_map_.addStaticKey(Headers::get().Path, - request->url().substr(path_pos)); - } - - header_map_.addStaticKey(Headers::get().Scheme, "http"); - header_map_.addStaticKey(Headers::get().Host, "localhost"); - header_map_.addStaticKey(Headers::get().ContentLength, body_.length()); - header_map_.addStaticKey(kApiManagerUrl, request->url()); - for (const auto header : request->request_headers()) { - LowerCaseString lower_key(header.first); - HeaderString key, value; - key.setCopy(lower_key.get().data(), lower_key.get().size()); - value.setCopy(header.second.data(), header.second.size()); - header_map_.addViaMove(std::move(key), std::move(value)); - } - } - virtual HeaderMap &headers() override { return header_map_; } - virtual Buffer::Instance *body() override { return &body_; } - virtual void body(Buffer::InstancePtr &&body) override {} - virtual HeaderMap *trailers() override { return nullptr; } - virtual void trailers(HeaderMapPtr &&trailers) override {} - virtual std::string bodyAsString() const override { return ""; } -}; - -class HTTPRequestCallbacks : public AsyncClient::Callbacks { - private: - std::unique_ptr request_; - std::unique_ptr sent_request_; - - public: - HTTPRequestCallbacks( - std::unique_ptr &&request) - : request_(std::move(request)) {} - virtual void onSuccess(MessagePtr &&response) override { - google::api_manager::utils::Status status( - std::stoi(response->headers().Status()->value().c_str()), ""); - std::map headers; - response->headers().iterate( - [&](const HeaderEntry &header, void *) -> void { - // TODO: fix it - // headers.emplace(header.key().c_str(), header.value().c_str()); - }, - nullptr); - request_->OnComplete(status, std::move(headers), response->bodyAsString()); - delete this; - } - virtual void onFailure(AsyncClient::FailureReason reason) override { - google::api_manager::utils::Status status(-1, - "Cannot connect to HTTP server."); - std::map headers; - request_->OnComplete(status, std::move(headers), ""); - delete this; - } -}; - -namespace { -// Copy the code here from envoy/grpc/common.cc -Buffer::InstancePtr SerializeGrpcBody(const std::string &body_str) { - // http://www.grpc.io/docs/guides/wire.html - Buffer::InstancePtr body(new Buffer::OwnedImpl()); - uint8_t compressed = 0; - body->add(&compressed, sizeof(compressed)); - uint32_t size = htonl(body_str.size()); - body->add(&size, sizeof(size)); - body->add(body_str); - return body; -} -Http::MessagePtr PrepareGrpcHeaders(const std::string &upstream_cluster, - const std::string &service_full_name, - const std::string &method_name) { - Http::MessagePtr message(new Http::RequestMessageImpl()); - message->headers().insertMethod().value( - Http::Headers::get().MethodValues.Post); - message->headers().insertPath().value( - fmt::format("/{}/{}", service_full_name, method_name)); - message->headers().insertHost().value(upstream_cluster); - message->headers().insertContentType().value(Grpc::Common::GRPC_CONTENT_TYPE); - message->headers().addStatic(kGrpcTEKey, kGrpcTEValue); - return message; -} -} // annoymous namespace - -class GrpcRequestCallbacks : public AsyncClient::Callbacks { - private: - Env *env_; - std::unique_ptr request_; - - public: - GrpcRequestCallbacks( - Env *env, std::unique_ptr &&request) - : env_(env), request_(std::move(request)) {} - virtual void onSuccess(MessagePtr &&response) override { - google::api_manager::utils::Status status( - std::stoi(response->headers().Status()->value().c_str()), ""); - Grpc::Common::validateResponse(*response); - env_->LogInfo("pass validate"); - // remove 5 bytes of grpc header - response->body()->drain(5); - request_->OnComplete(status, response->bodyAsString()); - delete this; - } - virtual void onFailure(AsyncClient::FailureReason reason) override { - google::api_manager::utils::Status status(-1, - "Cannot connect to gRPC server."); - request_->OnComplete(status, ""); - delete this; - } -}; - -void Env::RunHTTPRequest( - std::unique_ptr request) { - auto &client = cm_.httpAsyncClientForCluster("api_manager"); - - MessagePtr message{new HTTPRequest(request.get())}; - HTTPRequestCallbacks *callbacks = - new HTTPRequestCallbacks(std::move(request)); - client.send( - std::move(message), *callbacks, - Optional(std::chrono::milliseconds(10000))); -} - -void Env::RunGRPCRequest( - std::unique_ptr request) { - auto &client = cm_.httpAsyncClientForCluster(request->server()); - - Http::MessagePtr message = - PrepareGrpcHeaders("localhost", request->service(), request->method()); - message->body(SerializeGrpcBody(request->body())); - auto callbacks = new GrpcRequestCallbacks(this, std::move(request)); - client.send( - std::move(message), *callbacks, - Optional(std::chrono::milliseconds(10000))); -} -} -} diff --git a/src/envoy/prototype/api_manager_env.h b/src/envoy/prototype/api_manager_env.h deleted file mode 100644 index 0ae8136f5be..00000000000 --- a/src/envoy/prototype/api_manager_env.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "precompiled/precompiled.h" - -#include "common/common/logger.h" -#include "contrib/endpoints/include/api_manager/env_interface.h" -#include "envoy/upstream/cluster_manager.h" -#include "server/server.h" - -namespace Http { -namespace ApiManager { - -class Env : public google::api_manager::ApiManagerEnvInterface, - public Logger::Loggable { - private: - Server::Instance& server; - Upstream::ClusterManager& cm_; - - public: - Env(Server::Instance& server) - : server(server), cm_(server.clusterManager()){}; - - virtual void Log(LogLevel level, const char* message) override; - virtual std::unique_ptr - StartPeriodicTimer(std::chrono::milliseconds interval, - std::function continuation) override; - virtual void RunHTTPRequest( - std::unique_ptr request) override; - virtual void RunGRPCRequest( - std::unique_ptr request) override; -}; -} -} diff --git a/src/envoy/prototype/api_manager_filter.cc b/src/envoy/prototype/api_manager_filter.cc deleted file mode 100644 index 3983a4d8b41..00000000000 --- a/src/envoy/prototype/api_manager_filter.cc +++ /dev/null @@ -1,346 +0,0 @@ -#include "precompiled/precompiled.h" - -#include "api_manager_env.h" -#include "common/common/logger.h" -#include "common/grpc/common.h" -#include "common/http/filter/ratelimit.h" -#include "common/http/headers.h" -#include "common/http/utility.h" -#include "contrib/endpoints/include/api_manager/api_manager.h" -#include "contrib/endpoints/src/grpc/transcoding/transcoder.h" -#include "envoy/server/instance.h" -#include "server/config/network/http_connection_manager.h" - -namespace Http { -namespace ApiManager { -namespace { - -// Define lower case string for X-Forwarded-Host. -const LowerCaseString kHeaderNameXFH("x-forwarded-host", false); - -} // namespace - -std::string ReadFile(const std::string& file_name) { - std::ifstream t(file_name); - std::string content((std::istreambuf_iterator(t)), - std::istreambuf_iterator()); - return content; -} - -class Config : public Logger::Loggable { - private: - google::api_manager::ApiManagerFactory api_manager_factory_; - std::shared_ptr api_manager_; - Upstream::ClusterManager& cm_; - - public: - Config(const Json::Object& config, Server::Instance& server) - : cm_(server.clusterManager()) { - std::string service_config_content; - if (config.hasObject("service_config")) { - const std::string service_config = config.getString("service_config"); - service_config_content = ReadFile(service_config); - } else { - log().error( - "Service_config is required but not specified in the config: {}", - __func__); - } - - std::string server_config_content; - if (config.hasObject("server_config")) { - const std::string server_config = config.getString("server_config"); - server_config_content = ReadFile(server_config); - } - std::unique_ptr env( - new Env(server)); - - api_manager_ = api_manager_factory_.GetOrCreateApiManager( - std::move(env), service_config_content, server_config_content); - - api_manager_->Init(); - log().debug("Called ApiManager::Config constructor: {}", __func__); - } - - std::shared_ptr& api_manager() { - return api_manager_; - } -}; - -typedef std::shared_ptr ConfigPtr; - -class Request : public google::api_manager::Request { - private: - HeaderMap& header_map_; - std::string downstream_address_; - std::string virtual_host_; - bool query_parsed_; - std::map query_params_; - - public: - Request(HeaderMap& header_map, const std::string& downstream_address, - const std::string& virtual_host) - : header_map_(header_map), - downstream_address_(downstream_address), - virtual_host_(virtual_host), - query_parsed_(false) {} - virtual std::string GetRequestHTTPMethod() override { - return header_map_.Method()->value().c_str(); - } - virtual std::string GetRequestPath() override { - return header_map_.Path()->value().c_str(); - } - virtual std::string GetUnparsedRequestPath() override { - return header_map_.Path()->value().c_str(); - } - - virtual std::string GetClientIP() override { - if (!header_map_.ForwardedFor()) { - return downstream_address_; - } - std::vector xff_address_list = - StringUtil::split(header_map_.ForwardedFor()->value().c_str(), ','); - if (xff_address_list.empty()) { - return downstream_address_; - } - return xff_address_list.front(); - } - - virtual std::string GetClientHost() override { - const HeaderEntry* entry = header_map_.get(kHeaderNameXFH); - if (entry == nullptr) { - return virtual_host_; - } - auto xff_list = StringUtil::split(entry->value().c_str(), ','); - if (xff_list.empty()) { - return virtual_host_; - } - return xff_list.back(); - } - - virtual bool FindQuery(const std::string& name, std::string* query) override { - if (!query_parsed_) { - auto header = header_map_.Path(); - if (header != nullptr) { - std::string path = header->value().c_str(); - Utility::parseQueryString(path).swap(query_params_); - } - query_parsed_ = true; - } - auto entry = query_params_.find(name); - if (entry == query_params_.end()) { - return false; - } - *query = entry->second; - return true; - } - - virtual bool FindHeader(const std::string& name, - std::string* header) override { - LowerCaseString key(name); - const HeaderEntry* entry = header_map_.get(key); - if (entry == nullptr) { - return false; - } - *header = entry->value().c_str(); - return true; - } - - virtual google::api_manager::protocol::Protocol GetRequestProtocol() - override { - return google::api_manager::protocol::Protocol::HTTP; - } - virtual google::api_manager::utils::Status AddHeaderToBackend( - const std::string& key, const std::string& value) override { - return google::api_manager::utils::Status::OK; - } - virtual void SetAuthToken(const std::string& auth_token) override {} - - virtual int64_t GetGrpcRequestBytes() { return 0; } - virtual int64_t GetGrpcResponseBytes() { return 0; } - virtual int64_t GetGrpcRequestMessageCounts() { return 0; } - virtual int64_t GetGrpcResponseMessageCounts() { return 0; } - virtual std::string GetQueryParameters() { return ""; } -}; - -class Response : public google::api_manager::Response { - const AccessLog::RequestInfo& request_info_; - - public: - Response(const AccessLog::RequestInfo& request_info) - : request_info_(request_info) {} - - google::api_manager::utils::Status GetResponseStatus() { - return google::api_manager::utils::Status::OK; - } - - std::size_t GetRequestSize() { return request_info_.bytesReceived(); } - - std::size_t GetResponseSize() { return request_info_.bytesSent(); } - - google::api_manager::utils::Status GetLatencyInfo( - google::api_manager::service_control::LatencyInfo* info) { - info->request_time_ms = request_info_.duration().count(); - return google::api_manager::utils::Status::OK; - } -}; - -const Http::HeaderMapImpl BadRequest{{Http::Headers::get().Status, "400"}}; - -class Instance : public Http::StreamFilter, public Http::AccessLog::Instance { - private: - std::shared_ptr api_manager_; - std::unique_ptr - request_handler_; - - enum State { NotStarted, Calling, Complete, Responded }; - State state_; - - StreamDecoderFilterCallbacks* decoder_callbacks_; - StreamEncoderFilterCallbacks* encoder_callbacks_; - - bool initiating_call_; - - std::string getRouteVirtualHost(HeaderMap& headers) const { - const Router::Route* route = decoder_callbacks_->route(); - if (route && route->routeEntry()) { - return route->routeEntry()->virtualHost().name(); - } - return ""; - } - - public: - Instance(ConfigPtr config) - : api_manager_(config->api_manager()), - state_(NotStarted), - initiating_call_(false) { - Log().debug("Called ApiManager::Instance : {}", __func__); - } - - FilterHeadersStatus decodeHeaders(HeaderMap& headers, - bool end_stream) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - std::unique_ptr request( - new Request(headers, decoder_callbacks_->downstreamAddress(), - getRouteVirtualHost(headers))); - request_handler_ = api_manager_->CreateRequestHandler(std::move(request)); - state_ = Calling; - initiating_call_ = true; - request_handler_->Check([this](google::api_manager::utils::Status status) { - completeCheck(status); - }); - initiating_call_ = false; - - if (state_ == Complete) { - return FilterHeadersStatus::Continue; - } - Log().debug("Called ApiManager::Instance : {} Stop", __func__); - return FilterHeadersStatus::StopIteration; - } - - FilterDataStatus decodeData(Buffer::Instance& data, - bool end_stream) override { - Log().debug("Called ApiManager::Instance : {} ({}, {})", __func__, - data.length(), end_stream); - if (state_ == Calling) { - return FilterDataStatus::StopIterationAndBuffer; - } - return FilterDataStatus::Continue; - } - - FilterTrailersStatus decodeTrailers(HeaderMap& trailers) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - if (state_ == Calling) { - return FilterTrailersStatus::StopIteration; - } - return FilterTrailersStatus::Continue; - } - void setDecoderFilterCallbacks( - StreamDecoderFilterCallbacks& callbacks) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - decoder_callbacks_ = &callbacks; - decoder_callbacks_->addResetStreamCallback( - [this]() { state_ = Responded; }); - } - void completeCheck(const google::api_manager::utils::Status& status) { - Log().debug("Called ApiManager::Instance : check complete {}", - status.ToJson()); - if (!status.ok() && state_ != Responded) { - state_ = Responded; - decoder_callbacks_->dispatcher().post([this, status]() { - Utility::sendLocalReply(*decoder_callbacks_, Code(status.HttpCode()), - status.ToJson()); - }); - return; - } - state_ = Complete; - if (!initiating_call_) { - decoder_callbacks_->dispatcher().post( - [this]() { decoder_callbacks_->continueDecoding(); }); - } - } - - virtual FilterHeadersStatus encodeHeaders(HeaderMap& headers, - bool end_stream) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - return FilterHeadersStatus::Continue; - } - virtual FilterDataStatus encodeData(Buffer::Instance& data, - bool end_stream) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - return FilterDataStatus::Continue; - } - virtual FilterTrailersStatus encodeTrailers(HeaderMap& trailers) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - return FilterTrailersStatus::Continue; - } - virtual void setEncoderFilterCallbacks( - StreamEncoderFilterCallbacks& callbacks) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - encoder_callbacks_ = &callbacks; - } - - virtual void log(const HeaderMap* request_headers, - const HeaderMap* response_headers, - const AccessLog::RequestInfo& request_info) override { - Log().debug("Called ApiManager::Instance : {}", __func__); - std::unique_ptr response( - new Response(request_info)); - request_handler_->Report(std::move(response), []() {}); - } - - spdlog::logger& Log() { - static spdlog::logger& instance = - Logger::Registry::getLog(Logger::Id::http); - return instance; - } -}; -} -} - -namespace Server { -namespace Configuration { - -class ApiManagerConfig : public HttpFilterConfigFactory { - public: - HttpFilterFactoryCb tryCreateFilterFactory( - HttpFilterType type, const std::string& name, const Json::Object& config, - const std::string&, Server::Instance& server) override { - if (type != HttpFilterType::Both || name != "esp") { - return nullptr; - } - - Http::ApiManager::ConfigPtr api_manager_config( - new Http::ApiManager::Config(config, server)); - return [api_manager_config]( - Http::FilterChainFactoryCallbacks& callbacks) -> void { - std::shared_ptr instance( - new Http::ApiManager::Instance(api_manager_config)); - callbacks.addStreamFilter(Http::StreamFilterPtr(instance)); - callbacks.addAccessLogHandler(Http::AccessLog::InstancePtr(instance)); - }; - } -}; - -static RegisterHttpFilterConfigFactory register_; -} -} diff --git a/src/envoy/prototype/dummy_api_manager_cluster.py b/src/envoy/prototype/dummy_api_manager_cluster.py deleted file mode 100644 index 3f83476aae8..00000000000 --- a/src/envoy/prototype/dummy_api_manager_cluster.py +++ /dev/null @@ -1,91 +0,0 @@ -from BaseHTTPServer import BaseHTTPRequestHandler -from BaseHTTPServer import HTTPServer -from subprocess import Popen, PIPE, STDOUT - -PUBLIC_KEY = '''{ - "keys": [ - { - "kty": "RSA", - "alg": "RS256", - "use": "sig", - "kid": "686f442dead739e241342519849bd0d140707a86", - "n": "yVGRzBnVmCHC9uMH_mCna7FiSKOjMEsDdgf8hds41KYfUHH9cp4P41iQEBnqPYvQiMYaZDuatkMDh25ukmkSyfLwJIVQpnHgMDwoZ1cx83Z0PwC8wAAJYqKyItKNfFN4UJ6DZIOVU-Iqgxi8VOtGwMNx2LiD1NoFVfXyz52UJ_QLiUGzErVwTGv4UD6NtaWKFkctTnEG-9rZvDF8QknnzxAomVa2OcV8OHeszx6N8UE1tm9Kq4xj2Uu8D3dDrfu2jr45Pi6RHIZOTAnu8G7wTDNaiGbENrbHSk6WAjLZBOcWZj9SDlDlwH2xFoKdpNKRmLKpPQblHem_y1KRYwvJTw", - "e": "AQAB" - }, - { - "kty": "RSA", - "alg": "RS256", - "use": "sig", - "kid": "d57d66bfbff089769e3545589572d3b53955a8cb", - "n": "zX99YCqicbn_j-5YTJ-2FsgONUg7cmqJiwvHXrUopRvn2Tukrd0B5Sg-Rq1hdZTYgIym7lSMw_zLxIQCH54sUfydX5MMWr6FOxVUbYl-E0Oko85Yer9dFv61rN0USj_A12QRMmjCZkcqH_6MWWuA1QWaejyStopjpLEYnUD3bP6oS604eZWkkOp8Nu-Vg4NqqX7ZClIcQqe03xv3sFHiPuhB-qaifhpIPpKCiYSKxAY4_GxwCJ_ml_uJ5k1tIrDykAlie6aWxv8hogOXrQmNRCO2Qcumwb7d9cci1UxsEYOtpZxhTiZqWsbrBxwfvLqU_rvsCT8vOjrBPOkTtYl22w", - "e": "AQAB" - }, - { - "kty": "RSA", - "alg": "RS256", - "use": "sig", - "kid": "516ca9a83b130d4b605684fe7df83b43f33fba43", - "n": "rSLxCvtRLoJUt2xPTSjDgN8_7kuBLsZz0JD4HRiwvId_IYY-T5MsUirBx01AtI3KRlmeQ-1QIvET4cNN99QL8U6e7Hh75VWJvQhh0_TFdKbv_75b81-rzx-EvIoVe0czeY3QeRp3DDORRk9o7xgri6U3VfT2zcQIDAPY14h3wLHE5DQuH9EpbxjS_wNrQxRYZH_mWgmWU7h001WHWRDKdEIgtzQkinKOTig90Wy4pt_vgMGcv0mh_wYvIcmB62Qj1sHUUOa5NJWUaZLC4Stj7CH0dLiBrVqg3JFqvO60Oo3wrcdmNQl0RaRHFjBYLameUPSP6M2BevfCRx8-Ix26rw", - "e": "AQAB" - }, - { - "kty": "RSA", - "alg": "RS256", - "use": "sig", - "kid": "33a681b36b8983913b05f8d5eab165c60694b6fc", - "n": "pRbWhLXIOvF1Naxh5n2evZqpJ3kPEFL4b-jHRHOhMnzqsi_aeQtIwYLVM8zdYYfgCxRq8umG1YwMenBKKPzRWr4MkFAB64O3UPgdyg-3je-fgCMziqS_3KH7AXHekxG_ZHpwbkgilRMtJNiDnSZWGad8XAfW3VFct4RqRAaf7h-6Za0IM7R3u4VYkUfosNqKtoDJDQrng9Nbv9ryUk8u1WikKF0M1r-wrZoDA7QFRAFkbdfYyvHL2daUflNDIXmFkUeHGGApMlJQ3wJk7Tln4txGMSUdJoD3JWEyKa2W1WshtqBHnQb8VlL77H-ch9zbn5pGZCoJ0MsgJr0vjoea8w", - "e": "AQAB" - }, - { - "kty": "RSA", - "alg": "RS256", - "use": "sig", - "kid": "986f2c30b9843defdc8f8debe138d640d1d67d9d", - "n": "qfE-u8I60zP_Vg3UsP_X9Qv1idkrnsXKkcQcsGWUdqs4jM2VixGBJDMJWbP55aJA93Sl49_dzAv_lr5-ctc1L04ke6nHX19EEBDtFTjGKyEdI-X1C-6HXCQmpI1XvUA8DzTOIZd5KEXJgBA9tpn6qkMAHzXyMHOfg8nhW36She4QggFjfF_RDKOA2-jRXDIjinOmIaLhVq4hsC9hCshhsfreLPw3HH8UhRONbkoFU_8ZBgAQLdVB1TQwp-ZDiVyh9od9a-RmfIiUl27AK5LDrtpVRCtXj6bv9OMx4QWVX8G-NfQexDwAp1pICaE5qYyJbiIK25E07vPTJ1ZtMpodFQ", - "e": "AQAB" - } - ] -} -''' - -def print_body(binary, expected): - p = Popen(['bazel-bin/src/tools/service_control_json_gen', - '--text', - '--'+expected, - '--stdin'], stdin=PIPE) - p.communicate(input=binary) - -class Handler(BaseHTTPRequestHandler): - def do_GET(self): - self.handle_request("GET") - - def do_POST(self): - self.handle_request("POST") - - - - def handle_request(self, method): - print(method, self.path, self.headers.items()) - url = self.headers.get('x-api-manager-url', '') - if url == 'https://www.googleapis.com/service_accounts/v1/jwk/loadtest@esp-test-client.iam.gserviceaccount.com': - self.send_response(200) - self.send_header('Content-Length', str(len(PUBLIC_KEY))) - self.end_headers() - self.wfile.write(PUBLIC_KEY) - else: - #content_len = self.headers.getheader('content-length', 0) - #post_body = self.rfile.read(int(content_len)) - if url.endswith(":report"): - print_body(post_body, "report_request") - elif url.endswith(":check"): - print_body(post_body, "check_request") - - self.send_response(200) - self.send_header('Content-Length', "0") - self.end_headers() - - -if __name__ == '__main__': - server = HTTPServer(('localhost', 8081), Handler) - print 'Starting server, use to stop' - server.serve_forever() diff --git a/src/envoy/prototype/envoy-esp.conf b/src/envoy/prototype/envoy-esp.conf deleted file mode 100644 index 27ea9f1b397..00000000000 --- a/src/envoy/prototype/envoy-esp.conf +++ /dev/null @@ -1,89 +0,0 @@ -{ - "listeners": [ - { - "port": 9092, - "bind_to_port": true, - "use_original_dst": true, - "filters": [] - }, - { - "port": 9090, - "bind_to_port": false, - "filters": [ - { - "type": "read", - "name": "http_connection_manager", - "config": { - "codec_type": "auto", - "stat_prefix": "ingress_http", - "route_config": { - "virtual_hosts": [ - { - "name": "backend", - "domains": ["*"], - "routes": [ - { - "timeout_ms": 0, - "prefix": "/", - "cluster": "service1" - } - ] - } - ] - }, - "access_log": [ - { - "path": "/dev/stdout" - } - ], - "filters": [ - { - "type": "both", - "name": "esp", - "config": { - "service_config": "src/envoy/prototype/generic_service_config.json", - "server_config": "src/envoy/prototype/server_config.pb.txt" - } - }, - { - "type": "decoder", - "name": "router", - "config": {} - } - ] - } - } - ] - } - ], - "admin": { - "access_log_path": "/dev/stdout", - "port": 9001 - }, - "cluster_manager": { - "clusters": [ - { - "name": "service1", - "connect_timeout_ms": 5000, - "type": "strict_dns", - "lb_type": "round_robin", - "hosts": [ - { - "url": "tcp://localhost:8080" - } - ] - }, - { - "name": "api_manager", - "connect_timeout_ms": 5000, - "type": "strict_dns", - "lb_type": "round_robin", - "hosts": [ - { - "url": "tcp://localhost:8081" - } - ] - } - ] - } -} diff --git a/src/envoy/prototype/generic_service_config.json b/src/envoy/prototype/generic_service_config.json deleted file mode 100644 index ac926e5e4c2..00000000000 --- a/src/envoy/prototype/generic_service_config.json +++ /dev/null @@ -1,736 +0,0 @@ -{ - "apis": [ - { - "methods": [ - { - "name": "Get", - "requestTypeUrl": "type.googleapis.com/google.protobuf.Empty", - "responseTypeUrl": "type.googleapis.com/google.protobuf.Value" - }, - { - "name": "Delete", - "requestTypeUrl": "type.googleapis.com/google.protobuf.Empty", - "responseTypeUrl": "type.googleapis.com/google.protobuf.Value" - }, - { - "name": "Patch", - "requestTypeUrl": "type.googleapis.com/google.protobuf.Empty", - "responseTypeUrl": "type.googleapis.com/google.protobuf.Value" - }, - { - "name": "Post", - "requestTypeUrl": "type.googleapis.com/google.protobuf.Empty", - "responseTypeUrl": "type.googleapis.com/google.protobuf.Value" - }, - { - "name": "Put", - "requestTypeUrl": "type.googleapis.com/google.protobuf.Empty", - "responseTypeUrl": "type.googleapis.com/google.protobuf.Value" - } - ], - "name": "generic_qiwzhang_app_1_appspot_com_1_0_0", - "sourceContext": { - "fileName": "sss.yaml" - }, - "version": "1.0.0" - } - ], - "authentication": {}, - "backend": { - "rules": [ - { - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Get" - }, - { - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Delete" - }, - { - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Patch" - }, - { - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Post" - }, - { - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Put" - } - ] - }, - "configVersion": 3, - "context": {}, - "control": { - "environment": "servicecontrol.googleapis.com" - }, - "customError": {}, - "documentation": {}, - "enums": [ - { - "enumvalue": [ - { - "name": "NULL_VALUE" - } - ], - "name": "google.protobuf.NullValue", - "sourceContext": { - "fileName": "struct.proto" - } - } - ], - "http": { - "rules": [ - { - "get": "/**", - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Get" - }, - { - "delete": "/**", - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Delete" - }, - { - "patch": "/**", - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Patch" - }, - { - "post": "/**", - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Post" - }, - { - "put": "/**", - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Put" - } - ] - }, - "id": "2017-01-06r0", - "logging": { - "producerDestinations": [ - { - "logs": [ - "endpoints_log" - ], - "monitoredResource": "api" - } - ] - }, - "logs": [ - { - "name": "endpoints_log" - } - ], - "metrics": [ - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/protocol" - }, - { - "key": "/response_code" - }, - { - "key": "/response_code_class" - }, - { - "key": "/status_code" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/request_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/error_type" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/error_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/total_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/protocol" - }, - { - "key": "/response_code" - }, - { - "key": "/response_code_class" - }, - { - "key": "/status_code" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/request_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/error_type" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/error_count", - "valueType": "INT64" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/total_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/end_user" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/top_request_count_by_end_user", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/end_user_country" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/top_request_count_by_end_user_country", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/referer" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/top_request_count_by_referer", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/protocol" - }, - { - "key": "/response_code" - }, - { - "key": "/consumer_id" - }, - { - "key": "/status_code" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/top_request_count_by_consumer", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/quota_group_name" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/quota_used_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/quota_group_name" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/quota_billable_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/request_overhead_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/backend_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/request_sizes", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/response_sizes", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/request_overhead_latencies", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/backend_latencies", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/request_sizes", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/response_sizes", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/consumer_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/top_request_sizes_by_consumer", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/consumer_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/top_response_sizes_by_consumer", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/protocol" - }, - { - "key": "/response_code" - }, - { - "key": "/response_code_class" - }, - { - "key": "/status_code" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/request_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/error_type" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/error_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/total_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - }, - { - "key": "/quota_group_name" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/quota_used_count", - "valueType": "INT64" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/request_overhead_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/backend_latencies", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/request_sizes", - "valueType": "DISTRIBUTION" - }, - { - "labels": [ - { - "key": "/credential_id" - } - ], - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/by_consumer/response_sizes", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/streaming_request_message_counts", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/streaming_response_message_counts", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/streaming_request_message_counts", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/streaming_response_message_counts", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/streaming_durations", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/streaming_durations", - "valueType": "DISTRIBUTION" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/request_bytes", - "valueType": "INT64" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/producer/response_bytes", - "valueType": "INT64" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/request_bytes", - "valueType": "INT64" - }, - { - "metricKind": "DELTA", - "name": "serviceruntime.googleapis.com/api/consumer/response_bytes", - "valueType": "INT64" - } - ], - "monitoredResources": [ - { - "labels": [ - { - "key": "cloud.googleapis.com/location" - }, - { - "key": "cloud.googleapis.com/uid" - }, - { - "key": "serviceruntime.googleapis.com/api_version" - }, - { - "key": "serviceruntime.googleapis.com/api_method" - }, - { - "key": "serviceruntime.googleapis.com/consumer_project" - }, - { - "key": "cloud.googleapis.com/project" - }, - { - "key": "cloud.googleapis.com/service" - } - ], - "type": "api" - } - ], - "monitoring": { - "consumerDestinations": [ - { - "metrics": [ - "serviceruntime.googleapis.com/api/consumer/request_count", - "serviceruntime.googleapis.com/api/consumer/error_count", - "serviceruntime.googleapis.com/api/consumer/quota_used_count", - "serviceruntime.googleapis.com/api/consumer/total_latencies", - "serviceruntime.googleapis.com/api/consumer/request_overhead_latencies", - "serviceruntime.googleapis.com/api/consumer/backend_latencies", - "serviceruntime.googleapis.com/api/consumer/request_sizes", - "serviceruntime.googleapis.com/api/consumer/response_sizes", - "serviceruntime.googleapis.com/api/consumer/top_request_count_by_end_user", - "serviceruntime.googleapis.com/api/consumer/top_request_count_by_end_user_country", - "serviceruntime.googleapis.com/api/consumer/top_request_count_by_referer", - "serviceruntime.googleapis.com/api/consumer/streaming_request_message_counts", - "serviceruntime.googleapis.com/api/consumer/streaming_response_message_counts", - "serviceruntime.googleapis.com/api/consumer/streaming_durations", - "serviceruntime.googleapis.com/api/consumer/request_bytes", - "serviceruntime.googleapis.com/api/consumer/response_bytes" - ], - "monitoredResource": "api" - } - ], - "producerDestinations": [ - { - "metrics": [ - "serviceruntime.googleapis.com/api/producer/request_count", - "serviceruntime.googleapis.com/api/producer/error_count", - "serviceruntime.googleapis.com/api/producer/total_latencies", - "serviceruntime.googleapis.com/api/producer/request_overhead_latencies", - "serviceruntime.googleapis.com/api/producer/backend_latencies", - "serviceruntime.googleapis.com/api/producer/request_sizes", - "serviceruntime.googleapis.com/api/producer/response_sizes", - "serviceruntime.googleapis.com/api/producer/top_request_count_by_consumer", - "serviceruntime.googleapis.com/api/producer/top_request_sizes_by_consumer", - "serviceruntime.googleapis.com/api/producer/top_response_sizes_by_consumer", - "serviceruntime.googleapis.com/api/producer/streaming_request_message_counts", - "serviceruntime.googleapis.com/api/producer/streaming_response_message_counts", - "serviceruntime.googleapis.com/api/producer/streaming_durations", - "serviceruntime.googleapis.com/api/producer/request_bytes", - "serviceruntime.googleapis.com/api/producer/response_bytes", - "serviceruntime.googleapis.com/api/producer/by_consumer/request_count", - "serviceruntime.googleapis.com/api/producer/by_consumer/error_count", - "serviceruntime.googleapis.com/api/producer/by_consumer/total_latencies", - "serviceruntime.googleapis.com/api/producer/by_consumer/quota_used_count", - "serviceruntime.googleapis.com/api/producer/by_consumer/request_overhead_latencies", - "serviceruntime.googleapis.com/api/producer/by_consumer/backend_latencies", - "serviceruntime.googleapis.com/api/producer/by_consumer/request_sizes", - "serviceruntime.googleapis.com/api/producer/by_consumer/response_sizes" - ], - "monitoredResource": "api" - } - ] - }, - "name": "generic.qiwzhang-app-1.appspot.com", - "producerProjectId": "qiwzhang-app-1", - "systemParameters": {}, - "title": "Basic HTTP service configuration", - "types": [ - { - "fields": [ - { - "cardinality": "CARDINALITY_REPEATED", - "jsonName": "values", - "kind": "TYPE_MESSAGE", - "name": "values", - "number": 1, - "typeUrl": "type.googleapis.com/google.protobuf.Value" - } - ], - "name": "google.protobuf.ListValue", - "sourceContext": { - "fileName": "struct.proto" - } - }, - { - "fields": [ - { - "cardinality": "CARDINALITY_REPEATED", - "jsonName": "fields", - "kind": "TYPE_MESSAGE", - "name": "fields", - "number": 1, - "typeUrl": "type.googleapis.com/google.protobuf.Struct.FieldsEntry" - } - ], - "name": "google.protobuf.Struct", - "sourceContext": { - "fileName": "struct.proto" - } - }, - { - "fields": [ - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "key", - "kind": "TYPE_STRING", - "name": "key", - "number": 1 - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "value", - "kind": "TYPE_MESSAGE", - "name": "value", - "number": 2, - "typeUrl": "type.googleapis.com/google.protobuf.Value" - } - ], - "name": "google.protobuf.Struct.FieldsEntry", - "sourceContext": { - "fileName": "struct.proto" - } - }, - { - "name": "google.protobuf.Empty", - "sourceContext": { - "fileName": "struct.proto" - } - }, - { - "fields": [ - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "nullValue", - "kind": "TYPE_ENUM", - "name": "null_value", - "number": 1, - "typeUrl": "type.googleapis.com/google.protobuf.NullValue" - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "numberValue", - "kind": "TYPE_DOUBLE", - "name": "number_value", - "number": 2 - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "stringValue", - "kind": "TYPE_STRING", - "name": "string_value", - "number": 3 - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "boolValue", - "kind": "TYPE_BOOL", - "name": "bool_value", - "number": 4 - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "structValue", - "kind": "TYPE_MESSAGE", - "name": "struct_value", - "number": 5, - "typeUrl": "type.googleapis.com/google.protobuf.Struct" - }, - { - "cardinality": "CARDINALITY_OPTIONAL", - "jsonName": "listValue", - "kind": "TYPE_MESSAGE", - "name": "list_value", - "number": 6, - "typeUrl": "type.googleapis.com/google.protobuf.ListValue" - } - ], - "name": "google.protobuf.Value", - "sourceContext": { - "fileName": "struct.proto" - } - } - ], - "usage": { - "rules": [ - { - "allowUnregisteredCalls": true, - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Get" - }, - { - "allowUnregisteredCalls": true, - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Delete" - }, - { - "allowUnregisteredCalls": true, - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Patch" - }, - { - "allowUnregisteredCalls": true, - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Post" - }, - { - "allowUnregisteredCalls": true, - "selector": "generic_qiwzhang_app_1_appspot_com_1_0_0.Put" - } - ] - }, - "visibility": {} -} diff --git a/src/envoy/prototype/server_config.pb.txt b/src/envoy/prototype/server_config.pb.txt deleted file mode 100644 index 19cb6cbb2c0..00000000000 --- a/src/envoy/prototype/server_config.pb.txt +++ /dev/null @@ -1,6 +0,0 @@ -cloud_tracing_config { - force_disable: true -} -mixer_options { - mixer_server: "localhost:9091" -}