diff --git a/.github/workflows/psm-interop.yaml b/.github/workflows/psm-interop.yaml index 4ab8094e36032..ddbce2fbcdb54 100644 --- a/.github/workflows/psm-interop.yaml +++ b/.github/workflows/psm-interop.yaml @@ -5,7 +5,6 @@ on: push: branches: - master - - 'v1.*' permissions: contents: read diff --git a/src/compiler/config.h b/src/compiler/config.h index 91f4b4d7826e1..49c78755b50b2 100644 --- a/src/compiler/config.h +++ b/src/compiler/config.h @@ -40,7 +40,8 @@ namespace protobuf { namespace compiler { typedef GRPC_CUSTOM_CODEGENERATOR CodeGenerator; typedef GRPC_CUSTOM_GENERATORCONTEXT GeneratorContext; -static inline int PluginMain(int argc, char* argv[], CodeGenerator* generator) { +static inline int PluginMain(int argc, char* argv[], + const CodeGenerator* generator) { return GRPC_CUSTOM_PLUGINMAIN(argc, argv, generator); } static inline void ParseGeneratorParameter( diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc index c5445c3dcf29a..02949cac379e6 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc @@ -18,6 +18,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.h" +#include #include #include @@ -430,7 +431,10 @@ void XdsOverrideHostLb::ResetBackoffLocked() { absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { - gpr_log(GPR_INFO, "[xds_override_host_lb %p] Received update", this); + gpr_log(GPR_INFO, + "[xds_override_host_lb %p] Received update with %" PRIuPTR + " addresses", + this, args.addresses.ok() ? args.addresses->size() : 0); } auto old_config = std::move(config_); // Update config. @@ -498,6 +502,10 @@ OrphanablePtr XdsOverrideHostLb::CreateChildPolicyLocked( absl::StatusOr XdsOverrideHostLb::UpdateAddressMap( absl::StatusOr addresses) { if (!addresses.ok()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, "[xds_override_host_lb %p] address error: %s", this, + addresses.status().ToString().c_str()); + } return addresses; } ServerAddressList return_value; @@ -505,13 +513,30 @@ absl::StatusOr XdsOverrideHostLb::UpdateAddressMap( for (const auto& address : *addresses) { XdsHealthStatus status = GetAddressHealthStatus(address); if (status.status() != XdsHealthStatus::kDraining) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, + "[xds_override_host_lb %p] address %s: not draining, " + "passing to child", + this, address.ToString().c_str()); + } return_value.push_back(address); } else if (!config_->override_host_status_set().Contains(status)) { // Skip draining hosts if not in the override status set. + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, + "[xds_override_host_lb %p] address %s: draining but not in " + "override_host_status set -- ignoring", + this, address.ToString().c_str()); + } continue; } auto key = grpc_sockaddr_to_uri(&address.address()); if (key.ok()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, + "[xds_override_host_lb %p] address %s: adding map key %s", this, + address.ToString().c_str(), key->c_str()); + } addresses_for_map.emplace(std::move(*key), status); } } @@ -519,6 +544,10 @@ absl::StatusOr XdsOverrideHostLb::UpdateAddressMap( MutexLock lock(&subchannel_map_mu_); for (auto it = subchannel_map_.begin(); it != subchannel_map_.end();) { if (addresses_for_map.find(it->first) == addresses_for_map.end()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, "[xds_override_host_lb %p] removing map key %s", + this, it->first.c_str()); + } it = subchannel_map_.erase(it); } else { ++it; @@ -527,10 +556,20 @@ absl::StatusOr XdsOverrideHostLb::UpdateAddressMap( for (const auto& key_status : addresses_for_map) { auto it = subchannel_map_.find(key_status.first); if (it == subchannel_map_.end()) { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, "[xds_override_host_lb %p] adding map key %s", this, + key_status.first.c_str()); + } subchannel_map_.emplace(std::piecewise_construct, std::forward_as_tuple(key_status.first), std::forward_as_tuple(key_status.second)); } else { + if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_override_host_trace)) { + gpr_log(GPR_INFO, + "[xds_override_host_lb %p] setting EDS health status for " + "%s to %s", + this, key_status.first.c_str(), key_status.second.ToString()); + } it->second.SetEdsHealthStatus(key_status.second); } } diff --git a/src/core/ext/transport/chttp2/transport/frame.cc b/src/core/ext/transport/chttp2/transport/frame.cc index 0a88aff5c9ab3..4a297d546d1a6 100644 --- a/src/core/ext/transport/chttp2/transport/frame.cc +++ b/src/core/ext/transport/chttp2/transport/frame.cc @@ -40,6 +40,7 @@ constexpr uint8_t kFrameTypeSettings = 4; constexpr uint8_t kFrameTypePing = 6; constexpr uint8_t kFrameTypeGoaway = 7; constexpr uint8_t kFrameTypeWindowUpdate = 8; +constexpr uint8_t kFrameTypePushPromise = 5; constexpr uint8_t kFlagEndStream = 1; constexpr uint8_t kFlagAck = 1; @@ -175,6 +176,7 @@ class SerializeHeaderAndPayload { } void operator()(Http2SettingsFrame& frame) { + // Six bytes per setting (u16 id, u32 value) const size_t payload_size = 6 * frame.settings.size(); auto hdr_and_payload = extra_bytes_.TakeFirst(kFrameHeaderSize + payload_size); @@ -463,7 +465,7 @@ void Serialize(absl::Span frames, SliceBuffer& out) { for (auto& frame : frames) { // Bytes needed for framing buffer_needed += kFrameHeaderSize; - // Bytes needed for unserialized payload + // Bytes needed for frame payload buffer_needed += absl::visit(SerializeExtraBytesRequired(), frame); } SerializeHeaderAndPayload serialize(buffer_needed, out); @@ -492,6 +494,10 @@ absl::StatusOr ParseFramePayload(const Http2FrameHeader& hdr, return ParseGoawayFrame(hdr, payload); case kFrameTypeWindowUpdate: return ParseWindowUpdateFrame(hdr, payload); + case kFrameTypePushPromise: + return absl::InternalError( + "push promise not supported (and SETTINGS_ENABLE_PUSH explicitly " + "disabled)."); default: return Http2UnknownFrame{}; } diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 4d1f44f1f656e..e7248696c10ee 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -305,6 +305,13 @@ struct GrpcTagsBinMetadata : public SimpleSliceBasedMetadata { static absl::string_view key() { return "grpc-tags-bin"; } }; +// XEnvoyPeerMetadata +struct XEnvoyPeerMetadata : public SimpleSliceBasedMetadata { + static constexpr bool kRepeatable = false; + using CompressionTraits = StableValueCompressor; + static absl::string_view key() { return "x-envoy-peer-metadata"; } +}; + // :authority metadata trait. struct HttpAuthorityMetadata : public SimpleSliceBasedMetadata { static constexpr bool kRepeatable = false; @@ -1474,6 +1481,7 @@ using grpc_metadata_batch_base = grpc_core::MetadataMap< grpc_core::GrpcServerStatsBinMetadata, grpc_core::GrpcTraceBinMetadata, grpc_core::GrpcTagsBinMetadata, grpc_core::GrpcLbClientStatsMetadata, grpc_core::LbCostBinMetadata, grpc_core::LbTokenMetadata, + grpc_core::XEnvoyPeerMetadata, // Non-encodable things grpc_core::GrpcStreamNetworkState, grpc_core::PeerString, grpc_core::GrpcStatusContext, grpc_core::GrpcStatusFromWire, diff --git a/src/cpp/ext/gsm/BUILD b/src/cpp/ext/gsm/BUILD index 658c7cebc88e4..33f07f3b48c7d 100644 --- a/src/cpp/ext/gsm/BUILD +++ b/src/cpp/ext/gsm/BUILD @@ -32,21 +32,32 @@ grpc_cc_library( name = "gsm_observability", srcs = [ "gsm_observability.cc", + "metadata_exchange.cc", ], hdrs = [ "gsm_observability.h", + "metadata_exchange.h", ], external_deps = [ "absl/container:flat_hash_set", + "absl/meta:type_traits", "absl/status", "absl/status:statusor", "absl/strings", + "absl/types:optional", + "absl/types:variant", "otel/sdk/src/metrics", + "otel/sdk:headers", + "upb_lib", ], language = "c++", visibility = ["//:__subpackages__"], deps = [ "//:gpr_platform", + "//:grpc_base", + "//:protobuf_struct_upb", + "//src/core:env", + "//src/core:slice", "//src/cpp/ext/otel:otel_plugin", ], ) diff --git a/src/cpp/ext/gsm/metadata_exchange.cc b/src/cpp/ext/gsm/metadata_exchange.cc new file mode 100644 index 0000000000000..890b3ae5e7fdb --- /dev/null +++ b/src/cpp/ext/gsm/metadata_exchange.cc @@ -0,0 +1,344 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 + +#include "src/cpp/ext/gsm/metadata_exchange.h" + +#include + +#include +#include +#include + +#include "absl/meta/type_traits.h" +#include "absl/strings/escaping.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "absl/types/variant.h" +#include "google/protobuf/struct.upb.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "upb/base/string_view.h" +#include "upb/mem/arena.h" +#include "upb/upb.hpp" + +#include "src/core/lib/gprpp/env.h" + +namespace grpc { +namespace internal { + +namespace { + +// The keys that will be used in the Metadata Exchange between local and remote. +constexpr absl::string_view kMetadataExchangeTypeKey = "type"; +constexpr absl::string_view kMetadataExchangePodNameKey = "pod_name"; +constexpr absl::string_view kMetadataExchangeContainerNameKey = + "container_name"; +constexpr absl::string_view kMetadataExchangeNamespaceNameKey = + "namespace_name"; +constexpr absl::string_view kMetadataExchangeClusterNameKey = "cluster_name"; +constexpr absl::string_view kMetadataExchangeLocationKey = "location"; +constexpr absl::string_view kMetadataExchangeProjectIdKey = "project_id"; +constexpr absl::string_view kMetadataExchangeCanonicalServiceKey = + "canonical_service"; +// The keys that will be used for the peer attributes when recording metrics. +constexpr absl::string_view kPeerTypeAttribute = "gsm.remote_workload_type"; +constexpr absl::string_view kPeerPodNameAttribute = + "gsm.remote_workload_pod_name"; +constexpr absl::string_view kPeerContainerNameAttribute = + "gsm.remote_workload_container_name"; +constexpr absl::string_view kPeerNamespaceNameAttribute = + "gsm.remote_workload_namespace_name"; +constexpr absl::string_view kPeerClusterNameAttribute = + "gsm.remote_workload_cluster_name"; +constexpr absl::string_view kPeerLocationAttribute = + "gsm.remote_workload_location"; +constexpr absl::string_view kPeerProjectIdAttribute = + "gsm.remote_workload_project_id"; +constexpr absl::string_view kPeerCanonicalServiceAttribute = + "gsm.remote_workload_canonical_service"; +// Type values used by Google Cloud Resource Detector +constexpr absl::string_view kGkeType = "gcp_kubernetes_engine"; + +enum class GcpResourceType : std::uint8_t { kGke, kUnknown }; + +GcpResourceType StringToGcpResourceType(absl::string_view type) { + if (type == kGkeType) { + return GcpResourceType::kGke; + } + return GcpResourceType::kUnknown; +} + +upb_StringView AbslStrToUpbStr(absl::string_view str) { + return upb_StringView_FromDataAndSize(str.data(), str.size()); +} + +absl::string_view UpbStrToAbslStr(upb_StringView str) { + return absl::string_view(str.data, str.size); +} + +void AddStringKeyValueToStructProto(google_protobuf_Struct* struct_pb, + absl::string_view key, + absl::string_view value, upb_Arena* arena) { + google_protobuf_Value* value_pb = google_protobuf_Value_new(arena); + google_protobuf_Value_set_string_value(value_pb, AbslStrToUpbStr(value)); + google_protobuf_Struct_fields_set(struct_pb, AbslStrToUpbStr(key), value_pb, + arena); +} + +absl::string_view GetStringValueFromAttributeMap( + const opentelemetry::sdk::common::AttributeMap& map, + absl::string_view key) { + const auto& attributes = map.GetAttributes(); + const auto it = attributes.find(std::string(key)); + if (it == attributes.end()) { + return "unknown"; + } + const auto* string_value = absl::get_if(&it->second); + if (string_value == nullptr) { + return "unknown"; + } + return *string_value; +} + +absl::string_view GetStringValueFromUpbStruct(google_protobuf_Struct* struct_pb, + absl::string_view key, + upb_Arena* arena) { + if (struct_pb == nullptr) { + return "unknown"; + } + google_protobuf_Value* value_pb = google_protobuf_Value_new(arena); + bool present = google_protobuf_Struct_fields_get( + struct_pb, AbslStrToUpbStr(key), &value_pb); + if (present) { + if (google_protobuf_Value_has_string_value(value_pb)) { + return UpbStrToAbslStr(google_protobuf_Value_string_value(value_pb)); + } + } + return "unknown"; +} + +class LocalLabelsIterable : public LabelsIterable { + public: + explicit LocalLabelsIterable( + const std::vector>& labels) + : labels_(labels) {} + + absl::optional> Next() + override { + if (pos_ >= labels_.size()) { + return absl::nullopt; + } + return labels_[pos_++]; + } + + size_t Size() const override { return labels_.size(); } + + void ResetIteratorPosition() override { pos_ = 0; } + + private: + size_t pos_ = 0; + const std::vector>& labels_; +}; + +class PeerLabelsIterable : public LabelsIterable { + public: + explicit PeerLabelsIterable(grpc_core::Slice remote_metadata) + : metadata_(std::move(remote_metadata)) {} + + absl::optional> Next() + override { + auto& struct_pb = GetDecodedMetadata(); + if (struct_pb.struct_pb == nullptr) { + return absl::nullopt; + } + if (++pos_ == 1) { + return std::make_pair(kPeerTypeAttribute, + GetStringValueFromUpbStruct( + struct_pb.struct_pb, kMetadataExchangeTypeKey, + struct_pb.arena.ptr())); + } + // Only handle GKE type for now. + switch (type_) { + case GcpResourceType::kGke: + if (pos_ - 2 >= kGkeAttributeList.size()) { + return absl::nullopt; + } + return std::make_pair( + kGkeAttributeList[pos_ - 2].otel_attribute, + GetStringValueFromUpbStruct( + struct_pb.struct_pb, + kGkeAttributeList[pos_ - 2].metadata_attribute, + struct_pb.arena.ptr())); + case GcpResourceType::kUnknown: + return absl::nullopt; + } + } + + size_t Size() const override { + auto& struct_pb = GetDecodedMetadata(); + if (struct_pb.struct_pb == nullptr) { + return 0; + } + if (type_ != GcpResourceType::kGke) { + return 1; + } + return kGkeAttributeList.size(); + } + + void ResetIteratorPosition() override { pos_ = 0; } + + private: + struct GkeAttribute { + absl::string_view otel_attribute; + absl::string_view metadata_attribute; + }; + + struct StructPb { + upb::Arena arena; + google_protobuf_Struct* struct_pb = nullptr; + }; + + static constexpr std::array kGkeAttributeList = { + GkeAttribute{kPeerPodNameAttribute, kMetadataExchangePodNameKey}, + GkeAttribute{kPeerContainerNameAttribute, + kMetadataExchangeContainerNameKey}, + GkeAttribute{kPeerNamespaceNameAttribute, + kMetadataExchangeNamespaceNameKey}, + GkeAttribute{kPeerClusterNameAttribute, kMetadataExchangeClusterNameKey}, + GkeAttribute{kPeerLocationAttribute, kMetadataExchangeLocationKey}, + GkeAttribute{kPeerProjectIdAttribute, kMetadataExchangeProjectIdKey}, + GkeAttribute{kPeerCanonicalServiceAttribute, + kMetadataExchangeCanonicalServiceKey}, + }; + + StructPb& GetDecodedMetadata() const { + auto* slice = absl::get_if(&metadata_); + if (slice == nullptr) { + return absl::get(metadata_); + } + std::string decoded_metadata; + bool metadata_decoded = + absl::Base64Unescape(slice->as_string_view(), &decoded_metadata); + metadata_ = StructPb{}; + auto& struct_pb = absl::get(metadata_); + if (metadata_decoded) { + struct_pb.struct_pb = google_protobuf_Struct_parse( + decoded_metadata.c_str(), decoded_metadata.size(), + struct_pb.arena.ptr()); + type_ = StringToGcpResourceType(GetStringValueFromUpbStruct( + struct_pb.struct_pb, kMetadataExchangeTypeKey, + struct_pb.arena.ptr())); + } + return struct_pb; + } + + // Holds either the metadata slice or the decoded proto struct. + mutable absl::variant metadata_; + mutable GcpResourceType type_; + uint32_t pos_ = 0; +}; + +constexpr std::array + PeerLabelsIterable::kGkeAttributeList; + +} // namespace + +ServiceMeshLabelsInjector::ServiceMeshLabelsInjector( + const opentelemetry::sdk::common::AttributeMap& map) { + upb::Arena arena; + auto* metadata = google_protobuf_Struct_new(arena.ptr()); + // Assume kubernetes for now + absl::string_view type_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions::kCloudPlatform); + absl::string_view pod_name_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions::kK8sPodName); + absl::string_view container_name_value = GetStringValueFromAttributeMap( + map, + opentelemetry::sdk::resource::SemanticConventions::kK8sContainerName); + absl::string_view namespace_value = GetStringValueFromAttributeMap( + map, + opentelemetry::sdk::resource::SemanticConventions::kK8sNamespaceName); + absl::string_view cluster_name_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions::kK8sClusterName); + absl::string_view cluster_location_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions:: + kCloudRegion); // if regional + if (cluster_location_value == "unknown") { + cluster_location_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions:: + kCloudAvailabilityZone); // if zonal + } + absl::string_view project_id_value = GetStringValueFromAttributeMap( + map, opentelemetry::sdk::resource::SemanticConventions::kCloudAccountId); + std::string canonical_service_value = + grpc_core::GetEnv("GSM_CANONICAL_SERVICE_NAME").value_or("unknown"); + // Create metadata to be sent over wire. + AddStringKeyValueToStructProto(metadata, kMetadataExchangeTypeKey, type_value, + arena.ptr()); + // Only handle GKE for now + if (type_value == kGkeType) { + AddStringKeyValueToStructProto(metadata, kMetadataExchangePodNameKey, + pod_name_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, kMetadataExchangeContainerNameKey, + container_name_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, kMetadataExchangeNamespaceNameKey, + namespace_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, kMetadataExchangeClusterNameKey, + cluster_name_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, kMetadataExchangeLocationKey, + cluster_location_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, kMetadataExchangeProjectIdKey, + project_id_value, arena.ptr()); + AddStringKeyValueToStructProto(metadata, + kMetadataExchangeCanonicalServiceKey, + canonical_service_value, arena.ptr()); + } + + size_t output_length; + char* output = + google_protobuf_Struct_serialize(metadata, arena.ptr(), &output_length); + serialized_labels_to_send_ = grpc_core::Slice::FromCopiedString( + absl::Base64Escape(absl::string_view(output, output_length))); + // Fill up local labels map. The rest we get from the detected Resource and + // from the peer. + // TODO(yashykt): Add mesh_id +} + +std::unique_ptr ServiceMeshLabelsInjector::GetPeerLabels( + grpc_metadata_batch* incoming_initial_metadata) { + auto peer_metadata = + incoming_initial_metadata->Take(grpc_core::XEnvoyPeerMetadata()); + if (!peer_metadata.has_value()) { + return nullptr; + } + return std::make_unique(*std::move(peer_metadata)); +} + +std::unique_ptr ServiceMeshLabelsInjector::GetLocalLabels() { + return std::make_unique(local_labels_); +} + +void ServiceMeshLabelsInjector::AddLabels( + grpc_metadata_batch* outgoing_initial_metadata) { + outgoing_initial_metadata->Set(grpc_core::XEnvoyPeerMetadata(), + serialized_labels_to_send_.Ref()); +} + +} // namespace internal +} // namespace grpc diff --git a/src/cpp/ext/gsm/metadata_exchange.h b/src/cpp/ext/gsm/metadata_exchange.h new file mode 100644 index 0000000000000..fc19d151ae2c5 --- /dev/null +++ b/src/cpp/ext/gsm/metadata_exchange.h @@ -0,0 +1,64 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 GRPC_SRC_CPP_EXT_GSM_METADATA_EXCHANGE_H +#define GRPC_SRC_CPP_EXT_GSM_METADATA_EXCHANGE_H + +#include + +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" + +#include "src/core/lib/slice/slice.h" +#include "src/core/lib/transport/metadata_batch.h" +#include "src/cpp/ext/otel/otel_plugin.h" + +namespace grpc { +namespace internal { + +class ServiceMeshLabelsInjector : public LabelsInjector { + public: + explicit ServiceMeshLabelsInjector( + const opentelemetry::sdk::common::AttributeMap& map); + // Read the incoming initial metadata to get the set of labels to be added to + // metrics. + std::unique_ptr GetPeerLabels( + grpc_metadata_batch* incoming_initial_metadata) override; + + // Get the local labels to be added to metrics. To be used when the peer + // metadata is not available, for example, for started RPCs metric. + std::unique_ptr GetLocalLabels() override; + + // Modify the outgoing initial metadata with metadata information to be sent + // to the peer. + void AddLabels(grpc_metadata_batch* outgoing_initial_metadata) override; + + private: + std::vector> local_labels_; + grpc_core::Slice serialized_labels_to_send_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPC_SRC_CPP_EXT_GSM_METADATA_EXCHANGE_H diff --git a/src/cpp/ext/otel/BUILD b/src/cpp/ext/otel/BUILD index d9fd4635bf114..60d66cba4e56e 100644 --- a/src/cpp/ext/otel/BUILD +++ b/src/cpp/ext/otel/BUILD @@ -36,6 +36,7 @@ grpc_cc_library( "otel_server_call_tracer.cc", ], hdrs = [ + "key_value_iterable.h", "otel_call_tracer.h", "otel_client_filter.h", "otel_plugin.h", @@ -44,13 +45,13 @@ grpc_cc_library( external_deps = [ "absl/base:core_headers", "absl/container:flat_hash_set", - "absl/container:inlined_vector", "absl/status", "absl/status:statusor", "absl/strings", "absl/strings:str_format", "absl/time", "absl/types:optional", + "absl/types:span", "otel/api", ], language = "c++", @@ -62,6 +63,7 @@ grpc_cc_library( "//:gpr_platform", "//:grpc_base", "//:grpc_client_channel", + "//:grpc_public_hdrs", "//:legacy_context", "//src/core:arena", "//src/core:arena_promise", diff --git a/src/cpp/ext/otel/key_value_iterable.h b/src/cpp/ext/otel/key_value_iterable.h new file mode 100644 index 0000000000000..a76c6c9edcd48 --- /dev/null +++ b/src/cpp/ext/otel/key_value_iterable.h @@ -0,0 +1,109 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 GRPC_SRC_CPP_EXT_OTEL_KEY_VALUE_ITERABLE_H +#define GRPC_SRC_CPP_EXT_OTEL_KEY_VALUE_ITERABLE_H + +#include + +#include + +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "absl/types/span.h" +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/string_view.h" + +#include "src/cpp/ext/otel/otel_plugin.h" + +namespace grpc { +namespace internal { + +inline opentelemetry::nostd::string_view AbslStrViewToOTelStrView( + absl::string_view str) { + return opentelemetry::nostd::string_view(str.data(), str.size()); +} + +// An iterable class based on opentelemetry::common::KeyValueIterable that +// allows gRPC to iterate on its various sources of attributes and avoid an +// allocation in cases wherever possible. +class KeyValueIterable : public opentelemetry::common::KeyValueIterable { + public: + explicit KeyValueIterable( + LabelsIterable* local_labels_iterable, + LabelsIterable* peer_labels_iterable, + absl::Span> + additional_labels) + : local_labels_iterable_(local_labels_iterable), + peer_labels_iterable_(peer_labels_iterable), + additional_labels_(additional_labels) {} + + bool ForEachKeyValue(opentelemetry::nostd::function_ref< + bool(opentelemetry::nostd::string_view, + opentelemetry::common::AttributeValue)> + callback) const noexcept override { + if (local_labels_iterable_ != nullptr) { + local_labels_iterable_->ResetIteratorPosition(); + while (const auto& pair = local_labels_iterable_->Next()) { + if (!callback(AbslStrViewToOTelStrView(pair->first), + AbslStrViewToOTelStrView(pair->second))) { + return false; + } + } + } + if (peer_labels_iterable_ != nullptr) { + peer_labels_iterable_->ResetIteratorPosition(); + while (const auto& pair = peer_labels_iterable_->Next()) { + if (!callback(AbslStrViewToOTelStrView(pair->first), + AbslStrViewToOTelStrView(pair->second))) { + return false; + } + } + } + for (const auto& pair : additional_labels_) { + if (!callback(AbslStrViewToOTelStrView(pair.first), + AbslStrViewToOTelStrView(pair.second))) { + return false; + } + } + return true; + } + + size_t size() const noexcept override { + return (local_labels_iterable_ != nullptr ? local_labels_iterable_->Size() + : 0) + + (peer_labels_iterable_ != nullptr ? peer_labels_iterable_->Size() + : 0) + + additional_labels_.size(); + } + + private: + LabelsIterable* local_labels_iterable_; + LabelsIterable* peer_labels_iterable_; + absl::Span> + additional_labels_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPC_SRC_CPP_EXT_OTEL_KEY_VALUE_ITERABLE_H diff --git a/src/cpp/ext/otel/otel_call_tracer.h b/src/cpp/ext/otel/otel_call_tracer.h index eb0e05352c118..37f5445c035cb 100644 --- a/src/cpp/ext/otel/otel_call_tracer.h +++ b/src/cpp/ext/otel/otel_call_tracer.h @@ -23,6 +23,7 @@ #include +#include #include #include "absl/base/thread_annotations.h" @@ -41,6 +42,7 @@ #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" #include "src/cpp/ext/otel/otel_client_filter.h" +#include "src/cpp/ext/otel/otel_plugin.h" namespace grpc { namespace internal { @@ -68,14 +70,14 @@ class OpenTelemetryCallTracer : public grpc_core::ClientCallTracer { } void RecordSendInitialMetadata( - grpc_metadata_batch* /*send_initial_metadata*/) override {} + grpc_metadata_batch* send_initial_metadata) override; void RecordSendTrailingMetadata( grpc_metadata_batch* /*send_trailing_metadata*/) override {} void RecordSendMessage(const grpc_core::SliceBuffer& send_message) override; void RecordSendCompressedMessage( const grpc_core::SliceBuffer& send_compressed_message) override; void RecordReceivedInitialMetadata( - grpc_metadata_batch* /*recv_initial_metadata*/) override {} + grpc_metadata_batch* recv_initial_metadata) override; void RecordReceivedMessage( const grpc_core::SliceBuffer& recv_message) override; void RecordReceivedDecompressedMessage( @@ -93,6 +95,8 @@ class OpenTelemetryCallTracer : public grpc_core::ClientCallTracer { const bool arena_allocated_; // Start time (for measuring latency). absl::Time start_time_; + std::unique_ptr local_labels_; + std::unique_ptr peer_labels_; }; explicit OpenTelemetryCallTracer(OpenTelemetryClientFilter* parent, @@ -124,7 +128,6 @@ class OpenTelemetryCallTracer : public grpc_core::ClientCallTracer { const OpenTelemetryClientFilter* parent_; // Client method. grpc_core::Slice path_; - absl::string_view method_; grpc_core::Arena* arena_; grpc_core::Mutex mu_; // Non-transparent attempts per call diff --git a/src/cpp/ext/otel/otel_client_filter.cc b/src/cpp/ext/otel/otel_client_filter.cc index 42806dd5ad45e..13a6fce399cda 100644 --- a/src/cpp/ext/otel/otel_client_filter.cc +++ b/src/cpp/ext/otel/otel_client_filter.cc @@ -20,13 +20,13 @@ #include "src/cpp/ext/otel/otel_client_filter.h" +#include #include #include #include #include #include -#include "absl/container/inlined_vector.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" @@ -34,21 +34,25 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "absl/types/optional.h" +#include "absl/types/span.h" #include "opentelemetry/context/context.h" #include "opentelemetry/metrics/sync_instruments.h" +#include #include #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/context.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/promise/context.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/metadata_batch.h" +#include "src/cpp/ext/otel/key_value_iterable.h" #include "src/cpp/ext/otel/otel_call_tracer.h" #include "src/cpp/ext/otel/otel_plugin.h" @@ -100,11 +104,34 @@ OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: : parent_(parent), arena_allocated_(arena_allocated), start_time_(absl::Now()) { - // TODO(yashykt): Figure out how to get this to work with absl::string_view + // We don't have the peer labels at this point. + if (OTelPluginState().labels_injector != nullptr) { + local_labels_ = OTelPluginState().labels_injector->GetLocalLabels(); + } if (OTelPluginState().client.attempt.started != nullptr) { - OTelPluginState().client.attempt.started->Add( - 1, {{std::string(OTelMethodKey()), std::string(parent_->method_)}, - {std::string(OTelTargetKey()), parent_->parent_->target()}}); + std::array, 2> + additional_labels = { + {{OTelMethodKey(), + absl::StripPrefix(parent_->path_.as_string_view(), "/")}, + {OTelTargetKey(), parent_->parent_->target()}}}; + KeyValueIterable labels(local_labels_.get(), peer_labels_.get(), + additional_labels); + OTelPluginState().client.attempt.started->Add(1, labels); + } +} + +void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: + RecordReceivedInitialMetadata(grpc_metadata_batch* recv_initial_metadata) { + if (OTelPluginState().labels_injector != nullptr) { + peer_labels_ = + OTelPluginState().labels_injector->GetPeerLabels(recv_initial_metadata); + } +} + +void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: + RecordSendInitialMetadata(grpc_metadata_batch* send_initial_metadata) { + if (OTelPluginState().labels_injector != nullptr) { + OTelPluginState().labels_injector->AddLabels(send_initial_metadata); } } @@ -138,13 +165,19 @@ void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: RecordReceivedTrailingMetadata( absl::Status status, grpc_metadata_batch* /*recv_trailing_metadata*/, const grpc_transport_stream_stats* transport_stream_stats) { - absl::InlinedVector, 2> attributes = { - {std::string(OTelMethodKey()), std::string(parent_->method_)}, - {std::string(OTelStatusKey()), absl::StatusCodeToString(status.code())}, - {std::string(OTelTargetKey()), parent_->parent_->target()}}; + std::array, 3> + additional_labels = { + {{OTelMethodKey(), + absl::StripPrefix(parent_->path_.as_string_view(), "/")}, + {OTelTargetKey(), parent_->parent_->target()}, + {OTelStatusKey(), + grpc_status_code_to_string( + static_cast(status.code()))}}}; + KeyValueIterable labels(local_labels_.get(), peer_labels_.get(), + additional_labels); if (OTelPluginState().client.attempt.duration != nullptr) { OTelPluginState().client.attempt.duration->Record( - absl::ToDoubleSeconds(absl::Now() - start_time_), attributes, + absl::ToDoubleSeconds(absl::Now() - start_time_), labels, opentelemetry::context::Context{}); } if (OTelPluginState().client.attempt.sent_total_compressed_message_size != @@ -153,7 +186,7 @@ void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: transport_stream_stats != nullptr ? transport_stream_stats->outgoing.data_bytes : 0, - attributes, opentelemetry::context::Context{}); + labels, opentelemetry::context::Context{}); } if (OTelPluginState().client.attempt.rcvd_total_compressed_message_size != nullptr) { @@ -161,7 +194,7 @@ void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer:: transport_stream_stats != nullptr ? transport_stream_stats->incoming.data_bytes : 0, - attributes, opentelemetry::context::Context{}); + labels, opentelemetry::context::Context{}); } } @@ -194,10 +227,7 @@ void OpenTelemetryCallTracer::OpenTelemetryCallAttemptTracer::RecordAnnotation( OpenTelemetryCallTracer::OpenTelemetryCallTracer( OpenTelemetryClientFilter* parent, grpc_core::Slice path, grpc_core::Arena* arena) - : parent_(parent), - path_(std::move(path)), - method_(absl::StripPrefix(path_.as_string_view(), "/")), - arena_(arena) {} + : parent_(parent), path_(std::move(path)), arena_(arena) {} OpenTelemetryCallTracer::~OpenTelemetryCallTracer() {} diff --git a/src/cpp/ext/otel/otel_client_filter.h b/src/cpp/ext/otel/otel_client_filter.h index dbafb322ca0f2..9205da43511c1 100644 --- a/src/cpp/ext/otel/otel_client_filter.h +++ b/src/cpp/ext/otel/otel_client_filter.h @@ -25,6 +25,7 @@ #include #include "absl/status/statusor.h" +#include "absl/strings/string_view.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" @@ -47,7 +48,7 @@ class OpenTelemetryClientFilter : public grpc_core::ChannelFilter { grpc_core::CallArgs call_args, grpc_core::NextPromiseFactory next_promise_factory) override; - const std::string& target() const { return target_; } + absl::string_view target() const { return target_; } private: explicit OpenTelemetryClientFilter(std::string target) diff --git a/src/cpp/ext/otel/otel_plugin.cc b/src/cpp/ext/otel/otel_plugin.cc index bb805e9341717..01ce8a58ed006 100644 --- a/src/cpp/ext/otel/otel_plugin.cc +++ b/src/cpp/ext/otel/otel_plugin.cc @@ -114,6 +114,12 @@ OpenTelemetryPluginBuilder& OpenTelemetryPluginBuilder::DisableMetrics( return *this; } +OpenTelemetryPluginBuilder& OpenTelemetryPluginBuilder::SetLabelsInjector( + std::unique_ptr labels_injector) { + labels_injector_ = std::move(labels_injector); + return *this; +} + void OpenTelemetryPluginBuilder::BuildAndRegisterGlobal() { opentelemetry::nostd::shared_ptr meter_provider = meter_provider_; @@ -164,6 +170,7 @@ void OpenTelemetryPluginBuilder::BuildAndRegisterGlobal() { meter->CreateUInt64Histogram(std::string( OTelServerCallRcvdTotalCompressedMessageSizeInstrumentName())); } + g_otel_plugin_state_->labels_injector = std::move(labels_injector_); g_otel_plugin_state_->meter_provider = std::move(meter_provider); grpc_core::ServerCallTracerFactory::RegisterGlobal( new grpc::internal::OpenTelemetryServerCallTracerFactory); diff --git a/src/cpp/ext/otel/otel_plugin.h b/src/cpp/ext/otel/otel_plugin.h index b0cd5a4c7a896..36344563f0c48 100644 --- a/src/cpp/ext/otel/otel_plugin.h +++ b/src/cpp/ext/otel/otel_plugin.h @@ -21,20 +21,64 @@ #include +#include #include #include #include +#include #include "absl/container/flat_hash_set.h" #include "absl/strings/string_view.h" +#include "absl/types/optional.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "src/core/lib/transport/metadata_batch.h" + namespace grpc { namespace internal { +// An iterable container interface that can be used as a return type for the +// OTel plugin's label injector. +class LabelsIterable { + public: + virtual ~LabelsIterable() = default; + + // Returns the key-value label at the current position or absl::nullopt if the + // iterator has reached the end. + virtual absl::optional> + Next() = 0; + + virtual size_t Size() const = 0; + + // Resets position of iterator to the start. + virtual void ResetIteratorPosition() = 0; +}; + +// An interface that allows you to add additional labels on the calls traced +// through the OTel plugin. +class LabelsInjector { + public: + virtual ~LabelsInjector() {} + // Read the incoming initial metadata to get the set of labels to be added to + // metrics. (Does not include the local labels.) + virtual std::unique_ptr GetPeerLabels( + grpc_metadata_batch* incoming_initial_metadata) = 0; + + // Get the local labels to be added to metrics. To be used when the peer + // metadata is not available, for example, for started RPCs metric. + // It is the responsibility of the implementation to make sure that the + // backing store for the absl::string_view remains valid for the lifetime of + // gRPC. + virtual std::unique_ptr GetLocalLabels() = 0; + + // Modify the outgoing initial metadata with metadata information to be sent + // to the peer. + virtual void AddLabels(grpc_metadata_batch* outgoing_initial_metadata) = 0; +}; + struct OTelPluginState { struct Client { struct Attempt { @@ -58,6 +102,7 @@ struct OTelPluginState { } server; opentelemetry::nostd::shared_ptr meter_provider; + std::unique_ptr labels_injector; }; const struct OTelPluginState& OTelPluginState(); @@ -90,6 +135,10 @@ class OpenTelemetryPluginBuilder { OpenTelemetryPluginBuilder& DisableMetrics( const absl::flat_hash_set& metric_names); // Builds and registers the OTel Plugin + + OpenTelemetryPluginBuilder& SetLabelsInjector( + std::unique_ptr labels_injector); + void BuildAndRegisterGlobal(); // The base set of metrics - @@ -105,6 +154,7 @@ class OpenTelemetryPluginBuilder { private: std::shared_ptr meter_provider_; + std::unique_ptr labels_injector_; absl::flat_hash_set metrics_; }; diff --git a/src/cpp/ext/otel/otel_server_call_tracer.cc b/src/cpp/ext/otel/otel_server_call_tracer.cc index aa7c45d362f31..652c9bf6f011d 100644 --- a/src/cpp/ext/otel/otel_server_call_tracer.cc +++ b/src/cpp/ext/otel/otel_server_call_tracer.cc @@ -20,27 +20,29 @@ #include "src/cpp/ext/otel/otel_server_call_tracer.h" +#include #include #include #include #include -#include "absl/container/inlined_vector.h" -#include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/time/clock.h" #include "absl/time/time.h" +#include "absl/types/span.h" #include "opentelemetry/context/context.h" #include "opentelemetry/metrics/sync_instruments.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +#include "src/cpp/ext/otel/key_value_iterable.h" #include "src/cpp/ext/otel/otel_plugin.h" namespace grpc { @@ -52,7 +54,12 @@ namespace { class OpenTelemetryServerCallTracer : public grpc_core::ServerCallTracer { public: - OpenTelemetryServerCallTracer() : start_time_(absl::Now()) {} + OpenTelemetryServerCallTracer() : start_time_(absl::Now()) { + // We don't have the peer labels at this point. + if (OTelPluginState().labels_injector != nullptr) { + local_labels_ = OTelPluginState().labels_injector->GetLocalLabels(); + } + } std::string TraceId() override { // Not implemented @@ -72,7 +79,13 @@ class OpenTelemetryServerCallTracer : public grpc_core::ServerCallTracer { // Please refer to `grpc_transport_stream_op_batch_payload` for details on // arguments. void RecordSendInitialMetadata( - grpc_metadata_batch* /*send_initial_metadata*/) override {} + grpc_metadata_batch* send_initial_metadata) override { + // Only add labels to outgoing metadata if labels were received from peer. + if (OTelPluginState().labels_injector != nullptr && + peer_labels_ != nullptr) { + OTelPluginState().labels_injector->AddLabels(send_initial_metadata); + } + } void RecordSendTrailingMetadata( grpc_metadata_batch* /*send_trailing_metadata*/) override; @@ -119,34 +132,28 @@ class OpenTelemetryServerCallTracer : public grpc_core::ServerCallTracer { } private: - grpc_core::Slice path_; - absl::string_view method_; - std::string authority_; absl::Time start_time_; absl::Duration elapsed_time_; + grpc_core::Slice path_; + std::unique_ptr local_labels_; + std::unique_ptr peer_labels_; }; void OpenTelemetryServerCallTracer::RecordReceivedInitialMetadata( grpc_metadata_batch* recv_initial_metadata) { - const auto* path = - recv_initial_metadata->get_pointer(grpc_core::HttpPathMetadata()); - if (path != nullptr) { - path_ = path->Ref(); - } - method_ = absl::StripPrefix(path_.as_string_view(), "/"); - const auto* authority = - recv_initial_metadata->get_pointer(grpc_core::HttpAuthorityMetadata()); - // Override with host metadata if authority is absent. - if (authority == nullptr) { - authority = recv_initial_metadata->get_pointer(grpc_core::HostMetadata()); - } - if (authority != nullptr) { - authority_ = std::string(authority->as_string_view()); - } - // TODO(yashykt): Figure out how to get this to work with absl::string_view + path_ = + recv_initial_metadata->get_pointer(grpc_core::HttpPathMetadata())->Ref(); + if (OTelPluginState().labels_injector != nullptr) { + peer_labels_ = + OTelPluginState().labels_injector->GetPeerLabels(recv_initial_metadata); + } + std::array, 1> + additional_labels = { + {{OTelMethodKey(), absl::StripPrefix(path_.as_string_view(), "/")}}}; if (OTelPluginState().server.call.started != nullptr) { OTelPluginState().server.call.started->Add( - 1, {{std::string(OTelMethodKey()), std::string(method_)}}); + 1, KeyValueIterable(local_labels_.get(), peer_labels_.get(), + additional_labels)); } } @@ -159,27 +166,29 @@ void OpenTelemetryServerCallTracer::RecordSendTrailingMetadata( void OpenTelemetryServerCallTracer::RecordEnd( const grpc_call_final_info* final_info) { - absl::InlinedVector, 2> attributes = { - {std::string(OTelMethodKey()), std::string(method_)}, - {std::string(OTelStatusKey()), - absl::StatusCodeToString( - static_cast(final_info->final_status))}}; + std::array, 2> + additional_labels = { + {{OTelMethodKey(), absl::StripPrefix(path_.as_string_view(), "/")}, + {OTelStatusKey(), + grpc_status_code_to_string(final_info->final_status)}}}; + KeyValueIterable labels(local_labels_.get(), peer_labels_.get(), + additional_labels); if (OTelPluginState().server.call.duration != nullptr) { OTelPluginState().server.call.duration->Record( - absl::ToDoubleSeconds(elapsed_time_), attributes, + absl::ToDoubleSeconds(elapsed_time_), labels, opentelemetry::context::Context{}); } if (OTelPluginState().server.call.sent_total_compressed_message_size != nullptr) { OTelPluginState().server.call.sent_total_compressed_message_size->Record( - final_info->stats.transport_stream_stats.outgoing.data_bytes, - attributes, opentelemetry::context::Context{}); + final_info->stats.transport_stream_stats.outgoing.data_bytes, labels, + opentelemetry::context::Context{}); } if (OTelPluginState().server.call.rcvd_total_compressed_message_size != nullptr) { OTelPluginState().server.call.rcvd_total_compressed_message_size->Record( - final_info->stats.transport_stream_stats.incoming.data_bytes, - attributes, opentelemetry::context::Context{}); + final_info->stats.transport_stream_stats.incoming.data_bytes, labels, + opentelemetry::context::Context{}); } } diff --git a/test/core/client_channel/lb_policy/xds_override_host_test.cc b/test/core/client_channel/lb_policy/xds_override_host_test.cc index 26cfc7a60d49a..1395542026ed4 100644 --- a/test/core/client_channel/lb_policy/xds_override_host_test.cc +++ b/test/core/client_channel/lb_policy/xds_override_host_test.cc @@ -29,6 +29,7 @@ #include #include +#include #include "src/core/ext/filters/stateful_session/stateful_session_filter.h" #include "src/core/ext/xds/xds_health_status.h" @@ -209,18 +210,31 @@ TEST_F(XdsOverrideHostTest, FailedSubchannelIsNotPicked) { EXPECT_EQ(ExpectPickComplete(picker.get(), MakeOverrideHostAttribute(kAddresses[1])), kAddresses[1]); + // Subchannel for address 1 becomes disconnected. + gpr_log(GPR_INFO, "### subchannel 1 reporting IDLE"); auto subchannel = FindSubchannel(kAddresses[1]); ASSERT_NE(subchannel, nullptr); subchannel->SetConnectivityState(GRPC_CHANNEL_IDLE); + gpr_log(GPR_INFO, "### expecting re-resolution request"); ExpectReresolutionRequest(); + gpr_log(GPR_INFO, + "### expecting RR picks to exclude the disconnected subchannel"); ExpectRoundRobinPicks(ExpectState(GRPC_CHANNEL_READY).get(), {kAddresses[0], kAddresses[2]}); + // It starts trying to reconnect... + gpr_log(GPR_INFO, "### subchannel 1 reporting CONNECTING"); subchannel->SetConnectivityState(GRPC_CHANNEL_CONNECTING); + gpr_log(GPR_INFO, "### expecting RR picks again"); ExpectRoundRobinPicks(ExpectState(GRPC_CHANNEL_READY).get(), {kAddresses[0], kAddresses[2]}); + // ...but the connection attempt fails. + gpr_log(GPR_INFO, "### subchannel 1 reporting TRANSIENT_FAILURE"); subchannel->SetConnectivityState(GRPC_CHANNEL_TRANSIENT_FAILURE, absl::ResourceExhaustedError("Hmmmm")); + gpr_log(GPR_INFO, "### expecting re-resolution request"); ExpectReresolutionRequest(); + // The host override is not used. + gpr_log(GPR_INFO, "### checking that host override is not used"); picker = ExpectState(GRPC_CHANNEL_READY); ExpectRoundRobinPicks(picker.get(), {kAddresses[0], kAddresses[2]}, MakeOverrideHostAttribute(kAddresses[1])); @@ -292,6 +306,12 @@ TEST_F(XdsOverrideHostTest, DrainingSubchannelIsConnecting) { EXPECT_EQ(ExpectPickComplete(picker.get(), MakeOverrideHostAttribute(kAddresses[1])), kAddresses[1]); + // Send an update that marks the endpoints with different EDS health + // states, but those states are present in override_host_status. + // The picker should use the DRAINING host when a call's override + // points to that hose, but the host should not be used if there is no + // override pointing to it. + gpr_log(GPR_INFO, "### sending update with DRAINING host"); ApplyUpdateWithHealthStatuses( {{kAddresses[0], XdsHealthStatus::HealthStatus::kUnknown}, {kAddresses[1], XdsHealthStatus::HealthStatus::kDraining}, @@ -299,23 +319,35 @@ TEST_F(XdsOverrideHostTest, DrainingSubchannelIsConnecting) { {"UNKNOWN", "HEALTHY", "DRAINING"}); auto subchannel = FindSubchannel(kAddresses[1]); ASSERT_NE(subchannel, nullptr); - // There are two notifications - one from child policy and one from the parent - // policy due to draining channel update picker = ExpectState(GRPC_CHANNEL_READY); EXPECT_EQ(ExpectPickComplete(picker.get(), MakeOverrideHostAttribute(kAddresses[1])), kAddresses[1]); ExpectRoundRobinPicks(picker.get(), {kAddresses[0], kAddresses[2]}); + // Now the connection to the draining host gets dropped. + // The picker should queue picks where the override host is IDLE. + // All picks without an override host should not use this host. + gpr_log(GPR_INFO, "### closing connection to DRAINING host"); subchannel->SetConnectivityState(GRPC_CHANNEL_IDLE); picker = ExpectState(GRPC_CHANNEL_READY); ExpectPickQueued(picker.get(), MakeOverrideHostAttribute(kAddresses[1])); ExpectRoundRobinPicks(picker.get(), {kAddresses[0], kAddresses[2]}); + // The subchannel should have been asked to reconnect as a result of the + // queued pick above. It will therefore transition into state CONNECTING. + // The pick behavior is the same as above: The picker should queue + // picks where the override host is CONNECTING. All picks without an + // override host should not use this host. + gpr_log(GPR_INFO, "### subchannel starts reconnecting"); EXPECT_TRUE(subchannel->ConnectionRequested()); ExpectQueueEmpty(); subchannel->SetConnectivityState(GRPC_CHANNEL_CONNECTING); picker = ExpectState(GRPC_CHANNEL_READY); ExpectPickQueued(picker.get(), MakeOverrideHostAttribute(kAddresses[1])); ExpectRoundRobinPicks(picker.get(), {kAddresses[0], kAddresses[2]}); + // The subchannel now becomes connected again. + // Now picks with this override host can be completed again. + // Picks without an override host still don't use the draining host. + gpr_log(GPR_INFO, "### subchannel becomes reconnected"); subchannel->SetConnectivityState(GRPC_CHANNEL_READY); picker = ExpectState(GRPC_CHANNEL_READY); EXPECT_EQ(ExpectPickComplete(picker.get(), diff --git a/test/core/transport/chttp2/frame_test.cc b/test/core/transport/chttp2/frame_test.cc index b09afecdef3c9..a353d0fa1ef55 100644 --- a/test/core/transport/chttp2/frame_test.cc +++ b/test/core/transport/chttp2/frame_test.cc @@ -237,7 +237,24 @@ TEST(Frame, ParsePadded) { SliceBufferFromString("hello")})); } +TEST(Frame, UnknownIgnored) { + // 77 = some random undefined frame + EXPECT_EQ( + ParseFrame(0, 0, 10, 77, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), + Http2Frame(Http2UnknownFrame{})); + // 2 = PRIORITY, we just ignore it + EXPECT_EQ( + ParseFrame(0, 0, 10, 2, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), + Http2Frame(Http2UnknownFrame{})); +} + TEST(Frame, ParseRejects) { + // 5 == PUSH_PROMISE + EXPECT_THAT( + ValidateFrame(0, 0, 10, 5, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), + StatusIs(absl::StatusCode::kInternal, + "push promise not supported (and SETTINGS_ENABLE_PUSH " + "explicitly disabled).")); EXPECT_THAT(ValidateFrame(0, 0, 0, 0, 0, 0, 0, 0, 0), StatusIs(absl::StatusCode::kInternal, "invalid stream id: {DATA: flags=0, " diff --git a/test/cpp/ext/gsm/BUILD b/test/cpp/ext/gsm/BUILD index 4fa713f11158d..71cd12945e627 100644 --- a/test/cpp/ext/gsm/BUILD +++ b/test/cpp/ext/gsm/BUILD @@ -40,3 +40,24 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "metadata_exchange_test", + srcs = [ + "metadata_exchange_test.cc", + ], + external_deps = [ + "google_cloud_cpp:experimental-opentelemetry", + "gtest", + "otel/sdk/src/metrics", + ], + language = "C++", + tags = [ + ], + deps = [ + "//:grpc++", + "//src/cpp/ext/gsm:gsm_observability", + "//test/core/util:grpc_test_util", + "//test/cpp/ext/otel:otel_test_library", + ], +) diff --git a/test/cpp/ext/gsm/gsm_observability_test.cc b/test/cpp/ext/gsm/gsm_observability_test.cc index 584df8990a5f4..e46115dba44d0 100644 --- a/test/cpp/ext/gsm/gsm_observability_test.cc +++ b/test/cpp/ext/gsm/gsm_observability_test.cc @@ -21,6 +21,7 @@ #include "google/cloud/opentelemetry/resource_detector.h" #include "gtest/gtest.h" +#include "src/core/lib/gprpp/env.h" #include "test/core/util/test_config.h" namespace grpc { diff --git a/test/cpp/ext/gsm/metadata_exchange_test.cc b/test/cpp/ext/gsm/metadata_exchange_test.cc new file mode 100644 index 0000000000000..b3dc86f7ce407 --- /dev/null +++ b/test/cpp/ext/gsm/metadata_exchange_test.cc @@ -0,0 +1,232 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 "src/cpp/ext/gsm/metadata_exchange.h" + +#include "absl/functional/any_invocable.h" +#include "api/include/opentelemetry/metrics/provider.h" +#include "gmock/gmock.h" +#include "google/cloud/opentelemetry/resource_detector.h" +#include "gtest/gtest.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" + +#include + +#include "src/core/lib/channel/call_tracer.h" +#include "src/core/lib/config/core_configuration.h" +#include "src/core/lib/gprpp/env.h" +#include "src/cpp/ext/gsm/gsm_observability.h" +#include "src/cpp/ext/otel/otel_plugin.h" +#include "test/core/util/test_config.h" +#include "test/cpp/end2end/test_service_impl.h" +#include "test/cpp/ext/otel/otel_test_library.h" + +namespace grpc { +namespace testing { +namespace { + +class TestScenario { + public: + enum class Type : std::uint8_t { kGke, kUnknown }; + + explicit TestScenario(Type type) : type_(type) {} + + opentelemetry::sdk::resource::Resource GetTestResource() const { + switch (type_) { + case Type::kGke: + return TestGkeResource(); + case Type::kUnknown: + return TestUnknownResource(); + } + } + + static std::string Name(const ::testing::TestParamInfo& info) { + switch (info.param.type_) { + case Type::kGke: + return "gke"; + case Type::kUnknown: + return "unknown"; + } + } + + Type type() const { return type_; } + + private: + static opentelemetry::sdk::resource::Resource TestGkeResource() { + opentelemetry::sdk::common::AttributeMap attributes; + attributes.SetAttribute("cloud.platform", "gcp_kubernetes_engine"); + attributes.SetAttribute("k8s.pod.name", "pod"); + attributes.SetAttribute("k8s.container.name", "container"); + attributes.SetAttribute("k8s.namespace.name", "namespace"); + attributes.SetAttribute("k8s.cluster.name", "cluster"); + attributes.SetAttribute("cloud.region", "region"); + attributes.SetAttribute("cloud.account.id", "id"); + return opentelemetry::sdk::resource::Resource::Create(attributes); + } + + static opentelemetry::sdk::resource::Resource TestUnknownResource() { + opentelemetry::sdk::common::AttributeMap attributes; + attributes.SetAttribute("cloud.platform", "random"); + return opentelemetry::sdk::resource::Resource::Create(attributes); + } + + Type type_; +}; + +class MetadataExchangeTest + : public OTelPluginEnd2EndTest, + public ::testing::WithParamInterface { + protected: + void Init(const absl::flat_hash_set& metric_names) { + OTelPluginEnd2EndTest::Init( + metric_names, /*resource=*/GetParam().GetTestResource(), + /*labels_injector=*/ + std::make_unique( + GetParam().GetTestResource().GetAttributes())); + } + + void VerifyGkeServiceMeshAttributes( + const std::map& + attributes, + bool local_only = false) { + if (!local_only) { + switch (GetParam().type()) { + case TestScenario::Type::kGke: + EXPECT_EQ( + absl::get(attributes.at("gsm.remote_workload_type")), + "gcp_kubernetes_engine"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_pod_name")), + "pod"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_container_name")), + "container"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_namespace_name")), + "namespace"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_cluster_name")), + "cluster"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_location")), + "region"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_project_id")), + "id"); + EXPECT_EQ(absl::get( + attributes.at("gsm.remote_workload_canonical_service")), + "canonical_service"); + break; + case TestScenario::Type::kUnknown: + EXPECT_EQ( + absl::get(attributes.at("gsm.remote_workload_type")), + "random"); + break; + } + } + } +}; + +TEST_P(MetadataExchangeTest, ClientAttemptStarted) { + Init(/*metric_names=*/{ + grpc::internal::OTelClientAttemptStartedInstrumentName()}); + SendRPC(); + const char* kMetricName = "grpc.client.attempt.started"; + auto data = ReadCurrentMetricsData( + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return !data.contains(kMetricName); }); + ASSERT_EQ(data[kMetricName].size(), 1); + auto point_data = absl::get_if( + &data[kMetricName][0].point_data); + ASSERT_NE(point_data, nullptr); + auto client_started_value = absl::get_if(&point_data->value_); + ASSERT_NE(client_started_value, nullptr); + EXPECT_EQ(*client_started_value, 1); + const auto& attributes = data[kMetricName][0].attributes.GetAttributes(); + EXPECT_EQ(absl::get(attributes.at("grpc.method")), kMethodName); + EXPECT_EQ(absl::get(attributes.at("grpc.target")), + canonical_server_address_); + VerifyGkeServiceMeshAttributes(attributes, /*local_only=*/true); +} + +TEST_P(MetadataExchangeTest, ClientAttemptDuration) { + Init(/*metric_names=*/{ + grpc::internal::OTelClientAttemptDurationInstrumentName()}); + SendRPC(); + const char* kMetricName = "grpc.client.attempt.duration"; + auto data = ReadCurrentMetricsData( + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return !data.contains(kMetricName); }); + ASSERT_EQ(data[kMetricName].size(), 1); + auto point_data = + absl::get_if( + &data[kMetricName][0].point_data); + ASSERT_NE(point_data, nullptr); + ASSERT_EQ(point_data->count_, 1); + const auto& attributes = data[kMetricName][0].attributes.GetAttributes(); + EXPECT_EQ(absl::get(attributes.at("grpc.method")), kMethodName); + EXPECT_EQ(absl::get(attributes.at("grpc.target")), + canonical_server_address_); + EXPECT_EQ(absl::get(attributes.at("grpc.status")), "OK"); + VerifyGkeServiceMeshAttributes(attributes); +} + +TEST_P(MetadataExchangeTest, ServerCallDuration) { + Init(/*metric_names=*/{ + grpc::internal::OTelServerCallDurationInstrumentName()}); + SendRPC(); + const char* kMetricName = "grpc.server.call.duration"; + auto data = ReadCurrentMetricsData( + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return !data.contains(kMetricName); }); + ASSERT_EQ(data[kMetricName].size(), 1); + auto point_data = + absl::get_if( + &data[kMetricName][0].point_data); + ASSERT_NE(point_data, nullptr); + ASSERT_EQ(point_data->count_, 1); + const auto& attributes = data[kMetricName][0].attributes.GetAttributes(); + EXPECT_EQ(absl::get(attributes.at("grpc.method")), kMethodName); + EXPECT_EQ(absl::get(attributes.at("grpc.status")), "OK"); + VerifyGkeServiceMeshAttributes(attributes); +} + +INSTANTIATE_TEST_SUITE_P( + MetadataExchange, MetadataExchangeTest, + ::testing::Values(TestScenario(TestScenario::Type::kGke), + TestScenario(TestScenario::Type::kUnknown)), + &TestScenario::Name); + +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc::testing::TestEnvironment env(&argc, argv); + ::testing::InitGoogleTest(&argc, argv); + grpc_core::SetEnv("GSM_CANONICAL_SERVICE_NAME", "canonical_service"); + return RUN_ALL_TESTS(); +} diff --git a/test/cpp/ext/otel/BUILD b/test/cpp/ext/otel/BUILD index 7eb21fd9fcc31..284aece49d658 100644 --- a/test/cpp/ext/otel/BUILD +++ b/test/cpp/ext/otel/BUILD @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") licenses(["notice"]) @@ -21,6 +21,31 @@ grpc_package( visibility = "tests", ) +grpc_cc_library( + name = "otel_test_library", + testonly = 1, + srcs = [ + "otel_test_library.cc", + ], + hdrs = [ + "otel_test_library.h", + ], + external_deps = [ + "gtest", + "otel/api", + "otel/sdk/src/metrics", + ], + language = "C++", + tags = [ + ], + deps = [ + "//:grpc++", + "//src/cpp/ext/otel:otel_plugin", + "//test/core/util:grpc_test_util", + "//test/cpp/end2end:test_service_impl", + ], +) + grpc_cc_test( name = "otel_plugin_test", srcs = [ @@ -35,6 +60,7 @@ grpc_cc_test( tags = [ ], deps = [ + ":otel_test_library", "//:grpc++", "//src/cpp/ext/otel:otel_plugin", "//test/core/util:grpc_test_util", diff --git a/test/cpp/ext/otel/otel_plugin_test.cc b/test/cpp/ext/otel/otel_plugin_test.cc index 95caf6a06a912..b5b9635cbfbb7 100644 --- a/test/cpp/ext/otel/otel_plugin_test.cc +++ b/test/cpp/ext/otel/otel_plugin_test.cc @@ -31,6 +31,7 @@ #include "src/core/lib/config/core_configuration.h" #include "test/core/util/test_config.h" #include "test/cpp/end2end/test_service_impl.h" +#include "test/cpp/ext/otel/otel_test_library.h" namespace grpc { namespace testing { @@ -44,120 +45,8 @@ TEST(OTelPluginBuildTest, SdkDependency) { opentelemetry::sdk::metrics::MeterProvider(); } -class MockMetricReader : public opentelemetry::sdk::metrics::MetricReader { - public: - opentelemetry::sdk::metrics::AggregationTemporality GetAggregationTemporality( - opentelemetry::sdk::metrics::InstrumentType) const noexcept override { - return opentelemetry::sdk::metrics::AggregationTemporality::kDelta; - } - - bool OnForceFlush(std::chrono::microseconds) noexcept override { - return true; - } - - bool OnShutDown(std::chrono::microseconds) noexcept override { return true; } - - void OnInitialized() noexcept override {} -}; - -class OTelPluginEnd2EndTest : public ::testing::Test { - protected: - using ::testing::Test::SetUp; - void SetUp(const absl::flat_hash_set& metric_names, - bool test_no_meter_provider = false) { - // We are resetting the MeterProvider and OpenTelemetry plugin at the start - // of each test to avoid test results from one test carrying over to another - // test. (Some measurements can get arbitrarily delayed.) - grpc_core::CoreConfiguration::Reset(); - grpc::internal::OpenTelemetryPluginBuilder ot_builder; - ot_builder.EnableMetrics(metric_names); - if (!test_no_meter_provider) { - auto meter_provider = - std::make_shared(); - reader_.reset(new grpc::testing::MockMetricReader); - meter_provider->AddMetricReader(reader_); - ot_builder.SetMeterProvider(std::move(meter_provider)); - } - ot_builder.BuildAndRegisterGlobal(); - grpc_init(); - grpc::ServerBuilder builder; - int port; - // Use IPv4 here because it's less flaky than IPv6 ("[::]:0") on Travis. - builder.AddListeningPort("0.0.0.0:0", grpc::InsecureServerCredentials(), - &port); - builder.RegisterService(&service_); - server_ = builder.BuildAndStart(); - ASSERT_NE(nullptr, server_); - ASSERT_NE(0, port); - server_address_ = absl::StrCat("localhost:", port); - canonical_server_address_ = absl::StrCat("dns:///", server_address_); - - stub_ = EchoTestService::NewStub(grpc::CreateChannel( - server_address_, grpc::InsecureChannelCredentials())); - } - - void TearDown() override { - server_->Shutdown(); - grpc_shutdown_blocking(); - delete grpc_core::ServerCallTracerFactory::Get(grpc_core::ChannelArgs()); - grpc_core::ServerCallTracerFactory::RegisterGlobal(nullptr); - } - - void ResetStub(std::shared_ptr channel) { - stub_ = EchoTestService::NewStub(channel); - } - - void SendRPC() { - EchoRequest request; - request.set_message("foo"); - EchoResponse response; - grpc::ClientContext context; - grpc::Status status = stub_->Echo(&context, request, &response); - } - - absl::flat_hash_map< - std::string, - std::vector> - ReadCurrentMetricsData( - absl::AnyInvocable< - bool(const absl::flat_hash_map< - std::string, - std::vector>&)> - continue_predicate) { - absl::flat_hash_map< - std::string, - std::vector> - data; - auto deadline = absl::Now() + absl::Seconds(5); - do { - reader_->Collect([&](opentelemetry::sdk::metrics::ResourceMetrics& rm) { - for (const opentelemetry::sdk::metrics::ScopeMetrics& smd : - rm.scope_metric_data_) { - for (const opentelemetry::sdk::metrics::MetricData& md : - smd.metric_data_) { - for (const opentelemetry::sdk::metrics::PointDataAttributes& dp : - md.point_data_attr_) { - data[md.instrument_descriptor.name_].push_back(dp); - } - } - } - return true; - }); - } while (continue_predicate(data) && deadline > absl::Now()); - return data; - } - - const absl::string_view kMethodName = "grpc.testing.EchoTestService/Echo"; - std::shared_ptr reader_; - std::string server_address_; - std::string canonical_server_address_; - CallbackTestServiceImpl service_; - std::unique_ptr server_; - std::unique_ptr stub_; -}; - TEST_F(OTelPluginEnd2EndTest, ClientAttemptStarted) { - SetUp({grpc::internal::OTelClientAttemptStartedInstrumentName()}); + Init({grpc::internal::OTelClientAttemptStartedInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.client.attempt.started"; auto data = ReadCurrentMetricsData( @@ -185,7 +74,7 @@ TEST_F(OTelPluginEnd2EndTest, ClientAttemptStarted) { } TEST_F(OTelPluginEnd2EndTest, ClientAttemptDuration) { - SetUp({grpc::internal::OTelClientAttemptDurationInstrumentName()}); + Init({grpc::internal::OTelClientAttemptDurationInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.client.attempt.duration"; auto data = ReadCurrentMetricsData( @@ -216,8 +105,8 @@ TEST_F(OTelPluginEnd2EndTest, ClientAttemptDuration) { } TEST_F(OTelPluginEnd2EndTest, ClientAttemptSentTotalCompressedMessageSize) { - SetUp({grpc::internal:: - OTelClientAttemptSentTotalCompressedMessageSizeInstrumentName()}); + Init({grpc::internal:: + OTelClientAttemptSentTotalCompressedMessageSizeInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.client.attempt.sent_total_compressed_message_size"; @@ -249,8 +138,8 @@ TEST_F(OTelPluginEnd2EndTest, ClientAttemptSentTotalCompressedMessageSize) { } TEST_F(OTelPluginEnd2EndTest, ClientAttemptRcvdTotalCompressedMessageSize) { - SetUp({grpc::internal:: - OTelClientAttemptRcvdTotalCompressedMessageSizeInstrumentName()}); + Init({grpc::internal:: + OTelClientAttemptRcvdTotalCompressedMessageSizeInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.client.attempt.rcvd_total_compressed_message_size"; @@ -282,7 +171,7 @@ TEST_F(OTelPluginEnd2EndTest, ClientAttemptRcvdTotalCompressedMessageSize) { } TEST_F(OTelPluginEnd2EndTest, ServerCallStarted) { - SetUp({grpc::internal::OTelServerCallStartedInstrumentName()}); + Init({grpc::internal::OTelServerCallStartedInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.server.call.started"; auto data = ReadCurrentMetricsData( @@ -306,7 +195,7 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallStarted) { } TEST_F(OTelPluginEnd2EndTest, ServerCallDuration) { - SetUp({grpc::internal::OTelServerCallDurationInstrumentName()}); + Init({grpc::internal::OTelServerCallDurationInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.server.call.duration"; auto data = ReadCurrentMetricsData( @@ -333,8 +222,8 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallDuration) { } TEST_F(OTelPluginEnd2EndTest, ServerCallSentTotalCompressedMessageSize) { - SetUp({grpc::internal:: - OTelServerCallSentTotalCompressedMessageSizeInstrumentName()}); + Init({grpc::internal:: + OTelServerCallSentTotalCompressedMessageSizeInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.server.call.sent_total_compressed_message_size"; @@ -362,8 +251,8 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallSentTotalCompressedMessageSize) { } TEST_F(OTelPluginEnd2EndTest, ServerCallRcvdTotalCompressedMessageSize) { - SetUp({grpc::internal:: - OTelServerCallRcvdTotalCompressedMessageSizeInstrumentName()}); + Init({grpc::internal:: + OTelServerCallRcvdTotalCompressedMessageSizeInstrumentName()}); SendRPC(); const char* kMetricName = "grpc.server.call.rcvd_total_compressed_message_size"; @@ -392,8 +281,10 @@ TEST_F(OTelPluginEnd2EndTest, ServerCallRcvdTotalCompressedMessageSize) { // Make sure that no meter provider results in normal operations. TEST_F(OTelPluginEnd2EndTest, NoMeterProviderRegistered) { - SetUp({grpc::internal::OTelClientAttemptStartedInstrumentName()}, - /*test_no_meter_provider=*/true); + Init({grpc::internal::OTelClientAttemptStartedInstrumentName()}, + /*resource=*/opentelemetry::sdk::resource::Resource::Create({}), + /*labels_injector=*/nullptr, + /*test_no_meter_provider=*/true); SendRPC(); } diff --git a/test/cpp/ext/otel/otel_test_library.cc b/test/cpp/ext/otel/otel_test_library.cc new file mode 100644 index 0000000000000..151395926f794 --- /dev/null +++ b/test/cpp/ext/otel/otel_test_library.cc @@ -0,0 +1,132 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 "test/cpp/ext/otel/otel_test_library.h" + +#include "absl/functional/any_invocable.h" +#include "api/include/opentelemetry/metrics/provider.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" + +#include + +#include "src/core/lib/channel/call_tracer.h" +#include "src/core/lib/config/core_configuration.h" +#include "test/core/util/test_config.h" +#include "test/cpp/end2end/test_service_impl.h" + +namespace grpc { +namespace testing { + +void OTelPluginEnd2EndTest::Init( + const absl::flat_hash_set& metric_names, + opentelemetry::sdk::resource::Resource resource, + std::unique_ptr labels_injector, + bool test_no_meter_provider) { + // We are resetting the MeterProvider and OpenTelemetry plugin at the start + // of each test to avoid test results from one test carrying over to another + // test. (Some measurements can get arbitrarily delayed.) + auto meter_provider = + std::make_shared( + std::make_unique(), + std::move(resource)); + reader_.reset(new grpc::testing::MockMetricReader); + meter_provider->AddMetricReader(reader_); + grpc_core::CoreConfiguration::Reset(); + grpc::internal::OpenTelemetryPluginBuilder ot_builder; + ot_builder.EnableMetrics(metric_names); + if (!test_no_meter_provider) { + auto meter_provider = + std::make_shared(); + reader_.reset(new grpc::testing::MockMetricReader); + meter_provider->AddMetricReader(reader_); + ot_builder.SetMeterProvider(std::move(meter_provider)); + } + ot_builder.SetLabelsInjector(std::move(labels_injector)); + ot_builder.BuildAndRegisterGlobal(); + grpc_init(); + grpc::ServerBuilder builder; + int port; + // Use IPv4 here because it's less flaky than IPv6 ("[::]:0") on Travis. + builder.AddListeningPort("0.0.0.0:0", grpc::InsecureServerCredentials(), + &port); + builder.RegisterService(&service_); + server_ = builder.BuildAndStart(); + ASSERT_NE(nullptr, server_); + ASSERT_NE(0, port); + server_address_ = absl::StrCat("localhost:", port); + canonical_server_address_ = absl::StrCat("dns:///", server_address_); + + stub_ = EchoTestService::NewStub( + grpc::CreateChannel(server_address_, grpc::InsecureChannelCredentials())); +} + +void OTelPluginEnd2EndTest::TearDown() { + server_->Shutdown(); + grpc_shutdown_blocking(); + delete grpc_core::ServerCallTracerFactory::Get(grpc_core::ChannelArgs()); + grpc_core::ServerCallTracerFactory::RegisterGlobal(nullptr); +} + +void OTelPluginEnd2EndTest::ResetStub(std::shared_ptr channel) { + stub_ = EchoTestService::NewStub(std::move(channel)); +} + +void OTelPluginEnd2EndTest::SendRPC() { + EchoRequest request; + request.set_message("foo"); + EchoResponse response; + grpc::ClientContext context; + grpc::Status status = stub_->Echo(&context, request, &response); +} + +absl::flat_hash_map< + std::string, std::vector> +OTelPluginEnd2EndTest::ReadCurrentMetricsData( + absl::AnyInvocable< + bool(const absl::flat_hash_map< + std::string, + std::vector>&)> + continue_predicate) { + absl::flat_hash_map< + std::string, + std::vector> + data; + auto deadline = absl::Now() + absl::Seconds(5); + do { + reader_->Collect([&](opentelemetry::sdk::metrics::ResourceMetrics& rm) { + for (const opentelemetry::sdk::metrics::ScopeMetrics& smd : + rm.scope_metric_data_) { + for (const opentelemetry::sdk::metrics::MetricData& md : + smd.metric_data_) { + for (const opentelemetry::sdk::metrics::PointDataAttributes& dp : + md.point_data_attr_) { + data[md.instrument_descriptor.name_].push_back(dp); + } + } + } + return true; + }); + } while (continue_predicate(data) && deadline > absl::Now()); + return data; +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/ext/otel/otel_test_library.h b/test/cpp/ext/otel/otel_test_library.h new file mode 100644 index 0000000000000..7c9dabbf17380 --- /dev/null +++ b/test/cpp/ext/otel/otel_test_library.h @@ -0,0 +1,94 @@ +// +// +// Copyright 2023 gRPC authors. +// +// 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 GRPC_TEST_CPP_EXT_OTEL_OTEL_TEST_LIBRARY_H +#define GRPC_TEST_CPP_EXT_OTEL_OTEL_TEST_LIBRARY_H + +#include "absl/functional/any_invocable.h" +#include "api/include/opentelemetry/metrics/provider.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" + +#include + +#include "src/core/lib/channel/call_tracer.h" +#include "src/core/lib/config/core_configuration.h" +#include "src/cpp/ext/otel/otel_plugin.h" +#include "test/core/util/test_config.h" +#include "test/cpp/end2end/test_service_impl.h" + +namespace grpc { +namespace testing { + +class MockMetricReader : public opentelemetry::sdk::metrics::MetricReader { + public: + opentelemetry::sdk::metrics::AggregationTemporality GetAggregationTemporality( + opentelemetry::sdk::metrics::InstrumentType) const noexcept override { + return opentelemetry::sdk::metrics::AggregationTemporality::kDelta; + } + + bool OnForceFlush(std::chrono::microseconds) noexcept override { + return true; + } + + bool OnShutDown(std::chrono::microseconds) noexcept override { return true; } + + void OnInitialized() noexcept override {} +}; + +class OTelPluginEnd2EndTest : public ::testing::Test { + protected: + // Note that we can't use SetUp() here since we want to send in parameters. + void Init( + const absl::flat_hash_set& metric_names, + opentelemetry::sdk::resource::Resource resource = + opentelemetry::sdk::resource::Resource::Create({}), + std::unique_ptr labels_injector = nullptr, + bool test_no_meter_provider = false); + + void TearDown() override; + + void ResetStub(std::shared_ptr channel); + + void SendRPC(); + + absl::flat_hash_map< + std::string, + std::vector> + ReadCurrentMetricsData( + absl::AnyInvocable< + bool(const absl::flat_hash_map< + std::string, + std::vector>&)> + continue_predicate); + + const absl::string_view kMethodName = "grpc.testing.EchoTestService/Echo"; + std::shared_ptr reader_; + std::string server_address_; + std::string canonical_server_address_; + CallbackTestServiceImpl service_; + std::unique_ptr server_; + std::unique_ptr stub_; +}; + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_EXT_OTEL_OTEL_TEST_LIBRARY_H diff --git a/test/distrib/bazel/test_single_bazel_version.sh b/test/distrib/bazel/test_single_bazel_version.sh index a478e18bc55b1..8190899a2f0df 100755 --- a/test/distrib/bazel/test_single_bazel_version.sh +++ b/test/distrib/bazel/test_single_bazel_version.sh @@ -61,9 +61,9 @@ EXCLUDED_TARGETS=( # This could be a legitmate failure due to bitrot. "-//src/proto/grpc/testing:test_gen_proto" - # This appears to be a legitimately broken BUILD file. There's a reference to - # a non-existent "link_dynamic_library.sh". - "-//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:all" + # Analyzing windows toolchains when running on linux results in an error. + # Since bazel distribtests are run on linux, we exclude the windows RBE toolchains. + "-//third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/..." "-//third_party/toolchains:rbe_windows_default_toolchain_suite" # TODO(jtattermusch): add back once fixed diff --git a/third_party/protobuf2.patch b/third_party/protobuf2.patch deleted file mode 100644 index 6bbee4abe66a2..0000000000000 --- a/third_party/protobuf2.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/python/internal.bzl b/python/internal.bzl -index d9ba37ef8..6596a2d39 100644 ---- a/python/internal.bzl -+++ b/python/internal.bzl -@@ -1,5 +1,11 @@ - # Internal helpers for building the Python protobuf runtime. - -+def _remove_cross_repo_path(path): -+ components = path.split("/") -+ if components[0] == "..": -+ return "/".join(components[2:]) -+ return path -+ - def _internal_copy_files_impl(ctx): - strip_prefix = ctx.attr.strip_prefix - if strip_prefix[-1] != "/": -@@ -7,10 +13,11 @@ def _internal_copy_files_impl(ctx): - - src_dests = [] - for src in ctx.files.srcs: -- if src.short_path[:len(strip_prefix)] != strip_prefix: -+ short_path = _remove_cross_repo_path(src.short_path) -+ if short_path[:len(strip_prefix)] != strip_prefix: - fail("Source does not start with %s: %s" % -- (strip_prefix, src.short_path)) -- dest = ctx.actions.declare_file(src.short_path[len(strip_prefix):]) -+ (strip_prefix, short_path)) -+ dest = ctx.actions.declare_file(short_path[len(strip_prefix):]) - src_dests.append([src, dest]) - - if ctx.attr.is_windows: diff --git a/third_party/toolchains/BUILD b/third_party/toolchains/BUILD index 983aa3d0e33f4..97ac9afba0a25 100644 --- a/third_party/toolchains/BUILD +++ b/third_party/toolchains/BUILD @@ -52,25 +52,21 @@ platform( # The default toolchain suite for RBE windows, pass it to --crosstool_top alias( name = "rbe_windows_default_toolchain_suite", - actual = "//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:toolchain", + actual = "//third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc:toolchain", ) # The default CC toolchain suite for RBE windows alias( name = "rbe_windows_default_cc_toolchain", - actual = "//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:cc-toolchain-x64_windows", + actual = "//third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/config:cc-toolchain", ) # The default platform for RBE windows platform( name = "rbe_windows_default_platform", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - ], + # Inherit from the platform target generated by 'rbe_configs_gen'. + parents = ["//third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/config:platform"], exec_properties = create_rbe_exec_properties_dict( - # See rbe_win2019/Dockerfile for image details - container_image = "docker://gcr.io/grpc-testing/rbe_windows2019@sha256:41772e8eeb9dd8c8b996bf32d58164d84b2315c8e81e634bbff5a0216b7f52fd", os_family = "Windows", # by default, all RBE actions will run on "small" workers. labels = {"os": "windows_2019", "machine_size": "small"}, diff --git a/third_party/toolchains/README.md b/third_party/toolchains/README.md index e9d9351726320..2ff0a002e90bd 100644 --- a/third_party/toolchains/README.md +++ b/third_party/toolchains/README.md @@ -1,11 +1,37 @@ # RBE toolchain configuration (Linux and Windows) -- rbe_ubuntu2004: Autogenerated toolchain configuration for linux RBE. - Run `generate_linux_rbe_configs.sh` to regenerate. +## Linux +The `rbe_ubuntu2004` directory contains the autogenerated toolchain configuration for linux RBE. +Run `generate_linux_rbe_configs.sh` to regenerate. -- rbe_windows_bazel_5.2.0_vs2019: The autogenerated toolchain configuration for windows RBE. - Note that the bazel version denotes the bazel version that was used to generate the toolchain configuration. The configuration - can be use with different bazel versions (as long as it works). - See go/rbe-windows-user-guide +## Windows -- rbe_win2019: The windows dockerfile to rebuild the docker image we use on RBE workers. See go/rbe-windows-user-guide \ No newline at end of file +The `rbe_windows_bazel_6.3.2_vs2019` directory contains the autogenerated toolchain configuration for windows RBE. +The configuration was generated by the `rbe_configs_gen` tool (just as the linux RBE config), +but since it's a windows configuration, it needs to be run on a windows machine. + +In order to regenerate: +- Clone `grpc` repository in a kokoro debug windows VM (see internal documentation for how to create one) +- Run `generate_windows_rbe_configs.sh` to regenerate the configs locally on the VM. +- Copy the generated configs back to your workstation (e.g. via `gcloud compute scp` command) + +Note that the bazel version denotes the bazel version that was used to generate the toolchain configuration. The configuration +can be use with different bazel versions (as long as it works). + +Also see go/rbe-windows-user-guide + +# Windows RBE docker image + +The `dockerfile/rbe_windows2019` directory contains the dockerfile to rebuild the docker image we use on RBE windows workers. See go/rbe-windows-user-guide. + +Note that for linux, we use a docker image under `tools/dockerfile` (since for Linux RBE docker image is simply of the testing docker images +we maintain) + +## How to rebuild the Windows RBE docker image and use it for Windows RBE + +On a kokoro debug windows VM, run the following: +- `docker build -t us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_windows2019 third_party/toolchains/dockerfile/rbe_windows2019` +- To be able to authenticate when pushing the image to GAR, run `gcloud auth configure-docker us-docker.pkg.dev` +- `docker push us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_windows2019` +- Update the `generate_windows_rbe_configs.sh` with the newly built & pushed image's SHA256 digest. +- Regenerate the Windows RBE toolchain with the instructions above. diff --git a/third_party/toolchains/rbe_win2019/Dockerfile b/third_party/toolchains/dockerfile/rbe_windows2019/Dockerfile similarity index 99% rename from third_party/toolchains/rbe_win2019/Dockerfile rename to third_party/toolchains/dockerfile/rbe_windows2019/Dockerfile index eb1d018ca6c06..e7fb5b70042ba 100644 --- a/third_party/toolchains/rbe_win2019/Dockerfile +++ b/third_party/toolchains/dockerfile/rbe_windows2019/Dockerfile @@ -42,7 +42,7 @@ RUN Invoke-WebRequest "https://aka.ms/vs/16/release/vs_buildtools.exe" \ "--quiet", "--wait", "--nocache", \ "--add", "Microsoft.VisualStudio.Workload.VCTools", \ "--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", \ - "--add", "Microsoft.VisualStudio.Component.Windows10SDK.19041" -Wait; \ + "--add", "Microsoft.VisualStudio.Component.Windows10SDK.20348" -Wait; \ Remove-Item C:/TEMP/vs_buildtools.exe; \ [Environment]::SetEnvironmentVariable(\"BAZEL_VC\", \"C:\VS\VC\", \"Machine\") # Install msys2 and add to path. diff --git a/third_party/toolchains/generate_windows_rbe_configs.sh b/third_party/toolchains/generate_windows_rbe_configs.sh new file mode 100755 index 0000000000000..2d29ff96f5588 --- /dev/null +++ b/third_party/toolchains/generate_windows_rbe_configs.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright 2023 The gRPC Authors +# +# 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. + +# Generate windows RBE configs using rbe_configs_gen. +# See https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs + +set -ex + +cd $(dirname $0)/../.. + +REPO_ROOT="$(pwd)" + +# Download a recent version of rbe_configs_gen binary +wget https://github.com/bazelbuild/bazel-toolchains/releases/download/v5.1.2/rbe_configs_gen_windows_amd64.exe + +RBE_CONFIGS_GEN_TOOL_PATH="./rbe_configs_gen_windows_amd64.exe" + +# Actions on RBE will run under a dedicated docker image. +WINDOWS_RBE_DOCKER_IMAGE=us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_windows2019@sha256:63aed074a2ca1bf5af45bb43b255d21d51882d7169ec57be7f0f5454ea5d2c98 + +# Bazel version used for configuring +# Needs to be one of the versions from bazel/supported_versions.txt chosen so that the result is compatible +# with other supported bazel versions. +BAZEL_VERSION=6.3.2 + +# Where to store the generated configs (relative to repo root) +CONFIG_OUTPUT_PATH=third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019 + +# Delete old generated configs. +rm -rf "${REPO_ROOT}/${CONFIG_OUTPUT_PATH}" + +# Pull the RBE windows docker image first. +# TOOD(jtattermusch): investigate why pulling a docker image on windows is extremely slow. +docker pull ${WINDOWS_RBE_DOCKER_IMAGE} + +${RBE_CONFIGS_GEN_TOOL_PATH} \ + --bazel_version="${BAZEL_VERSION}" \ + --toolchain_container="${WINDOWS_RBE_DOCKER_IMAGE}" \ + --output_src_root="${REPO_ROOT}" \ + --output_config_path="${CONFIG_OUTPUT_PATH}" \ + --exec_os=windows \ + --target_os=windows \ + --generate_java_configs=false diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/LICENSE b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/LICENSE new file mode 100755 index 0000000000000..f0a1f59a3c8f3 --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 Google LLC + + 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. \ No newline at end of file diff --git a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/BUILD b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/BUILD old mode 100644 new mode 100755 similarity index 94% rename from third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/BUILD rename to third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/BUILD index 37d9cad927735..d61eb8171750a --- a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/BUILD +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/BUILD @@ -96,7 +96,6 @@ cc_toolchain_config( cxx_builtin_include_directories = [ "c:/msys64/usr/", ], tool_paths = {"ar": "c:/msys64/usr/bin/ar", - "compat-ld": "c:/msys64/usr/bin/compat-ld", "cpp": "c:/msys64/usr/bin/cpp", "dwp": "c:/msys64/usr/bin/dwp", "gcc": "c:/msys64/usr/bin/gcc", @@ -154,7 +153,6 @@ cc_toolchain_config( cxx_builtin_include_directories = [ "c:/msys64/mingw64/", ], tool_paths = {"ar": "c:/msys64/mingw64/bin/ar", - "compat-ld": "c:/msys64/mingw64/bin/compat-ld", "cpp": "c:/msys64/mingw64/bin/cpp", "dwp": "c:/msys64/mingw64/bin/dwp", "gcc": "c:/msys64/mingw64/bin/gcc", @@ -209,19 +207,19 @@ cc_toolchain_config( abi_libc_version = "local", toolchain_identifier = "msvc_x64", msvc_env_tmp = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp", - msvc_env_path = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64;C:\\VS\\Common7\\IDE\\VC\\VCPackages;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\VS\\MSBuild\\Current\\bin\\Roslyn;C:\\VS\\Common7\\Tools\\devinit;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64;C:\\VS\\\\MSBuild\\Current\\Bin;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\VS\\Common7\\IDE\\;C:\\VS\\Common7\\Tools\\;;C:\\Windows\\system32", - msvc_env_include = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt", - msvc_env_lib = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\lib\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x64", + msvc_env_path = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64;C:\\VS\\Common7\\IDE\\VC\\VCPackages;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\VS\\MSBuild\\Current\\bin\\Roslyn;C:\\VS\\Common7\\Tools\\devinit;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.20348.0\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64;C:\\VS\\\\MSBuild\\Current\\Bin;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\VS\\Common7\\IDE\\;C:\\VS\\Common7\\Tools\\;;C:\\Windows\\system32", + msvc_env_include = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\cppwinrt", + msvc_env_lib = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\lib\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.20348.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.20348.0\\um\\x64", msvc_cl_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe", msvc_ml_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/ml64.exe", msvc_link_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/link.exe", msvc_lib_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/lib.exe", cxx_builtin_include_directories = [ "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt"], + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\shared", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\um", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\winrt", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\cppwinrt"], tool_paths = { "ar": "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/lib.exe", "ml": "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/ml64.exe", @@ -280,19 +278,19 @@ cc_toolchain_config( abi_libc_version = "local", toolchain_identifier = "msvc_x64_x86", msvc_env_tmp = "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp", - msvc_env_path = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86;C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64;C:\\VS\\Common7\\IDE\\VC\\VCPackages;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\VS\\MSBuild\\Current\\bin\\Roslyn;C:\\VS\\Common7\\Tools\\devinit;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64;C:\\VS\\\\MSBuild\\Current\\Bin;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\VS\\Common7\\IDE\\;C:\\VS\\Common7\\Tools\\;;C:\\Windows\\system32", - msvc_env_include = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt", - msvc_env_lib = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\lib\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\ucrt\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x86", + msvc_env_path = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x86;C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64;C:\\VS\\Common7\\IDE\\VC\\VCPackages;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\VS\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\VS\\MSBuild\\Current\\bin\\Roslyn;C:\\VS\\Common7\\Tools\\devinit;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.20348.0\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64;C:\\VS\\\\MSBuild\\Current\\Bin;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\VS\\Common7\\IDE\\;C:\\VS\\Common7\\Tools\\;;C:\\Windows\\system32", + msvc_env_include = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\um;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\cppwinrt", + msvc_env_lib = "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\lib\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.20348.0\\ucrt\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.20348.0\\um\\x86", msvc_cl_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/cl.exe", msvc_ml_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/ml.exe", msvc_link_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/link.exe", msvc_lib_path = "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/lib.exe", cxx_builtin_include_directories = [ "C:\\VS\\VC\\Tools\\MSVC\\14.29.30133\\include", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt", - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt"], + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\shared", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\um", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\winrt", + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\cppwinrt"], tool_paths = { "ar": "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/lib.exe", "ml": "C:/VS/VC/Tools/MSVC/14.29.30133/bin/HostX64/x86/ml.exe", @@ -612,7 +610,7 @@ toolchain( exec_compatible_with = [ ], target_compatible_with = [ - "@platforms//cpu:arm", + "@platforms//cpu:armv7", "@platforms//os:android", ], toolchain = ":cc-compiler-armeabi-v7a", diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/WORKSPACE b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/WORKSPACE new file mode 100755 index 0000000000000..bc05b4c36ff49 --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/WORKSPACE @@ -0,0 +1,2 @@ +# DO NOT EDIT: automatically generated WORKSPACE file for cc_autoconf rule +workspace(name = "local_config_cc") diff --git a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/armeabi_cc_toolchain_config.bzl b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/armeabi_cc_toolchain_config.bzl old mode 100644 new mode 100755 similarity index 97% rename from third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/armeabi_cc_toolchain_config.bzl rename to third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/armeabi_cc_toolchain_config.bzl index 94e0720bf6c96..72ef48ae6d6df --- a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/armeabi_cc_toolchain_config.bzl +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/armeabi_cc_toolchain_config.bzl @@ -43,12 +43,12 @@ def _impl(ctx): tool_paths = [ tool_path(name = "ar", path = "/bin/false"), - tool_path(name = "compat-ld", path = "/bin/false"), tool_path(name = "cpp", path = "/bin/false"), tool_path(name = "dwp", path = "/bin/false"), tool_path(name = "gcc", path = "/bin/false"), tool_path(name = "gcov", path = "/bin/false"), tool_path(name = "ld", path = "/bin/false"), + tool_path(name = "llvm-profdata", path = "/bin/false"), tool_path(name = "nm", path = "/bin/false"), tool_path(name = "objcopy", path = "/bin/false"), tool_path(name = "objdump", path = "/bin/false"), diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_clangcl b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_clangcl new file mode 100755 index 0000000000000..f440b6083d71f --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_clangcl @@ -0,0 +1,7 @@ +This file is generated by cc_configure and contains builtin include directories +that clang-cl reported. This file is a dependency of every compilation action and +changes to it will be reflected in the action cache key. When some of these +paths change, Bazel will make sure to rerun the action, even though none of +declared action inputs or the action commandline changes. + + diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_mingw b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_mingw new file mode 100755 index 0000000000000..d2cc97c569d1b --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_mingw @@ -0,0 +1,8 @@ +This file is generated by cc_configure and contains builtin include directories +that mingw reported. This file is a dependency of every compilation action and +changes to it will be reflected in the action cache key. When some of these +paths change, Bazel will make sure to rerun the action, even though none of +declared action inputs or the action commandline changes. + + "c:/msys64/mingw64/", + diff --git a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/builtin_include_directory_paths_msvc b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_msvc old mode 100644 new mode 100755 similarity index 99% rename from third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/builtin_include_directory_paths_msvc rename to third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_msvc index 08734ee5632b2..1380bc62e15b6 --- a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/builtin_include_directory_paths_msvc +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/builtin_include_directory_paths_msvc @@ -3,3 +3,5 @@ that msvc reported. This file is a dependency of every compilation action and changes to it will be reflected in the action cache key. When some of these paths change, Bazel will make sure to rerun the action, even though none of declared action inputs or the action commandline changes. + + diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/clang_installation_error.bat b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/clang_installation_error.bat new file mode 100755 index 0000000000000..cf7a0a3a73893 --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/clang_installation_error.bat @@ -0,0 +1,24 @@ +:: Copyright 2019 The Bazel Authors. 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. + +@echo OFF + +echo. 1>&2 +echo The target you are compiling requires the Clang compiler. 1>&2 +echo Bazel couldn't find a valid Clang installation on your machine. 1>&2 + +echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 +echo. 1>&2 + +exit /b 1 diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/get_env.bat b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/get_env.bat new file mode 100755 index 0000000000000..bea05795334bb --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/get_env.bat @@ -0,0 +1,3 @@ +@echo off +call "C:\VS\VC\Auxiliary\Build\VCVARSALL.BAT" amd64 -vcvars_ver=14.29.30133 > NUL +echo PATH=%PATH%,INCLUDE=%INCLUDE%,LIB=%LIB%,WINDOWSSDKDIR=%WINDOWSSDKDIR% diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/msys_gcc_installation_error.bat b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/msys_gcc_installation_error.bat new file mode 100755 index 0000000000000..25c35534f9753 --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/msys_gcc_installation_error.bat @@ -0,0 +1,23 @@ +:: Copyright 2018 The Bazel Authors. 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. + +@echo OFF + +echo. 1>&2 +echo The target you are compiling requires MSYS gcc / MINGW gcc. 1>&2 +echo Bazel couldn't find gcc installation on your machine. 1>&2 +echo Please install MSYS gcc / MINGW gcc and set BAZEL_SH environment variable 1>&2 +echo. 1>&2 + +exit /b 1 diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm.bat b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm.bat new file mode 100755 index 0000000000000..1fb5bd7af880f --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm.bat @@ -0,0 +1,29 @@ +:: Copyright 2017 The Bazel Authors. 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. + +@echo OFF + +echo. 1>&2 +echo The target you are compiling requires Visual C++ build tools. 1>&2 +echo Bazel couldn't find a valid Visual C++ build tools installation on your machine. 1>&2 +echo. 1>&2 +echo Visual C++ build tools seems to be installed at C:\VS\VC 1>&2 +echo But Bazel can't find the following tools: 1>&2 +echo cl.exe, link.exe, lib.exe 1>&2 +echo for arm target architecture 1>&2 +echo. 1>&2 +echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 +echo. 1>&2 + +exit /b 1 diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm64.bat b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm64.bat new file mode 100755 index 0000000000000..7ad3d7b6903f4 --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/vc_installation_error_arm64.bat @@ -0,0 +1,29 @@ +:: Copyright 2017 The Bazel Authors. 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. + +@echo OFF + +echo. 1>&2 +echo The target you are compiling requires Visual C++ build tools. 1>&2 +echo Bazel couldn't find a valid Visual C++ build tools installation on your machine. 1>&2 +echo. 1>&2 +echo Visual C++ build tools seems to be installed at C:\VS\VC 1>&2 +echo But Bazel can't find the following tools: 1>&2 +echo cl.exe, link.exe, lib.exe 1>&2 +echo for arm64 target architecture 1>&2 +echo. 1>&2 +echo Please check your installation following https://bazel.build/docs/windows#using 1>&2 +echo. 1>&2 + +exit /b 1 diff --git a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/windows_cc_toolchain_config.bzl b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/windows_cc_toolchain_config.bzl old mode 100644 new mode 100755 similarity index 92% rename from third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/windows_cc_toolchain_config.bzl rename to third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/windows_cc_toolchain_config.bzl index f0233ceafbce7..e2f464a6c8ae4 --- a/third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019/windows_cc_toolchain_config.bzl +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc/windows_cc_toolchain_config.bzl @@ -21,7 +21,6 @@ load( "env_entry", "env_set", "feature", - "feature_set", "flag_group", "flag_set", "tool", @@ -135,7 +134,6 @@ def _impl(ctx): "output_execpath_flags", "input_param_flags", "user_link_flags", - "default_link_flags", "linker_subsystem_flag", "linker_param_file", "msvc_env", @@ -184,6 +182,20 @@ def _impl(ctx): c_compile_action = action_config( action_name = ACTION_NAMES.c_compile, + implies = [ + "compiler_input_flags", + "compiler_output_flags", + "nologo", + "msvc_env", + "parse_showincludes", + "user_compile_flags", + "sysroot", + ], + tools = [tool(path = ctx.attr.msvc_cl_path)], + ) + + linkstamp_compile_action = action_config( + action_name = ACTION_NAMES.linkstamp_compile, implies = [ "compiler_input_flags", "compiler_output_flags", @@ -203,13 +215,11 @@ def _impl(ctx): implies = [ "compiler_input_flags", "compiler_output_flags", - "default_compile_flags", "nologo", "msvc_env", "parse_showincludes", "user_compile_flags", "sysroot", - "unfiltered_compile_flags", ], tools = [tool(path = ctx.attr.msvc_cl_path)], ) @@ -222,7 +232,6 @@ def _impl(ctx): "output_execpath_flags", "input_param_flags", "user_link_flags", - "default_link_flags", "linker_subsystem_flag", "linker_param_file", "msvc_env", @@ -240,7 +249,6 @@ def _impl(ctx): "output_execpath_flags", "input_param_flags", "user_link_flags", - "default_link_flags", "linker_subsystem_flag", "linker_param_file", "msvc_env", @@ -255,6 +263,7 @@ def _impl(ctx): assemble_action, preprocess_assemble_action, c_compile_action, + linkstamp_compile_action, cpp_compile_action, cpp_link_executable_action, cpp_link_dynamic_library_action, @@ -317,6 +326,7 @@ def _impl(ctx): ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -338,11 +348,13 @@ def _impl(ctx): unfiltered_compile_flags_feature = feature( name = "unfiltered_compile_flags", + enabled = True, flag_sets = [ flag_set( actions = [ ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -359,6 +371,11 @@ def _impl(ctx): ], ) + archive_param_file_feature = feature( + name = "archive_param_file", + enabled = True, + ) + compiler_param_file_feature = feature( name = "compiler_param_file", ) @@ -471,6 +488,7 @@ def _impl(ctx): actions = [ ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -516,21 +534,57 @@ def _impl(ctx): ], ) - static_link_msvcrt_feature = feature(name = "static_link_msvcrt") + static_link_msvcrt_feature = feature( + name = "static_link_msvcrt", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MT"])], + with_features = [with_feature_set(not_features = ["dbg"])], + ), + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MTd"])], + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], + with_features = [with_feature_set(not_features = ["dbg"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], + with_features = [with_feature_set(features = ["dbg"])], + ), + ], + ) - dynamic_link_msvcrt_debug_feature = feature( - name = "dynamic_link_msvcrt_debug", + dynamic_link_msvcrt_feature = feature( + name = "dynamic_link_msvcrt", + enabled = True, flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["/MD"])], + with_features = [with_feature_set(not_features = ["dbg", "static_link_msvcrt"])], + ), flag_set( actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], flag_groups = [flag_group(flags = ["/MDd"])], + with_features = [with_feature_set(features = ["dbg"], not_features = ["static_link_msvcrt"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], + with_features = [with_feature_set(not_features = ["dbg", "static_link_msvcrt"])], ), flag_set( actions = all_link_actions, flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])], + with_features = [with_feature_set(features = ["dbg"], not_features = ["static_link_msvcrt"])], ), ], - requires = [feature_set(features = ["dbg"])], ) dbg_feature = feature( @@ -629,6 +683,7 @@ def _impl(ctx): env_set( actions = [ ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, @@ -650,6 +705,7 @@ def _impl(ctx): ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -683,24 +739,6 @@ def _impl(ctx): ], ) - dynamic_link_msvcrt_no_debug_feature = feature( - name = "dynamic_link_msvcrt_no_debug", - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], - flag_groups = [flag_group(flags = ["/MD"])], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], - ), - ], - requires = [ - feature_set(features = ["fastbuild"]), - feature_set(features = ["opt"]), - ], - ) - disable_assertions_feature = feature( name = "disable_assertions", enabled = True, @@ -755,6 +793,7 @@ def _impl(ctx): actions = [ ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_header_parsing, @@ -764,29 +803,11 @@ def _impl(ctx): ], ) - static_link_msvcrt_no_debug_feature = feature( - name = "static_link_msvcrt_no_debug", - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], - flag_groups = [flag_group(flags = ["/MT"])], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], - ), - ], - requires = [ - feature_set(features = ["fastbuild"]), - feature_set(features = ["opt"]), - ], - ) - treat_warnings_as_errors_feature = feature( name = "treat_warnings_as_errors", flag_sets = [ flag_set( - actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile] + all_link_actions, flag_groups = [flag_group(flags = ["/WX"])], ), ], @@ -805,6 +826,7 @@ def _impl(ctx): ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -827,6 +849,32 @@ def _impl(ctx): ], ) + external_include_paths_feature = feature( + name = "external_include_paths", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [ + flag_group( + flags = ["/external:I", "%{external_include_paths}"], + iterate_over = "external_include_paths", + expand_if_available = "external_include_paths", + ), + ], + ), + ], + ) + linkstamps_feature = feature( name = "linkstamps", flag_sets = [ @@ -859,21 +907,6 @@ def _impl(ctx): ], ) - static_link_msvcrt_debug_feature = feature( - name = "static_link_msvcrt_debug", - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], - flag_groups = [flag_group(flags = ["/MTd"])], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], - ), - ], - requires = [feature_set(features = ["dbg"])], - ) - frame_pointer_feature = feature( name = "frame_pointer", flag_sets = [ @@ -906,6 +939,7 @@ def _impl(ctx): actions = [ ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -951,6 +985,7 @@ def _impl(ctx): flag_set( actions = [ ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, @@ -992,6 +1027,7 @@ def _impl(ctx): ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, @@ -1028,6 +1064,7 @@ def _impl(ctx): env_set( actions = [ ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, @@ -1060,6 +1097,7 @@ def _impl(ctx): msvc_compile_env_feature, msvc_link_env_feature, include_paths_feature, + external_include_paths_feature, preprocessor_defines_feature, parse_showincludes_feature, generate_pdb_file_feature, @@ -1073,10 +1111,7 @@ def _impl(ctx): default_link_flags_feature, linker_param_file_feature, static_link_msvcrt_feature, - static_link_msvcrt_no_debug_feature, - dynamic_link_msvcrt_no_debug_feature, - static_link_msvcrt_debug_feature, - dynamic_link_msvcrt_debug_feature, + dynamic_link_msvcrt_feature, dbg_feature, fastbuild_feature, opt_feature, @@ -1089,6 +1124,7 @@ def _impl(ctx): user_compile_flags_feature, sysroot_feature, unfiltered_compile_flags_feature, + archive_param_file_feature, compiler_param_file_feature, compiler_output_flags_feature, compiler_input_flags_feature, @@ -1114,6 +1150,7 @@ def _impl(ctx): env_set( actions = [ ACTION_NAMES.c_compile, + ACTION_NAMES.linkstamp_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, @@ -1198,6 +1235,11 @@ def _impl(ctx): ) if ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc": + archive_param_file_feature = feature( + name = "archive_param_file", + enabled = True, + ) + compiler_param_file_feature = feature( name = "compiler_param_file", ) @@ -1207,6 +1249,7 @@ def _impl(ctx): copy_dynamic_libraries_to_binary_feature, gcc_env_feature, default_compile_flags_feature, + archive_param_file_feature, compiler_param_file_feature, default_link_flags_feature, supports_dynamic_linker_feature, @@ -1218,10 +1261,6 @@ def _impl(ctx): name = "supports_pic", enabled = True, ) - supports_start_end_lib_feature = feature( - name = "supports_start_end_lib", - enabled = True, - ) sysroot_feature = feature( name = "sysroot", @@ -1271,6 +1310,20 @@ def _impl(ctx): provides = ["profile"], ) + treat_warnings_as_errors_feature = feature( + name = "treat_warnings_as_errors", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["-Werror"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["-Wl,-fatal-warnings"])], + ), + ], + ) + user_compile_flags_feature = feature( name = "user_compile_flags", enabled = True, @@ -1311,6 +1364,7 @@ def _impl(ctx): dbg_feature, opt_feature, user_compile_flags_feature, + treat_warnings_as_errors_feature, sysroot_feature, ] diff --git a/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/config/BUILD b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/config/BUILD new file mode 100755 index 0000000000000..e6a62ca6d955c --- /dev/null +++ b/third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/config/BUILD @@ -0,0 +1,46 @@ +# Copyright 2020 The Bazel Authors. 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. + +# This file is auto-generated by github.com/bazelbuild/bazel-toolchains/pkg/rbeconfigsgen +# and should not be modified directly. + +package(default_visibility = ["//visibility:public"]) + + +toolchain( + name = "cc-toolchain", + exec_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + target_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + toolchain = "//third_party/toolchains/rbe_windows_bazel_6.3.2_vs2019/cc:cc-compiler-x64_windows", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +platform( + name = "platform", + parents = ["@local_config_platform//:host"], + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + exec_properties = { + "container-image": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_windows2019@sha256:63aed074a2ca1bf5af45bb43b255d21d51882d7169ec57be7f0f5454ea5d2c98", + "OSFamily": "Windows", + }, +) diff --git a/tools/distrib/fix_build_deps.py b/tools/distrib/fix_build_deps.py index 4bae1a10a4294..da478988b1979 100755 --- a/tools/distrib/fix_build_deps.py +++ b/tools/distrib/fix_build_deps.py @@ -94,6 +94,10 @@ "absl/utility/utility.h": "absl/utility", "address_sorting/address_sorting.h": "address_sorting", "google/cloud/opentelemetry/resource_detector.h": "google_cloud_cpp:experimental-opentelemetry", + "opentelemetry/common/attribute_value.h": "otel/api", + "opentelemetry/common/key_value_iterable.h": "otel/api", + "opentelemetry/nostd/function_ref.h": "otel/api", + "opentelemetry/nostd/string_view.h": "otel/api", "opentelemetry/context/context.h": "otel/api", "opentelemetry/metrics/meter.h": "otel/api", "opentelemetry/metrics/meter_provider.h": "otel/api", @@ -102,6 +106,8 @@ "opentelemetry/nostd/shared_ptr.h": "otel/api", "opentelemetry/nostd/unique_ptr.h": "otel/api", "opentelemetry/sdk/metrics/meter_provider.h": "otel/sdk/src/metrics", + "opentelemetry/sdk/common/attribute_utils.h": "otel/sdk:headers", + "opentelemetry/sdk/resource/semantic_conventions.h": "otel/sdk:headers", "ares.h": "cares", "fuzztest/fuzztest.h": ["fuzztest", "fuzztest_main"], "google/api/monitored_resource.pb.h": ( diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat index 103643c6d6c18..4bd9cb6c9eed4 100644 --- a/tools/internal_ci/windows/bazel_rbe.bat +++ b/tools/internal_ci/windows/bazel_rbe.bat @@ -29,8 +29,6 @@ call tools/internal_ci/helper_scripts/prepare_build_windows.bat || exit /b 1 @rem Install bazel @rem Side effect of the tools/bazel script is that it downloads the correct version of bazel binary. mkdir C:\bazel -@rem This is a workaround to resolve weird linker error from Bazel 6.x -set OVERRIDE_BAZEL_VERSION=5.4.1 bash -c "tools/bazel --version && cp tools/bazel-*.exe /c/bazel/bazel.exe" set PATH=C:\bazel;%PATH% bazel --version diff --git a/tools/remote_build/windows.bazelrc b/tools/remote_build/windows.bazelrc index f5b7a0cf1fdd2..d6390ce57fd6f 100644 --- a/tools/remote_build/windows.bazelrc +++ b/tools/remote_build/windows.bazelrc @@ -16,4 +16,8 @@ build --build_tag_filters=-no_windows build --jobs=100 +# Without this the build is broken on windows RBE with bazel 6.x+ +# TODO(jtattermusch): Remove the workaround. +build --dynamic_mode=off + import %workspace%/tools/remote_build/include/test_config_common.bazelrc diff --git a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client-secure.deployment.yaml b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client-secure.deployment.yaml index a78f720fef374..4803ecfa7090a 100644 --- a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client-secure.deployment.yaml +++ b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client-secure.deployment.yaml @@ -51,6 +51,8 @@ spec: value: "true" - name: GRPC_XDS_EXPERIMENTAL_V3_SUPPORT value: "true" + - name: GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST + value: "true" volumeMounts: - mountPath: /tmp/grpc-xds/ name: grpc-td-conf diff --git a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client.deployment.yaml b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client.deployment.yaml index 47336665a0392..5bc51824748aa 100644 --- a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client.deployment.yaml +++ b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/client.deployment.yaml @@ -51,9 +51,11 @@ spec: value: "true" - name: GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY value: "true" + - name: GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION + value: "true" - name: GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG value: "true" - - name: GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION + - name: GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST value: "true" volumeMounts: - mountPath: /tmp/grpc-xds/ diff --git a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server-secure.deployment.yaml b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server-secure.deployment.yaml index 45865d9849b78..ab3b1599e8fce 100644 --- a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server-secure.deployment.yaml +++ b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server-secure.deployment.yaml @@ -54,6 +54,8 @@ spec: value: "true" - name: GRPC_XDS_EXPERIMENTAL_RBAC value: "true" + - name: GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST + value: "true" volumeMounts: - mountPath: /tmp/grpc-xds/ name: grpc-td-conf diff --git a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server.deployment.yaml b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server.deployment.yaml index 0d6501a2daae4..f39a6d61dd998 100644 --- a/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server.deployment.yaml +++ b/tools/run_tests/xds_k8s_test_driver/kubernetes-manifests/server.deployment.yaml @@ -44,6 +44,8 @@ spec: value: "/tmp/grpc-xds/td-grpc-bootstrap.json" - name: GRPC_XDS_EXPERIMENTAL_V3_SUPPORT value: "true" + - name: GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST + value: "true" volumeMounts: - mountPath: /tmp/grpc-xds/ name: grpc-td-conf