grpc 1.38.0 → 1.39.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +50 -19
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +13 -15
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +17 -7
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +17 -13
  11. data/include/grpc/impl/codegen/port_platform.h +17 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +2 -2
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  15. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +10 -24
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +63 -95
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  23. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  24. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  25. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +15 -3
  26. data/src/core/ext/filters/client_channel/retry_filter.cc +665 -404
  27. data/src/core/ext/filters/client_channel/retry_service_config.cc +43 -24
  28. data/src/core/ext/filters/client_channel/retry_service_config.h +8 -2
  29. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  30. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +6 -0
  31. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  32. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  33. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +10 -4
  34. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  35. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -2
  36. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  37. data/src/core/ext/xds/xds_api.cc +247 -106
  38. data/src/core/ext/xds/xds_api.h +15 -6
  39. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  40. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  41. data/src/core/lib/channel/channelz.h +3 -0
  42. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  43. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  44. data/src/core/lib/event_engine/event_engine.cc +50 -0
  45. data/src/core/lib/event_engine/slice_allocator.cc +33 -3
  46. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  47. data/src/core/lib/event_engine/sockaddr.h +44 -0
  48. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  49. data/src/core/lib/gprpp/status_helper.h +3 -0
  50. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  51. data/src/core/lib/iomgr/error.cc +5 -4
  52. data/src/core/lib/iomgr/error.h +1 -1
  53. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  54. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  55. data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
  56. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  57. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  58. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  59. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  60. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  61. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  62. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  63. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  64. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  65. data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
  66. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  67. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  68. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  69. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  70. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  71. data/src/core/lib/iomgr/iomgr.cc +1 -1
  72. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  73. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  74. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  75. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  76. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  77. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  78. data/src/core/lib/iomgr/port.h +7 -5
  79. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  80. data/src/core/lib/iomgr/resolve_address.h +6 -0
  81. data/src/core/lib/iomgr/sockaddr.h +1 -0
  82. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  83. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  84. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  85. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  86. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  87. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  88. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  89. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  90. data/src/core/lib/iomgr/tcp_server_posix.cc +6 -0
  91. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  92. data/src/core/lib/iomgr/timer.h +6 -1
  93. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  94. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  95. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  96. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  97. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  98. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  99. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  100. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  101. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  102. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  103. data/src/core/lib/surface/call.cc +21 -1
  104. data/src/core/lib/surface/call.h +11 -0
  105. data/src/core/lib/surface/completion_queue.cc +22 -22
  106. data/src/core/lib/surface/completion_queue.h +1 -1
  107. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  108. data/src/core/lib/surface/init.cc +1 -3
  109. data/src/core/lib/surface/init.h +10 -1
  110. data/src/core/lib/surface/version.cc +1 -1
  111. data/src/core/lib/transport/error_utils.cc +2 -2
  112. data/src/core/lib/transport/transport.h +2 -0
  113. data/src/core/lib/transport/transport_op_string.cc +1 -1
  114. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  115. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  116. data/src/ruby/ext/grpc/extconf.rb +2 -0
  117. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  118. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  119. data/src/ruby/lib/grpc/version.rb +1 -1
  120. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  121. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  122. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  123. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  124. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  125. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  126. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  127. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  128. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  129. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  130. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  131. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  132. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  133. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  134. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  135. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  136. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  137. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  138. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  139. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  140. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  141. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  142. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  143. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  144. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  145. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  146. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  147. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  148. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  149. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  150. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  151. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  152. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  153. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  154. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  155. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  156. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  157. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  158. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  159. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  160. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  161. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  162. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  163. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  164. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  165. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  166. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  167. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  168. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  169. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  170. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  171. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  172. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  173. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  174. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  175. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  176. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  177. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  178. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  179. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  180. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  181. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  182. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  183. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  184. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  185. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  186. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  187. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  188. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  189. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  190. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  191. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  192. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  193. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  194. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  195. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  196. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  197. metadata +65 -40
  198. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -697,10 +697,24 @@ std::string XdsApi::LdsUpdate::ToString() const {
697
697
  //
698
698
 
699
699
  std::string XdsApi::CdsUpdate::ToString() const {
700
- absl::InlinedVector<std::string, 4> contents;
701
- if (!eds_service_name.empty()) {
702
- contents.push_back(
703
- absl::StrFormat("eds_service_name=%s", eds_service_name));
700
+ absl::InlinedVector<std::string, 8> contents;
701
+ switch (cluster_type) {
702
+ case EDS:
703
+ contents.push_back("cluster_type=EDS");
704
+ if (!eds_service_name.empty()) {
705
+ contents.push_back(
706
+ absl::StrFormat("eds_service_name=%s", eds_service_name));
707
+ }
708
+ break;
709
+ case LOGICAL_DNS:
710
+ contents.push_back("cluster_type=LOGICAL_DNS");
711
+ contents.push_back(absl::StrFormat("dns_hostname=%s", dns_hostname));
712
+ break;
713
+ case AGGREGATE:
714
+ contents.push_back("cluster_type=AGGREGATE");
715
+ contents.push_back(
716
+ absl::StrFormat("prioritized_cluster_names=[%s]",
717
+ absl::StrJoin(prioritized_cluster_names, ", ")));
704
718
  }
705
719
  if (!common_tls_context.Empty()) {
706
720
  contents.push_back(absl::StrFormat("common_tls_context=%s",
@@ -710,6 +724,11 @@ std::string XdsApi::CdsUpdate::ToString() const {
710
724
  contents.push_back(absl::StrFormat("lrs_load_reporting_server_name=%s",
711
725
  lrs_load_reporting_server_name.value()));
712
726
  }
727
+ contents.push_back(absl::StrCat("lb_policy=", lb_policy));
728
+ if (lb_policy == "RING_HASH") {
729
+ contents.push_back(absl::StrCat("min_ring_size=", min_ring_size));
730
+ contents.push_back(absl::StrCat("max_ring_size=", max_ring_size));
731
+ }
713
732
  contents.push_back(
714
733
  absl::StrFormat("max_concurrent_requests=%d", max_concurrent_requests));
715
734
  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
@@ -830,14 +849,39 @@ bool IsEds(absl::string_view type_url) {
830
849
 
831
850
  } // namespace
832
851
 
852
+ // If gRPC is built with -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="...", that string
853
+ // will be appended to the user agent name reported to the xDS server.
854
+ #ifdef GRPC_XDS_USER_AGENT_NAME_SUFFIX
855
+ #define GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING \
856
+ " " GRPC_XDS_USER_AGENT_NAME_SUFFIX
857
+ #else
858
+ #define GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING ""
859
+ #endif
860
+
861
+ // If gRPC is built with -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX="...", that string
862
+ // will be appended to the user agent version reported to the xDS server.
863
+ #ifdef GRPC_XDS_USER_AGENT_VERSION_SUFFIX
864
+ #define GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING \
865
+ " " GRPC_XDS_USER_AGENT_VERSION_SUFFIX
866
+ #else
867
+ #define GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING ""
868
+ #endif
869
+
833
870
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
834
871
  const XdsBootstrap::Node* node)
835
872
  : client_(client),
836
873
  tracer_(tracer),
837
874
  node_(node),
838
875
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
839
- grpc_version_string())),
840
- user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {
876
+ grpc_version_string(),
877
+ GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING,
878
+ GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING)),
879
+ user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING,
880
+ GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING)),
881
+ user_agent_version_(
882
+ absl::StrCat("C-core ", grpc_version_string(),
883
+ GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING,
884
+ GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING)) {
841
885
  // Populate upb symtab with xDS proto messages that we want to print
842
886
  // properly in logs.
843
887
  // Note: This won't actually work properly until upb adds support for
@@ -968,6 +1012,7 @@ void PopulateNode(const EncodingContext& context,
968
1012
  const XdsBootstrap::Node* node,
969
1013
  const std::string& build_version,
970
1014
  const std::string& user_agent_name,
1015
+ const std::string& user_agent_version,
971
1016
  envoy_config_core_v3_Node* node_msg) {
972
1017
  if (node != nullptr) {
973
1018
  if (!node->id.empty()) {
@@ -1007,7 +1052,7 @@ void PopulateNode(const EncodingContext& context,
1007
1052
  envoy_config_core_v3_Node_set_user_agent_name(
1008
1053
  node_msg, StdStringToUpbString(user_agent_name));
1009
1054
  envoy_config_core_v3_Node_set_user_agent_version(
1010
- node_msg, upb_strview_makez(grpc_version_string()));
1055
+ node_msg, StdStringToUpbString(user_agent_version));
1011
1056
  envoy_config_core_v3_Node_add_client_features(
1012
1057
  node_msg, upb_strview_makez("envoy.lb.does_not_support_overprovisioning"),
1013
1058
  context.arena);
@@ -1113,7 +1158,8 @@ grpc_slice XdsApi::CreateAdsRequest(
1113
1158
  envoy_config_core_v3_Node* node_msg =
1114
1159
  envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
1115
1160
  arena.ptr());
1116
- PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
1161
+ PopulateNode(context, node_, build_version_, user_agent_name_,
1162
+ user_agent_version_, node_msg);
1117
1163
  }
1118
1164
  // Add resource_names.
1119
1165
  for (const auto& resource_name : resource_names) {
@@ -1605,40 +1651,35 @@ grpc_error_handle RouteActionParse(const EncodingContext& context,
1605
1651
  regex_rewrite =
1606
1652
  envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
1607
1653
  header);
1608
- if (regex_rewrite == nullptr) {
1609
- gpr_log(
1610
- GPR_DEBUG,
1611
- "RouteAction HashPolicy contains policy specifier Header with "
1612
- "RegexMatchAndSubstitution but Regex is missing");
1613
- continue;
1614
- }
1615
- const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1616
- envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
1617
- regex_rewrite);
1618
- if (regex_matcher == nullptr) {
1619
- gpr_log(
1620
- GPR_DEBUG,
1621
- "RouteAction HashPolicy contains policy specifier Header with "
1622
- "RegexMatchAndSubstitution but RegexMatcher pattern is "
1623
- "missing");
1624
- continue;
1625
- }
1626
- RE2::Options options;
1627
- policy.regex = absl::make_unique<RE2>(
1628
- UpbStringToStdString(
1629
- envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
1630
- options);
1631
- if (!policy.regex->ok()) {
1632
- gpr_log(
1633
- GPR_DEBUG,
1634
- "RouteAction HashPolicy contains policy specifier Header with "
1635
- "RegexMatchAndSubstitution but RegexMatcher pattern does not "
1636
- "compile");
1637
- continue;
1654
+ if (regex_rewrite != nullptr) {
1655
+ const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1656
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
1657
+ regex_rewrite);
1658
+ if (regex_matcher == nullptr) {
1659
+ gpr_log(
1660
+ GPR_DEBUG,
1661
+ "RouteAction HashPolicy contains policy specifier Header with "
1662
+ "RegexMatchAndSubstitution but RegexMatcher pattern is "
1663
+ "missing");
1664
+ continue;
1665
+ }
1666
+ RE2::Options options;
1667
+ policy.regex = absl::make_unique<RE2>(
1668
+ UpbStringToStdString(
1669
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
1670
+ options);
1671
+ if (!policy.regex->ok()) {
1672
+ gpr_log(
1673
+ GPR_DEBUG,
1674
+ "RouteAction HashPolicy contains policy specifier Header with "
1675
+ "RegexMatchAndSubstitution but RegexMatcher pattern does not "
1676
+ "compile");
1677
+ continue;
1678
+ }
1679
+ policy.regex_substitution = UpbStringToStdString(
1680
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
1681
+ regex_rewrite));
1638
1682
  }
1639
- policy.regex_substitution = UpbStringToStdString(
1640
- envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
1641
- regex_rewrite));
1642
1683
  } else if ((filter_state =
1643
1684
  envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
1644
1685
  hash_policy)) != nullptr) {
@@ -2707,10 +2748,11 @@ grpc_error_handle CdsResponseParse(
2707
2748
  resource_names_failed->insert(cluster_name);
2708
2749
  continue;
2709
2750
  }
2710
- // Serialize into JSON and store it in the CdsUpdateMap
2751
+ // Add the cluster to cds_update_map.
2711
2752
  XdsApi::CdsResourceData& cds_resource_data =
2712
2753
  (*cds_update_map)[cluster_name];
2713
2754
  XdsApi::CdsUpdate& cds_update = cds_resource_data.resource;
2755
+ // Store serialized proto.
2714
2756
  cds_resource_data.serialized_proto = UpbStringToStdString(encoded_cluster);
2715
2757
  // Check the cluster_discovery_type.
2716
2758
  if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
@@ -2752,6 +2794,102 @@ grpc_error_handle CdsResponseParse(
2752
2794
  } else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
2753
2795
  envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
2754
2796
  cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
2797
+ const auto* load_assignment =
2798
+ envoy_config_cluster_v3_Cluster_load_assignment(cluster);
2799
+ if (load_assignment == nullptr) {
2800
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2801
+ absl::StrCat(
2802
+ cluster_name,
2803
+ ": load_assignment not present for LOGICAL_DNS cluster")
2804
+ .c_str()));
2805
+ resource_names_failed->insert(cluster_name);
2806
+ continue;
2807
+ }
2808
+ size_t num_localities;
2809
+ const auto* const* localities =
2810
+ envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
2811
+ load_assignment, &num_localities);
2812
+ if (num_localities != 1) {
2813
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2814
+ absl::StrCat(cluster_name,
2815
+ ": load_assignment for LOGICAL_DNS cluster must have "
2816
+ "exactly one locality, found ",
2817
+ num_localities)
2818
+ .c_str()));
2819
+ resource_names_failed->insert(cluster_name);
2820
+ continue;
2821
+ }
2822
+ size_t num_endpoints;
2823
+ const auto* const* endpoints =
2824
+ envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
2825
+ localities[0], &num_endpoints);
2826
+ if (num_endpoints != 1) {
2827
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2828
+ absl::StrCat(cluster_name,
2829
+ ": locality for LOGICAL_DNS cluster must have "
2830
+ "exactly one endpoint, found ",
2831
+ num_endpoints)
2832
+ .c_str()));
2833
+ resource_names_failed->insert(cluster_name);
2834
+ continue;
2835
+ }
2836
+ const auto* endpoint =
2837
+ envoy_config_endpoint_v3_LbEndpoint_endpoint(endpoints[0]);
2838
+ if (endpoint == nullptr) {
2839
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2840
+ absl::StrCat(cluster_name, ": LbEndpoint endpoint field not set")
2841
+ .c_str()));
2842
+ resource_names_failed->insert(cluster_name);
2843
+ continue;
2844
+ }
2845
+ const auto* address = envoy_config_endpoint_v3_Endpoint_address(endpoint);
2846
+ if (address == nullptr) {
2847
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2848
+ absl::StrCat(cluster_name, ": Endpoint address field not set")
2849
+ .c_str()));
2850
+ resource_names_failed->insert(cluster_name);
2851
+ continue;
2852
+ }
2853
+ const auto* socket_address =
2854
+ envoy_config_core_v3_Address_socket_address(address);
2855
+ if (socket_address == nullptr) {
2856
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2857
+ absl::StrCat(cluster_name, ": Address socket_address field not set")
2858
+ .c_str()));
2859
+ resource_names_failed->insert(cluster_name);
2860
+ continue;
2861
+ }
2862
+ if (envoy_config_core_v3_SocketAddress_resolver_name(socket_address)
2863
+ .size != 0) {
2864
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2865
+ absl::StrCat(
2866
+ cluster_name,
2867
+ ": LOGICAL_DNS clusters must NOT have a custom resolver "
2868
+ "name set")
2869
+ .c_str()));
2870
+ resource_names_failed->insert(cluster_name);
2871
+ continue;
2872
+ }
2873
+ absl::string_view address_str = UpbStringToAbsl(
2874
+ envoy_config_core_v3_SocketAddress_address(socket_address));
2875
+ if (address_str.empty()) {
2876
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2877
+ absl::StrCat(cluster_name, ": SocketAddress address field not set")
2878
+ .c_str()));
2879
+ resource_names_failed->insert(cluster_name);
2880
+ continue;
2881
+ }
2882
+ if (!envoy_config_core_v3_SocketAddress_has_port_value(socket_address)) {
2883
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2884
+ absl::StrCat(cluster_name,
2885
+ ": SocketAddress port_value field not set")
2886
+ .c_str()));
2887
+ resource_names_failed->insert(cluster_name);
2888
+ continue;
2889
+ }
2890
+ cds_update.dns_hostname = JoinHostPort(
2891
+ address_str,
2892
+ envoy_config_core_v3_SocketAddress_port_value(socket_address));
2755
2893
  } else {
2756
2894
  if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
2757
2895
  const envoy_config_cluster_v3_Cluster_CustomClusterType*
@@ -2815,75 +2953,61 @@ grpc_error_handle CdsResponseParse(
2815
2953
  // Record ring hash lb config
2816
2954
  auto* ring_hash_config =
2817
2955
  envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
2818
- if (ring_hash_config == nullptr) {
2819
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2820
- absl::StrCat(cluster_name,
2821
- ": ring hash lb config required but not present.")
2822
- .c_str()));
2823
- resource_names_failed->insert(cluster_name);
2824
- continue;
2825
- }
2826
- const google_protobuf_UInt64Value* max_ring_size =
2827
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
2828
- ring_hash_config);
2829
- if (max_ring_size != nullptr) {
2830
- cds_update.max_ring_size =
2831
- google_protobuf_UInt64Value_value(max_ring_size);
2832
- if (cds_update.max_ring_size > 8388608 ||
2833
- cds_update.max_ring_size == 0) {
2834
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2835
- absl::StrCat(
2836
- cluster_name,
2837
- ": max_ring_size is not in the range of 1 to 8388608.")
2838
- .c_str()));
2839
- resource_names_failed->insert(cluster_name);
2840
- continue;
2956
+ if (ring_hash_config != nullptr) {
2957
+ const google_protobuf_UInt64Value* max_ring_size =
2958
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
2959
+ ring_hash_config);
2960
+ if (max_ring_size != nullptr) {
2961
+ cds_update.max_ring_size =
2962
+ google_protobuf_UInt64Value_value(max_ring_size);
2963
+ if (cds_update.max_ring_size > 8388608 ||
2964
+ cds_update.max_ring_size == 0) {
2965
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2966
+ absl::StrCat(
2967
+ cluster_name,
2968
+ ": max_ring_size is not in the range of 1 to 8388608.")
2969
+ .c_str()));
2970
+ resource_names_failed->insert(cluster_name);
2971
+ continue;
2972
+ }
2841
2973
  }
