Skip to content

Commit

Permalink
update envoy wasm sha (envoyproxy#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
bianpengyuan authored and istio-testing committed Jan 9, 2020
1 parent a799857 commit 6f7d891
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 54 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ bind(
# 2. Update .bazelversion, envoy.bazelrc and .bazelrc if needed.
#
# envoy-wasm commit date: 12/19/19
ENVOY_SHA = "9cf22b854ed48b8d62bf480c6a2730fa958740de"
ENVOY_SHA = "456bf9aef22d7b4df4916fa49c5dad2f5dbf0f0f"

ENVOY_SHA256 = "f4297087e5f75defe24f75e87d6dccd7b1f43b8262aade62bc2fa17b9c8acb8a"
ENVOY_SHA256 = "e26750cabcd5d55d4c91a08f63328bdfcacb47eb87ae3c807152b7345a0faf65"

# To override with local envoy, just pass `--override_repository=envoy=/PATH/TO/ENVOY` to Bazel or
# persist the option in `user.bazelrc`.
Expand Down
4 changes: 2 additions & 2 deletions extensions/access_log_policy/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ void PluginContext::onLog() {
// not, based on last time a successful request was logged for this client ip
// and principal combination.
std::string downstream_ip = "";
getStringValue({kDestination, kAddress}, &downstream_ip);
getValue({kDestination, kAddress}, &downstream_ip);
std::string source_principal = "";
getStringValue({kConnection, kUriSanPeerCertificate}, &source_principal);
getValue({kConnection, kUriSanPeerCertificate}, &source_principal);
istio_dimensions_.set_downstream_ip(downstream_ip);
istio_dimensions_.set_source_principal(source_principal);
long long last_log_time_nanos = lastLogTimeNanos();
Expand Down
34 changes: 16 additions & 18 deletions extensions/common/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ using Envoy::Extensions::Common::Wasm::HeaderMapType;
using Envoy::Extensions::Common::Wasm::WasmResult;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getCurrentTimeNanoseconds;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getHeaderMapValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getStringValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getStructValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getMessageValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getValue;

#endif // NULL_PLUGIN
Expand Down Expand Up @@ -103,7 +102,7 @@ void getDestinationService(const std::string& dest_namespace,
bool use_host_header, std::string* dest_svc_host,
std::string* dest_svc_name) {
std::string cluster_name;
getStringValue({"cluster_name"}, &cluster_name);
getValue({"cluster_name"}, &cluster_name);
*dest_svc_host = use_host_header
? getHeaderMapValue(HeaderMapType::RequestHeaders,
kAuthorityHeaderKey)
Expand Down Expand Up @@ -137,33 +136,32 @@ void populateRequestInfo(bool outbound, bool use_host_header_fallback,
&request_info->destination_service_name);

// Get rbac labels from dynamic metadata.
getStringValue({"metadata", kRbacFilterName, kRbacPermissivePolicyIDField},
&request_info->rbac_permissive_policy_id);
getStringValue(
{"metadata", kRbacFilterName, kRbacPermissiveEngineResultField},
&request_info->rbac_permissive_engine_result);
getValue({"metadata", kRbacFilterName, kRbacPermissivePolicyIDField},
&request_info->rbac_permissive_policy_id);
getValue({"metadata", kRbacFilterName, kRbacPermissiveEngineResultField},
&request_info->rbac_permissive_engine_result);

getStringValue({"request", "url_path"}, &request_info->request_url_path);
getValue({"request", "url_path"}, &request_info->request_url_path);

if (outbound) {
uint64_t destination_port = 0;
getValue({"upstream", "port"}, &destination_port);
request_info->destination_port = destination_port;
getStringValue({"upstream", "uri_san_peer_certificate"},
&request_info->destination_principal);
getStringValue({"upstream", "uri_san_local_certificate"},
&request_info->source_principal);
getValue({"upstream", "uri_san_peer_certificate"},
&request_info->destination_principal);
getValue({"upstream", "uri_san_local_certificate"},
&request_info->source_principal);
} else {
bool mtls = false;
if (getValue({"connection", "mtls"}, &mtls)) {
request_info->service_auth_policy =
mtls ? ::Wasm::Common::ServiceAuthenticationPolicy::MutualTLS
: ::Wasm::Common::ServiceAuthenticationPolicy::None;
}
getStringValue({"connection", "uri_san_local_certificate"},
&request_info->destination_principal);
getStringValue({"connection", "uri_san_peer_certificate"},
&request_info->source_principal);
getValue({"connection", "uri_san_local_certificate"},
&request_info->destination_principal);
getValue({"connection", "uri_san_peer_certificate"},
&request_info->source_principal);
}

uint64_t response_flags = 0;
Expand Down Expand Up @@ -255,7 +253,7 @@ google::protobuf::util::Status extractNodeMetadataGeneric(
google::protobuf::util::Status extractLocalNodeMetadata(
wasm::common::NodeInfo* node_info) {
google::protobuf::Struct node;
if (!getStructValue({"node", "metadata"}, &node)) {
if (!getMessageValue({"node", "metadata"}, &node)) {
return google::protobuf::util::Status(
google::protobuf::util::error::Code::NOT_FOUND, "metadata not found");
}
Expand Down
7 changes: 3 additions & 4 deletions extensions/common/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <set>

#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "extensions/common/node_info.pb.h"
#include "google/protobuf/struct.pb.h"

Expand Down Expand Up @@ -69,10 +68,10 @@ StringView AuthenticationPolicyString(ServiceAuthenticationPolicy policy);
// callbacks. This is used to fill metrics and logs.
struct RequestInfo {
// Start timestamp in nanoseconds.
absl::Time start_time;
int64_t start_time;

// The total duration of the request.
absl::Duration duration;
// The total duration of the request in nanoseconds.
int64_t duration;

// Request total size in bytes, include header, body, and trailer.
int64_t request_size = 0;
Expand Down
8 changes: 4 additions & 4 deletions extensions/common/node_info_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ using google::protobuf::util::Status;

#ifdef NULL_PLUGIN

using Envoy::Extensions::Common::Wasm::Null::Plugin::getStringValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getStructValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getMessageValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::logDebug;
using Envoy::Extensions::Common::Wasm::Null::Plugin::logInfo;

Expand All @@ -40,7 +40,7 @@ namespace {
bool getNodeInfo(StringView peer_metadata_key,
wasm::common::NodeInfo* node_info) {
google::protobuf::Struct metadata;
if (!getStructValue({"filter_state", peer_metadata_key}, &metadata)) {
if (!getMessageValue({"filter_state", peer_metadata_key}, &metadata)) {
LOG_DEBUG(absl::StrCat("cannot get metadata for: ", peer_metadata_key));
return false;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ NodeInfoPtr NodeInfoCache::getPeerById(StringView peer_metadata_id_key,
}

std::string peer_id;
if (!getStringValue({"filter_state", peer_metadata_id_key}, &peer_id)) {
if (!getValue({"filter_state", peer_metadata_id_key}, &peer_id)) {
LOG_DEBUG(absl::StrCat("cannot get metadata for: ", peer_metadata_id_key));
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/metadata_exchange/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static RegisterContextFactory register_MetadataExchange(

void PluginRootContext::updateMetadataValue() {
google::protobuf::Struct node_metadata;
if (!getStructValue({"node", "metadata"}, &node_metadata)) {
if (!getMessageValue({"node", "metadata"}, &node_metadata)) {
logWarn("cannot get node metadata");
return;
}
Expand All @@ -88,7 +88,7 @@ void PluginRootContext::updateMetadataValue() {

bool PluginRootContext::onConfigure(size_t) {
updateMetadataValue();
if (!getStringValue({"node", "id"}, &node_id_)) {
if (!getValue({"node", "id"}, &node_id_)) {
logDebug("cannot get node ID");
}
logDebug(absl::StrCat("metadata_value_ id:", id(), " value:", metadata_value_,
Expand Down
8 changes: 3 additions & 5 deletions extensions/stackdriver/log/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ void Logger::addLogEntry(const ::Wasm::Common::RequestInfo& request_info,
auto* log_entries = log_entries_request_->mutable_entries();
auto* new_entry = log_entries->Add();

const int64_t s = absl::ToUnixSeconds(request_info.start_time);
new_entry->mutable_timestamp()->set_seconds(s);
new_entry->mutable_timestamp()->set_nanos(
(request_info.start_time - absl::FromUnixSeconds(s)) /
absl::Nanoseconds(1));
*new_entry->mutable_timestamp() =
google::protobuf::util::TimeUtil::NanosecondsToTimestamp(
request_info.start_time);
new_entry->set_severity(::google::logging::type::INFO);
auto label_map = new_entry->mutable_labels();
(*label_map)["source_name"] = peer_node_info.name();
Expand Down
2 changes: 1 addition & 1 deletion extensions/stackdriver/log/logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ wasm::common::NodeInfo peerNodeInfo() {

::Wasm::Common::RequestInfo requestInfo() {
::Wasm::Common::RequestInfo request_info;
request_info.start_time = absl::UnixEpoch();
request_info.start_time = 0;
request_info.request_operation = "GET";
request_info.destination_service_host = "httpbin.org";
request_info.response_flag = "-";
Expand Down
2 changes: 1 addition & 1 deletion extensions/stackdriver/metric/record.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Metric {
void record(bool is_outbound, const ::wasm::common::NodeInfo &local_node_info,
const ::wasm::common::NodeInfo &peer_node_info,
const ::Wasm::Common::RequestInfo &request_info) {
double latency_ms = request_info.duration / absl::Nanoseconds(1) / 1000.0;
double latency_ms = request_info.duration / 1000.0;
const auto &operation =
request_info.request_protocol == ::Wasm::Common::kProtocolGRPC
? request_info.request_url_path
Expand Down
26 changes: 12 additions & 14 deletions extensions/stackdriver/stackdriver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace opencensus::exporters::stats;
using namespace google::protobuf::util;
using namespace ::Extensions::Stackdriver::Common;
using namespace ::Extensions::Stackdriver::Metric;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getStringValue;
using Envoy::Extensions::Common::Wasm::Null::Plugin::getValue;
using ::Extensions::Stackdriver::Edges::EdgeReporter;
using Extensions::Stackdriver::Edges::MeshEdgesServiceClientImpl;
using Extensions::Stackdriver::Log::ExporterImpl;
Expand All @@ -68,8 +68,8 @@ namespace {
// it is not found.
std::string getMonitoringEndpoint() {
std::string monitoring_service;
if (!getStringValue({"node", "metadata", kMonitoringEndpointKey},
&monitoring_service)) {
if (!getValue({"node", "metadata", kMonitoringEndpointKey},
&monitoring_service)) {
return "";
}
return monitoring_service;
Expand All @@ -79,8 +79,7 @@ std::string getMonitoringEndpoint() {
// is not found.
std::string getLoggingEndpoint() {
std::string logging_service;
if (!getStringValue({"node", "metadata", kLoggingEndpointKey},
&logging_service)) {
if (!getValue({"node", "metadata", kLoggingEndpointKey}, &logging_service)) {
return "";
}
return logging_service;
Expand All @@ -90,8 +89,8 @@ std::string getLoggingEndpoint() {
// if it is not found.
std::string getMeshTelemetryEndpoint() {
std::string mesh_telemetry_service;
if (!getStringValue({"node", "metadata", kMeshTelemetryEndpointKey},
&mesh_telemetry_service)) {
if (!getValue({"node", "metadata", kMeshTelemetryEndpointKey},
&mesh_telemetry_service)) {
return "";
}
return mesh_telemetry_service;
Expand All @@ -101,8 +100,8 @@ std::string getMeshTelemetryEndpoint() {
// is not found in metadata.
int getExportInterval() {
std::string interval_s = "";
if (getStringValue({"node", "metadata", kMonitoringExportIntervalKey},
&interval_s)) {
if (getValue({"node", "metadata", kMonitoringExportIntervalKey},
&interval_s)) {
return std::stoi(interval_s);
}
return 60;
Expand Down Expand Up @@ -216,9 +215,8 @@ void StackdriverRootContext::record() {
}
if (enableEdgeReporting()) {
std::string peer_id;
if (!getStringValue(
{"filter_state", ::Wasm::Common::kDownstreamMetadataIdKey},
&peer_id)) {
if (!getValue({"filter_state", ::Wasm::Common::kDownstreamMetadataIdKey},
&peer_id)) {
LOG_DEBUG(absl::StrCat(
"cannot get metadata for: ", ::Wasm::Common::kDownstreamMetadataIdKey,
"; skipping edge."));
Expand Down Expand Up @@ -251,8 +249,8 @@ inline bool StackdriverRootContext::enableEdgeReporting() {

bool StackdriverRootContext::shouldLogThisRequest() {
std::string shouldLog = "";
if (!getStringValue({"filter_state", ::Wasm::Common::kAccessLogPolicyKey},
&shouldLog)) {
if (!getValue({"filter_state", ::Wasm::Common::kAccessLogPolicyKey},
&shouldLog)) {
LOG_DEBUG("cannot get envoy access log info from filter state.");
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/stats/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool PluginRootContext::onConfigure(size_t) {
absl::StrCat(stat_prefix, "request_duration_milliseconds"),
MetricType::Histogram,
[](const ::Wasm::Common::RequestInfo& request_info) -> uint64_t {
return request_info.duration / absl::Milliseconds(1);
return request_info.duration / 1000;
},
field_separator, value_separator),
StatGen(
Expand Down

0 comments on commit 6f7d891

Please sign in to comment.