diff --git a/WORKSPACE b/WORKSPACE index 22d20fabc1ae..1bc4a2730a31 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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`. diff --git a/extensions/access_log_policy/plugin.cc b/extensions/access_log_policy/plugin.cc index b75df910c48d..cf761860ee61 100644 --- a/extensions/access_log_policy/plugin.cc +++ b/extensions/access_log_policy/plugin.cc @@ -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(); diff --git a/extensions/common/context.cc b/extensions/common/context.cc index 0698b7703939..0abfd1877cf2 100644 --- a/extensions/common/context.cc +++ b/extensions/common/context.cc @@ -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 @@ -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) @@ -137,22 +136,21 @@ 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)) { @@ -160,10 +158,10 @@ void populateRequestInfo(bool outbound, bool use_host_header_fallback, 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; @@ -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"); } diff --git a/extensions/common/context.h b/extensions/common/context.h index fe3b8c6886b4..e900bb840b2a 100644 --- a/extensions/common/context.h +++ b/extensions/common/context.h @@ -18,7 +18,6 @@ #include #include "absl/strings/string_view.h" -#include "absl/time/time.h" #include "extensions/common/node_info.pb.h" #include "google/protobuf/struct.pb.h" @@ -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; diff --git a/extensions/common/node_info_cache.cc b/extensions/common/node_info_cache.cc index d5059abeeb95..7ed2001ab251 100644 --- a/extensions/common/node_info_cache.cc +++ b/extensions/common/node_info_cache.cc @@ -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; @@ -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; } @@ -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; } diff --git a/extensions/metadata_exchange/plugin.cc b/extensions/metadata_exchange/plugin.cc index 7bd857157241..8e27f8bf565d 100644 --- a/extensions/metadata_exchange/plugin.cc +++ b/extensions/metadata_exchange/plugin.cc @@ -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; } @@ -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_, diff --git a/extensions/stackdriver/log/logger.cc b/extensions/stackdriver/log/logger.cc index 2896634379c8..cc757cb22192 100644 --- a/extensions/stackdriver/log/logger.cc +++ b/extensions/stackdriver/log/logger.cc @@ -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(); diff --git a/extensions/stackdriver/log/logger_test.cc b/extensions/stackdriver/log/logger_test.cc index 6416923a78db..b82f4b3586cf 100644 --- a/extensions/stackdriver/log/logger_test.cc +++ b/extensions/stackdriver/log/logger_test.cc @@ -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 = "-"; diff --git a/extensions/stackdriver/metric/record.cc b/extensions/stackdriver/metric/record.cc index 99db59622997..222c5ee61e69 100644 --- a/extensions/stackdriver/metric/record.cc +++ b/extensions/stackdriver/metric/record.cc @@ -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 diff --git a/extensions/stackdriver/stackdriver.cc b/extensions/stackdriver/stackdriver.cc index de16abe0625e..549f479515a0 100644 --- a/extensions/stackdriver/stackdriver.cc +++ b/extensions/stackdriver/stackdriver.cc @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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.")); @@ -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; } diff --git a/extensions/stats/plugin.cc b/extensions/stats/plugin.cc index ab46713b631d..8907c2268738 100644 --- a/extensions/stats/plugin.cc +++ b/extensions/stats/plugin.cc @@ -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(