2842
- }
2843
- const google_protobuf_UInt64Value* min_ring_size =
2844
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
2845
- ring_hash_config);
2846
- if (min_ring_size != nullptr) {
2847
- cds_update.min_ring_size =
2848
- google_protobuf_UInt64Value_value(min_ring_size);
2849
- if (cds_update.min_ring_size > 8388608 ||
2850
- cds_update.min_ring_size == 0) {
2851
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2852
- absl::StrCat(
2853
- cluster_name,
2854
- ": min_ring_size is not in the range of 1 to 8388608.")
2855
- .c_str()));
2856
- resource_names_failed->insert(cluster_name);
2857
- continue;
2974
+ const google_protobuf_UInt64Value* min_ring_size =
2975
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
2976
+ ring_hash_config);
2977
+ if (min_ring_size != nullptr) {
2978
+ cds_update.min_ring_size =
2979
+ google_protobuf_UInt64Value_value(min_ring_size);
2980
+ if (cds_update.min_ring_size > 8388608 ||
2981
+ cds_update.min_ring_size == 0) {
2982
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2983
+ absl::StrCat(
2984
+ cluster_name,
2985
+ ": min_ring_size is not in the range of 1 to 8388608.")
2986
+ .c_str()));
2987
+ resource_names_failed->insert(cluster_name);
2988
+ continue;
2989
+ }
2990
+ if (cds_update.min_ring_size > cds_update.max_ring_size) {
2991
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2992
+ absl::StrCat(
2993
+ cluster_name,
2994
+ ": min_ring_size cannot be greater than max_ring_size.")
2995
+ .c_str()));
2996
+ resource_names_failed->insert(cluster_name);
2997
+ continue;
2998
+ }
2858
2999
  }
