From d5a878a10b899332639a46d83ce1e56356575baa Mon Sep 17 00:00:00 2001 From: Qian Sun Date: Mon, 13 Feb 2017 16:27:14 -0800 Subject: [PATCH 1/5] Get attributes from envoy config. (#87) * Send all attributes. * Remove unused const strings. * Address comment. --- src/envoy/mixer/http_control.cc | 24 ++++++------------------ src/envoy/mixer/http_control.h | 9 ++++----- src/envoy/mixer/http_filter.cc | 10 +++++++++- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/envoy/mixer/http_control.cc b/src/envoy/mixer/http_control.cc index 6ae266ef088..870d70956fb 100644 --- a/src/envoy/mixer/http_control.cc +++ b/src/envoy/mixer/http_control.cc @@ -38,12 +38,6 @@ const std::string kAttrNameResponseTime = "response.time"; const std::string kAttrNameOriginIp = "origin.ip"; const std::string kAttrNameOriginHost = "origin.host"; -const std::string kEnvNameSourceService = "SOURCE_SERVICE"; -const std::string kEnvNameTargetService = "TARGET_SERVICE"; - -const std::string kAttrNameSourceService = "source.service"; -const std::string kAttrNameTargetService = "target.service"; - Attributes::Value StringValue(const std::string& str) { Attributes::Value v; v.type = Attributes::Value::STRING; @@ -134,27 +128,21 @@ void FillRequestInfoAttributes(const AccessLog::RequestInfo& info, } // namespace -HttpControl::HttpControl(const std::string& mixer_server) { +HttpControl::HttpControl(const std::string& mixer_server, + std::map&& attributes) + : config_attributes_(std::move(attributes)) { ::istio::mixer_client::MixerClientOptions options; options.mixer_server = mixer_server; mixer_client_ = ::istio::mixer_client::CreateMixerClient(options); - - auto source_service = getenv(kEnvNameSourceService.c_str()); - if (source_service) { - source_service_ = source_service; - } - auto target_service = getenv(kEnvNameTargetService.c_str()); - if (target_service) { - target_service_ = target_service; - } } void HttpControl::FillCheckAttributes(const HeaderMap& header_map, Attributes* attr) { FillRequestHeaderAttributes(header_map, attr); - SetStringAttribute(kAttrNameSourceService, source_service_, attr); - SetStringAttribute(kAttrNameTargetService, target_service_, attr); + for (const auto& attribute : config_attributes_) { + SetStringAttribute(attribute.first, attribute.second, attr); + } } void HttpControl::Check(HttpRequestDataPtr request_data, HeaderMap& headers, diff --git a/src/envoy/mixer/http_control.h b/src/envoy/mixer/http_control.h index 312016e419c..bf52e49a81a 100644 --- a/src/envoy/mixer/http_control.h +++ b/src/envoy/mixer/http_control.h @@ -37,7 +37,8 @@ typedef std::shared_ptr HttpRequestDataPtr; class HttpControl final : public Logger::Loggable { public: // The constructor. - HttpControl(const std::string& mixer_server); + HttpControl(const std::string& mixer_server, + std::map&& attributes); // Make mixer check call. void Check(HttpRequestDataPtr request_data, HeaderMap& headers, @@ -55,10 +56,8 @@ class HttpControl final : public Logger::Loggable { // The mixer client std::unique_ptr<::istio::mixer_client::MixerClient> mixer_client_; - // Source service - std::string source_service_; - // Target service - std::string target_service_; + // The attributes read from the config file. + std::map config_attributes_; }; } // namespace Mixer diff --git a/src/envoy/mixer/http_filter.cc b/src/envoy/mixer/http_filter.cc index ec209b1ff98..a37ac032ee1 100644 --- a/src/envoy/mixer/http_filter.cc +++ b/src/envoy/mixer/http_filter.cc @@ -96,7 +96,15 @@ class Config : public Logger::Loggable { __func__); } - http_control_ = std::make_shared(mixer_server); + std::map attributes; + if (config.hasObject("attributes")) { + for (const std::string& attr : config.getStringArray("attributes")) { + attributes[attr] = config.getString(attr); + } + } + + http_control_ = + std::make_shared(mixer_server, std::move(attributes)); log().debug("Called Mixer::Config contructor with mixer_server: ", mixer_server); } From 25adae9db6ab1b499815ba7a8fd87d4309cdff69 Mon Sep 17 00:00:00 2001 From: GregHanson Date: Tue, 14 Feb 2017 15:51:40 -0600 Subject: [PATCH 2/5] updated SHA to point to newer envoy with RDS API feature (#94) --- src/envoy/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/envoy/repositories.bzl b/src/envoy/repositories.bzl index 94f371ebc7d..ec140710592 100644 --- a/src/envoy/repositories.bzl +++ b/src/envoy/repositories.bzl @@ -629,6 +629,6 @@ cc_test( native.new_git_repository( name = "envoy_git", remote = "https://github.com/lyft/envoy.git", - commit = "02c6fc97b4c21d25ab596a25208fbe283e927f6a", + commit = "fa1d9680d809668fef2ec9386769c79486029f04", build_file_content = BUILD, ) From 1cdc2ac135ba642d79fb584104232b2964fd5c6e Mon Sep 17 00:00:00 2001 From: Sebastien Vas Date: Tue, 14 Feb 2017 16:35:15 -0800 Subject: [PATCH 3/5] Disable travis on stable branches (#96) --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index d8559616e6d..88be42c285b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ sudo: required dist: xenial +branches: + except: + - stable + lang: go go: From 2f69cc985fc28e8131eba36ee24c21cfa535384e Mon Sep 17 00:00:00 2001 From: Kuat Date: Wed, 15 Feb 2017 14:36:06 -0800 Subject: [PATCH 4/5] Publish debug binaries (no release yet) (#98) --- script/release-binary | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/release-binary b/script/release-binary index 61d446533b8..13c4aea2bc7 100755 --- a/script/release-binary +++ b/script/release-binary @@ -36,7 +36,7 @@ gsutil stat "${DST}/${BINARY_NAME}" \ || echo 'Building a new binary.' # Build the binary -bazel build --config=release //src/envoy/mixer:envoy_tar +bazel build -c dbg //src/envoy/mixer:envoy_tar BAZEL_TARGET="bazel-bin/src/envoy/mixer/envoy_tar.tar.gz" ln "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -44,4 +44,3 @@ sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" # Copy it to the bucket. echo "Copying ${BINARY_NAME} ${SHA256_NAME} to ${DST}/" gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/" - From 84881332f5e3f31e64b06e46d61964b5ed390bac Mon Sep 17 00:00:00 2001 From: Sebastien Vas Date: Thu, 16 Feb 2017 13:38:01 -0800 Subject: [PATCH 5/5] Copies the binary instead of linking for release (#102) --- script/release-binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release-binary b/script/release-binary index 13c4aea2bc7..98bbc67a173 100755 --- a/script/release-binary +++ b/script/release-binary @@ -38,7 +38,7 @@ gsutil stat "${DST}/${BINARY_NAME}" \ # Build the binary bazel build -c dbg //src/envoy/mixer:envoy_tar BAZEL_TARGET="bazel-bin/src/envoy/mixer/envoy_tar.tar.gz" -ln "${BAZEL_TARGET}" "${BINARY_NAME}" +cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" # Copy it to the bucket.