2859
- if (cds_update.min_ring_size > cds_update.max_ring_size) {
3000
+ if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
3001
+ ring_hash_config) !=
3002
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
2860
3003
  errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2861
- absl::StrCat(
2862
- cluster_name,
2863
- ": min_ring_size cannot be greater than max_ring_size.")
3004
+ absl::StrCat(cluster_name,
3005
+ ": ring hash lb config has invalid hash function.")
2864
3006
  .c_str()));
2865
3007
  resource_names_failed->insert(cluster_name);
2866
3008
  continue;
2867
3009
  }
2868
3010
  }
2869
- if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
2870
- ring_hash_config) ==
2871
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
2872
- cds_update.hash_function = XdsApi::CdsUpdate::HashFunction::XX_HASH;
2873
- } else if (
2874
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
2875
- ring_hash_config) ==
2876
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_MURMUR_HASH_2) {
2877
- cds_update.hash_function =
2878
- XdsApi::CdsUpdate::HashFunction::MURMUR_HASH_2;
2879
- } else {
2880
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2881
- absl::StrCat(cluster_name,
2882
- ": ring hash lb config has invalid hash function.")
2883
- .c_str()));
2884
- resource_names_failed->insert(cluster_name);
2885
- continue;
2886
- }
2887
3011
  } else {
2888
3012
  errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2889
3013
  absl::StrCat(cluster_name, ": LB policy is not supported.").c_str()));
@@ -3014,13 +3138,28 @@ grpc_error_handle ServerAddressParseAndAppend(
3014
3138
  if (GPR_UNLIKELY(port >> 16) != 0) {
3015
3139
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port.");
3016
3140
  }
3141
+ // Find load_balancing_weight for the endpoint.
3142
+ const google_protobuf_UInt32Value* load_balancing_weight =
3143
+ envoy_config_endpoint_v3_LbEndpoint_load_balancing_weight(lb_endpoint);
3144
+ const int32_t weight =
3145
+ load_balancing_weight != nullptr
3146
+ ? google_protobuf_UInt32Value_value(load_balancing_weight)
3147
+ : 500;
3148
+ if (weight == 0) {
3149
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3150
+ "Invalid endpoint weight of 0.");
3151
+ }
3017
3152
  // Populate grpc_resolved_address.
3018
3153
  grpc_resolved_address addr;
3019
3154
  grpc_error_handle error =
3020
3155
  grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
3021
3156
  if (error != GRPC_ERROR_NONE) return error;
3022
3157
  // Append the address to the list.
3023
- list->emplace_back(addr, nullptr);
3158
+ std::map<const char*, std::unique_ptr<ServerAddress::AttributeInterface>>
3159
+ attributes;
3160
+ attributes[ServerAddressWeightAttribute::kServerAddressWeightAttributeKey] =
3161
+ absl::make_unique<ServerAddressWeightAttribute>(weight);
3162
+ list->emplace_back(addr, nullptr, std::move(attributes));
3024
3163
  return GRPC_ERROR_NONE;
3025
3164
  }
3026
3165
 
@@ -3362,7 +3501,8 @@ grpc_slice XdsApi::CreateLrsInitialRequest(
3362
3501
  envoy_config_core_v3_Node* node_msg =
3363
3502
  envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
3364
3503
  arena.ptr());
3365
- PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
3504
+ PopulateNode(context, node_, build_version_, user_agent_name_,
3505
+ user_agent_version_, node_msg);
3366
3506
  envoy_config_core_v3_Node_add_client_features(
3367
3507
  node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
3368
3508
  arena.ptr());
@@ -3759,7 +3899,8 @@ std::string XdsApi::AssembleClientConfig(
3759
3899
  arena.ptr());
3760
3900
  const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
3761
3901
  true};
3762
- PopulateNode(context, node_, build_version_, user_agent_name_, node);
3902
+ PopulateNode(context, node_, build_version_, user_agent_name_,
3903
+ user_agent_version_, node);
3763
3904
  // Dump each xDS-type config into PerXdsConfig
3764
3905
  for (auto& p : resource_type_metadata_map) {
3765
3906
  absl::string_view type_url = p.first;