grpc 1.55.3 → 1.56.0.pre3

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 (385) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +100 -70
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/module.modulemap +2 -0
  6. data/include/grpc/support/json.h +218 -0
  7. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  8. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  9. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  10. data/src/core/ext/filters/client_channel/client_channel.cc +82 -98
  11. data/src/core/ext/filters/client_channel/client_channel.h +4 -0
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  13. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  14. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  15. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +52 -20
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +32 -39
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  40. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  42. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  43. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  45. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  46. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  47. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  48. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  49. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  50. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  51. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  52. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  54. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +543 -567
  56. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +9 -150
  57. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +32 -46
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +5 -18
  59. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  60. data/src/core/ext/transport/chttp2/transport/parsing.cc +12 -12
  61. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  62. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  63. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  64. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  65. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  66. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  67. data/src/core/ext/xds/xds_api.cc +9 -6
  68. data/src/core/ext/xds/xds_api.h +3 -2
  69. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  70. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  71. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  72. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  73. data/src/core/ext/xds/xds_client.cc +5 -4
  74. data/src/core/ext/xds/xds_client_stats.h +1 -1
  75. data/src/core/ext/xds/xds_cluster.cc +20 -19
  76. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  77. data/src/core/ext/xds/xds_common_types.cc +3 -1
  78. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  79. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  80. data/src/core/ext/xds/xds_http_filters.h +4 -2
  81. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  82. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  83. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  84. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  85. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  86. data/src/core/ext/xds/xds_listener.cc +1 -0
  87. data/src/core/ext/xds/xds_route_config.cc +40 -3
  88. data/src/core/ext/xds/xds_routing.cc +2 -2
  89. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  90. data/src/core/lib/avl/avl.h +5 -0
  91. data/src/core/lib/backoff/random_early_detection.h +0 -5
  92. data/src/core/lib/channel/channel_args.cc +80 -22
  93. data/src/core/lib/channel/channel_args.h +34 -1
  94. data/src/core/lib/channel/channel_trace.cc +16 -12
  95. data/src/core/lib/channel/channelz.cc +159 -132
  96. data/src/core/lib/channel/channelz.h +42 -35
  97. data/src/core/lib/channel/channelz_registry.cc +23 -20
  98. data/src/core/lib/channel/connected_channel.cc +17 -6
  99. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  100. data/src/core/lib/channel/promise_based_filter.h +2 -0
  101. data/src/core/lib/compression/compression_internal.cc +2 -5
  102. data/src/core/lib/config/config_vars.cc +20 -18
  103. data/src/core/lib/config/config_vars.h +4 -4
  104. data/src/core/lib/config/load_config.cc +13 -0
  105. data/src/core/lib/config/load_config.h +6 -0
  106. data/src/core/lib/debug/event_log.h +1 -1
  107. data/src/core/lib/debug/stats_data.h +1 -1
  108. data/src/core/lib/debug/trace.cc +24 -55
  109. data/src/core/lib/debug/trace.h +3 -1
  110. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  111. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  112. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  113. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  114. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  115. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  116. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  117. data/src/core/lib/event_engine/poller.h +2 -2
  118. data/src/core/lib/event_engine/posix.h +4 -0
  119. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  120. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  121. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  122. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +3 -2
  123. data/src/core/lib/event_engine/posix_engine/posix_engine.h +1 -2
  124. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +4 -33
  125. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +7 -11
  126. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  127. data/src/core/lib/event_engine/shim.cc +7 -1
  128. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  129. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  130. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  131. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  132. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  133. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  134. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  135. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  136. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  137. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  138. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  139. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  140. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  141. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  142. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  143. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  144. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  145. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  146. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  147. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  148. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  149. data/src/core/lib/experiments/config.cc +38 -7
  150. data/src/core/lib/experiments/config.h +16 -0
  151. data/src/core/lib/experiments/experiments.cc +67 -20
  152. data/src/core/lib/experiments/experiments.h +27 -21
  153. data/src/core/lib/gpr/log_internal.h +55 -0
  154. data/src/core/lib/gprpp/crash.cc +10 -0
  155. data/src/core/lib/gprpp/crash.h +3 -0
  156. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  157. data/src/core/lib/gprpp/per_cpu.h +29 -6
  158. data/src/core/lib/gprpp/time.cc +1 -0
  159. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  160. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  161. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  162. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  163. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  164. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  165. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  166. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  167. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  168. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  169. data/src/core/lib/iomgr/socket_windows.h +9 -2
  170. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  171. data/src/core/lib/iomgr/tcp_server_posix.cc +156 -140
  172. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -13
  173. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +0 -21
  174. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  175. data/src/core/lib/json/json.h +2 -166
  176. data/src/core/lib/json/json_object_loader.cc +8 -9
  177. data/src/core/lib/json/json_object_loader.h +25 -18
  178. data/src/core/lib/json/json_reader.cc +13 -6
  179. data/src/core/lib/json/json_util.cc +6 -11
  180. data/src/core/lib/json/json_writer.cc +7 -8
  181. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  182. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  183. data/src/core/lib/matchers/matchers.cc +3 -4
  184. data/src/core/lib/matchers/matchers.h +2 -1
  185. data/src/core/lib/promise/activity.cc +5 -0
  186. data/src/core/lib/promise/activity.h +10 -0
  187. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  188. data/src/core/lib/promise/party.cc +31 -13
  189. data/src/core/lib/promise/party.h +11 -2
  190. data/src/core/lib/promise/pipe.h +9 -2
  191. data/src/core/lib/promise/prioritized_race.h +95 -0
  192. data/src/core/lib/promise/sleep.cc +2 -1
  193. data/src/core/lib/resolver/server_address.cc +0 -8
  194. data/src/core/lib/resolver/server_address.h +0 -6
  195. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  196. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  197. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  198. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  199. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  200. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  201. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  202. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  203. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  204. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  205. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  206. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  207. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  208. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  209. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  210. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  211. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  212. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  213. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  214. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  215. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  216. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  217. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  218. data/src/core/lib/security/util/json_util.cc +1 -0
  219. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  220. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  221. data/src/core/lib/surface/call.cc +38 -23
  222. data/src/core/lib/surface/completion_queue.cc +6 -2
  223. data/src/core/lib/surface/validate_metadata.cc +22 -37
  224. data/src/core/lib/surface/validate_metadata.h +3 -13
  225. data/src/core/lib/surface/version.cc +2 -2
  226. data/src/core/lib/transport/batch_builder.cc +15 -12
  227. data/src/core/lib/transport/batch_builder.h +39 -35
  228. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  229. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  230. data/src/ruby/ext/grpc/extconf.rb +8 -9
  231. data/src/ruby/lib/grpc/version.rb +1 -1
  232. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  233. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  234. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  235. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  236. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  237. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  238. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  239. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  240. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  241. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  242. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  243. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  244. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  245. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  246. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  247. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  248. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  249. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  250. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  251. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  252. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  253. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  254. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  255. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  262. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  271. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  278. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  279. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  280. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  281. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  282. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  283. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  284. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  286. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  288. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  289. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  290. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  291. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  292. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  293. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  297. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  298. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  299. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  300. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  301. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  302. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  303. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  304. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  305. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  306. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  307. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  308. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  309. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  310. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  311. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  312. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  313. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  314. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  315. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  316. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  317. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  318. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  319. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  320. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  321. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  322. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  323. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  324. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  325. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  326. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  327. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  328. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  329. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  330. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  331. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  332. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  333. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  334. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  335. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  336. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  337. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  338. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  339. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  340. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  341. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  342. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  343. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  344. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  345. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  346. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  347. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  348. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  349. data/third_party/cares/cares/include/ares.h +23 -1
  350. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  351. data/third_party/cares/cares/include/ares_rules.h +2 -2
  352. data/third_party/cares/cares/include/ares_version.h +3 -3
  353. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  354. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  355. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  356. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  357. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  358. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  359. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  360. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  361. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  362. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  363. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  364. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  365. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  366. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  367. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  368. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  369. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  370. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  371. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  372. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  373. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  374. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  375. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  376. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  377. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  378. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  379. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  380. metadata +50 -16
  381. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  382. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  383. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +0 -176
  384. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +0 -325
  385. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -31,7 +31,50 @@
31
31
  namespace grpc_core {
32
32
 
33
33
  namespace {
34
+
34
35
  constexpr uint16_t kMaxWeight = std::numeric_limits<uint16_t>::max();
36
+
37
+ // Assuming the mean of all known weights is M, StaticStrideScheduler will cap
38
+ // from above all known weights that are bigger than M*kMaxRatio (to
39
+ // M*kMaxRatio).
40
+ //
41
+ // This is done to limit the number of rounds for picks.
42
+ constexpr double kMaxRatio = 10;
43
+
44
+ // Assuming the mean of all known weights is M, StaticStrideScheduler will cap
45
+ // from below all known weights to M*kMinRatio.
46
+ //
47
+ // This is done as a performance optimization for edge cases when channels with
48
+ // large weights are non-accepting (and thus WeightedRoundRobin will retry
49
+ // picking them over and over again), and there are also channels with near-zero
50
+ // weights that are possibly accepting. In this case, without kMinRatio, it
51
+ // would potentially require WeightedRoundRobin to perform thousands of picks
52
+ // until it gets a single channel with near-zero weight. This was a part of what
53
+ // hapenned in b/276292666.
54
+ //
55
+ // The current value of 0.01 was chosen without any experimenting. It should
56
+ // ensure that WeightedRoundRobin doesn't do much more than an order of 100
57
+ // picks of non-accepting channels with high weights in such corner cases. But
58
+ // it also makes WeightedRoundRobin to send slightly more requests to
59
+ // potentially very bad tasks (that would have near-zero weights) than zero.
60
+ // This is not necesserily a downside, though. Perhaps this is not a problem at
61
+ // all and we should increase this value (to 0.05 or 0.1) to save CPU cycles.
62
+ //
63
+ // Note that this class treats weights that are exactly equal to zero as unknown
64
+ // and thus needing to be replaced with M. This behavior itself makes sense
65
+ // (fresh channels without feedback information will get an average flow of
66
+ // requests). However, it follows from this that this class will replace weight
67
+ // = 0 with M, but weight = epsilon with M*kMinRatio, and this step function is
68
+ // logically faulty. A demonstration of this is that the function that computes
69
+ // weights in WeightedRoundRobin
70
+ // (http://google3/production/rpc/stubs/core/loadbalancing/weightedroundrobin.cc;l=324-325;rcl=514986476)
71
+ // will cap some epsilon values to zero. There should be a clear distinction
72
+ // between "task is new, weight is unknown" and "task is unhealthy, weight is
73
+ // very low". A better solution would be to not mix "unknown" and "weight" into
74
+ // a single value but represent weights as std::optional<float> or, if memory
75
+ // usage is a concern, use NaN as the indicator of unknown weight.
76
+ constexpr double kMinRatio = 0.01;
77
+
35
78
  } // namespace
36
79
 
37
80
  absl::optional<StaticStrideScheduler> StaticStrideScheduler::Make(
@@ -45,10 +88,10 @@ absl::optional<StaticStrideScheduler> StaticStrideScheduler::Make(
45
88
  const size_t n = float_weights.size();
46
89
  size_t num_zero_weight_channels = 0;
47
90
  double sum = 0;
48
- float max = 0;
91
+ float unscaled_max = 0;
49
92
  for (const float weight : float_weights) {
50
93
  sum += weight;
51
- max = std::max(max, weight);
94
+ unscaled_max = std::max(unscaled_max, weight);
52
95
  if (weight == 0) {
53
96
  ++num_zero_weight_channels;
54
97
  }
@@ -59,6 +102,13 @@ absl::optional<StaticStrideScheduler> StaticStrideScheduler::Make(
59
102
  // Mean of non-zero weights before scaling to `kMaxWeight`.
60
103
  const double unscaled_mean =
61
104
  sum / static_cast<double>(n - num_zero_weight_channels);
105
+ const double ratio = unscaled_max / unscaled_mean;
106
+
107
+ // Adjust max value such that ratio does not exceed kMaxRatio. This should
108
+ // ensure that we on average do at most kMaxRatio rounds for picks.
109
+ if (ratio > kMaxRatio) {
110
+ unscaled_max = kMaxRatio * unscaled_mean;
111
+ }
62
112
 
63
113
  // Scale weights such that the largest is equal to `kMaxWeight`. This should
64
114
  // be accurate enough once we convert to an integer. Quantisation errors won't
@@ -66,15 +116,35 @@ absl::optional<StaticStrideScheduler> StaticStrideScheduler::Make(
66
116
  // TODO(b/190488683): it may be more stable over updates if we try to keep
67
117
  // `scaling_factor` consistent, and only change it when we can't accurately
68
118
  // represent the new weights.
69
- const double scaling_factor = kMaxWeight / max;
119
+ const double scaling_factor = kMaxWeight / unscaled_max;
120
+
121
+ // Note that since we cap the weights to stay within kMaxRatio, `mean` might
122
+ // not match the actual mean of the values that end up in the scheduler.
70
123
  const uint16_t mean = std::lround(scaling_factor * unscaled_mean);
71
124
 
125
+ // We compute weight_lower_bound and cap it to 1 from below so that in the
126
+ // worst case we represent tiny weights as 1 but not as 0 (which would cause
127
+ // an infinite loop as in b/276292666). This capping to 1 is probably only
128
+ // useful in case someone misconfigures kMinRatio to be very small.
129
+ //
130
+ // NOMUTANTS -- We have tests for this expression, but they are not precise
131
+ // enough to catch errors of plus/minus 1, what mutation testing does.
132
+ const uint16_t weight_lower_bound =
133
+ std::max(static_cast<uint16_t>(1),
134
+ static_cast<uint16_t>(std::lround(mean * kMinRatio)));
135
+
72
136
  std::vector<uint16_t> weights;
73
137
  weights.reserve(n);
74
138
  for (size_t i = 0; i < n; ++i) {
75
- weights.push_back(float_weights[i] == 0
76
- ? mean
77
- : std::lround(float_weights[i] * scaling_factor));
139
+ if (float_weights[i] == 0) { // Weight is unknown.
140
+ weights.push_back(mean);
141
+ } else {
142
+ const double float_weight_capped_from_above =
143
+ std::min(float_weights[i], unscaled_max);
144
+ const uint16_t weight =
145
+ std::lround(float_weight_capped_from_above * scaling_factor);
146
+ weights.push_back(std::max(weight, weight_lower_bound));
147
+ }
78
148
  }
79
149
 
80
150
  GPR_ASSERT(weights.size() == float_weights.size());
@@ -59,6 +59,7 @@
59
59
  #include "src/core/lib/gprpp/sync.h"
60
60
  #include "src/core/lib/gprpp/time.h"
61
61
  #include "src/core/lib/gprpp/validation_errors.h"
62
+ #include "src/core/lib/gprpp/work_serializer.h"
62
63
  #include "src/core/lib/iomgr/exec_ctx.h"
63
64
  #include "src/core/lib/iomgr/resolved_address.h"
64
65
  #include "src/core/lib/json/json.h"
@@ -157,7 +158,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy {
157
158
  : wrr_(std::move(wrr)), key_(std::move(key)) {}
158
159
  ~AddressWeight() override;
159
160
 
160
- void MaybeUpdateWeight(double qps, double eps, double cpu_utilization,
161
+ void MaybeUpdateWeight(double qps, double eps, double utilization,
161
162
  float error_utilization_penalty);
162
163
 
163
164
  float GetWeight(Timestamp now, Duration weight_expiration_period,
@@ -271,6 +272,10 @@ class WeightedRoundRobin : public LoadBalancingPolicy {
271
272
  absl::Status status_for_tf);
272
273
 
273
274
  private:
275
+ std::shared_ptr<WorkSerializer> work_serializer() const override {
276
+ return static_cast<WeightedRoundRobin*>(policy())->work_serializer();
277
+ }
278
+
274
279
  std::string CountersString() const {
275
280
  return absl::StrCat("num_subchannels=", num_subchannels(),
276
281
  " num_ready=", num_ready_,
@@ -335,11 +340,7 @@ class WeightedRoundRobin : public LoadBalancingPolicy {
335
340
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(&timer_mu_);
336
341
 
337
342
  RefCountedPtr<WeightedRoundRobin> wrr_;
338
- const bool use_per_rpc_utilization_;
339
- const Duration weight_update_period_;
340
- const Duration weight_expiration_period_;
341
- const Duration blackout_period_;
342
- const float error_utilization_penalty_;
343
+ RefCountedPtr<WeightedRoundRobinConfig> config_;
343
344
  std::vector<SubchannelInfo> subchannels_;
344
345
 
345
346
  Mutex scheduler_mu_;
@@ -397,23 +398,23 @@ WeightedRoundRobin::AddressWeight::~AddressWeight() {
397
398
  }
398
399
 
399
400
  void WeightedRoundRobin::AddressWeight::MaybeUpdateWeight(
400
- double qps, double eps, double cpu_utilization,
401
+ double qps, double eps, double utilization,
401
402
  float error_utilization_penalty) {
402
403
  // Compute weight.
403
404
  float weight = 0;
404
- if (qps > 0 && cpu_utilization > 0) {
405
+ if (qps > 0 && utilization > 0) {
405
406
  double penalty = 0.0;
406
407
  if (eps > 0 && error_utilization_penalty > 0) {
407
408
  penalty = eps / qps * error_utilization_penalty;
408
409
  }
409
- weight = qps / (cpu_utilization + penalty);
410
+ weight = qps / (utilization + penalty);
410
411
  }
411
412
  if (weight == 0) {
412
413
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
413
414
  gpr_log(GPR_INFO,
414
- "[WRR %p] subchannel %s: qps=%f, eps=%f, cpu_utilization=%f: "
415
+ "[WRR %p] subchannel %s: qps=%f, eps=%f, utilization=%f: "
415
416
  "error_util_penalty=%f, weight=%f (not updating)",
416
- wrr_.get(), key_.c_str(), qps, eps, cpu_utilization,
417
+ wrr_.get(), key_.c_str(), qps, eps, utilization,
417
418
  error_utilization_penalty, weight);
418
419
  }
419
420
  return;
@@ -423,10 +424,10 @@ void WeightedRoundRobin::AddressWeight::MaybeUpdateWeight(
423
424
  MutexLock lock(&mu_);
424
425
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
425
426
  gpr_log(GPR_INFO,
426
- "[WRR %p] subchannel %s: qps=%f, eps=%f, cpu_utilization=%f "
427
+ "[WRR %p] subchannel %s: qps=%f, eps=%f, utilization=%f "
427
428
  "error_util_penalty=%f : setting weight=%f weight_=%f now=%s "
428
429
  "last_update_time_=%s non_empty_since_=%s",
429
- wrr_.get(), key_.c_str(), qps, eps, cpu_utilization,
430
+ wrr_.get(), key_.c_str(), qps, eps, utilization,
430
431
  error_utilization_penalty, weight, weight_, now.ToString().c_str(),
431
432
  last_update_time_.ToString().c_str(),
432
433
  non_empty_since_.ToString().c_str());
@@ -482,14 +483,16 @@ void WeightedRoundRobin::Picker::SubchannelCallTracker::Finish(
482
483
  args.backend_metric_accessor->GetBackendMetricData();
483
484
  double qps = 0;
484
485
  double eps = 0;
485
- double cpu_utilization = 0;
486
+ double utilization = 0;
486
487
  if (backend_metric_data != nullptr) {
487
488
  qps = backend_metric_data->qps;
488
489
  eps = backend_metric_data->eps;
489
- cpu_utilization = backend_metric_data->cpu_utilization;
490
+ utilization = backend_metric_data->application_utilization;
491
+ if (utilization <= 0) {
492
+ utilization = backend_metric_data->cpu_utilization;
493
+ }
490
494
  }
491
- weight_->MaybeUpdateWeight(qps, eps, cpu_utilization,
492
- error_utilization_penalty_);
495
+ weight_->MaybeUpdateWeight(qps, eps, utilization, error_utilization_penalty_);
493
496
  }
494
497
 
495
498
  //
@@ -500,11 +503,7 @@ WeightedRoundRobin::Picker::Picker(
500
503
  RefCountedPtr<WeightedRoundRobin> wrr,
501
504
  WeightedRoundRobinSubchannelList* subchannel_list)
502
505
  : wrr_(std::move(wrr)),
503
- use_per_rpc_utilization_(!wrr_->config_->enable_oob_load_report()),
504
- weight_update_period_(wrr_->config_->weight_update_period()),
505
- weight_expiration_period_(wrr_->config_->weight_expiration_period()),
506
- blackout_period_(wrr_->config_->blackout_period()),
507
- error_utilization_penalty_(wrr_->config_->error_utilization_penalty()),
506
+ config_(wrr_->config_),
508
507
  last_picked_index_(absl::Uniform<size_t>(wrr_->bit_gen_)) {
509
508
  for (size_t i = 0; i < subchannel_list->num_subchannels(); ++i) {
510
509
  WeightedRoundRobinSubchannelData* sd = subchannel_list->subchannel(i);
@@ -543,9 +542,9 @@ WeightedRoundRobin::PickResult WeightedRoundRobin::Picker::Pick(
543
542
  auto& subchannel_info = subchannels_[index];
544
543
  // Collect per-call utilization data if needed.
545
544
  std::unique_ptr<SubchannelCallTrackerInterface> subchannel_call_tracker;
546
- if (use_per_rpc_utilization_) {
545
+ if (!config_->enable_oob_load_report()) {
547
546
  subchannel_call_tracker = std::make_unique<SubchannelCallTracker>(
548
- subchannel_info.weight, error_utilization_penalty_);
547
+ subchannel_info.weight, config_->error_utilization_penalty());
549
548
  }
550
549
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
551
550
  gpr_log(GPR_INFO,
@@ -577,7 +576,7 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() {
577
576
  weights.reserve(subchannels_.size());
578
577
  for (const auto& subchannel : subchannels_) {
579
578
  weights.push_back(subchannel.weight->GetWeight(
580
- now, weight_expiration_period_, blackout_period_));
579
+ now, config_->weight_expiration_period(), config_->blackout_period()));
581
580
  }
582
581
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
583
582
  gpr_log(GPR_INFO, "[WRR %p picker %p] new weights: %s", wrr_.get(), this,
@@ -604,7 +603,7 @@ void WeightedRoundRobin::Picker::BuildSchedulerAndStartTimerLocked() {
604
603
  // Start timer.
605
604
  WeakRefCountedPtr<Picker> self = WeakRef();
606
605
  timer_handle_ = wrr_->channel_control_helper()->GetEventEngine()->RunAfter(
607
- weight_update_period_, [self = std::move(self)]() mutable {
606
+ config_->weight_update_period(), [self = std::move(self)]() mutable {
608
607
  ApplicationCallbackExecCtx callback_exec_ctx;
609
608
  ExecCtx exec_ctx;
610
609
  {
@@ -724,12 +723,9 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) {
724
723
  return status;
725
724
  }
726
725
  // Otherwise, if this is the initial update, immediately promote it to
727
- // subchannel_list_ and report CONNECTING.
726
+ // subchannel_list_.
728
727
  if (subchannel_list_.get() == nullptr) {
729
728
  subchannel_list_ = std::move(latest_pending_subchannel_list_);
730
- channel_control_helper()->UpdateState(
731
- GRPC_CHANNEL_CONNECTING, absl::Status(),
732
- MakeRefCounted<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker")));
733
729
  }
734
730
  return absl::OkStatus();
735
731
  }
@@ -853,9 +849,12 @@ void WeightedRoundRobin::WeightedRoundRobinSubchannelList::
853
849
 
854
850
  void WeightedRoundRobin::WeightedRoundRobinSubchannelData::OobWatcher::
855
851
  OnBackendMetricReport(const BackendMetricData& backend_metric_data) {
852
+ double utilization = backend_metric_data.application_utilization;
853
+ if (utilization <= 0) {
854
+ utilization = backend_metric_data.cpu_utilization;
855
+ }
856
856
  weight_->MaybeUpdateWeight(backend_metric_data.qps, backend_metric_data.eps,
857
- backend_metric_data.cpu_utilization,
858
- error_utilization_penalty_);
857
+ utilization, error_utilization_penalty_);
859
858
  }
860
859
 
861
860
  //
@@ -987,13 +986,7 @@ class WeightedRoundRobinFactory : public LoadBalancingPolicyFactory {
987
986
 
988
987
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
989
988
  ParseLoadBalancingConfig(const Json& json) const override {
990
- if (json.type() == Json::Type::kNull) {
991
- return absl::InvalidArgumentError(
992
- "field:loadBalancingPolicy error:weighted_round_robin policy "
993
- "requires configuration. Please use loadBalancingConfig field of "
994
- "service config instead.");
995
- }
996
- return LoadRefCountedFromJson<WeightedRoundRobinConfig>(
989
+ return LoadFromJson<RefCountedPtr<WeightedRoundRobinConfig>>(
997
990
  json, JsonArgs(),
998
991
  "errors validating weighted_round_robin LB policy config");
999
992
  }
@@ -519,7 +519,9 @@ void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::OnTimerLocked() {
519
519
  WeightedTargetLb::WeightedChild::WeightedChild(
520
520
  RefCountedPtr<WeightedTargetLb> weighted_target_policy,
521
521
  const std::string& name)
522
- : weighted_target_policy_(std::move(weighted_target_policy)), name_(name) {
522
+ : weighted_target_policy_(std::move(weighted_target_policy)),
523
+ name_(name),
524
+ picker_(MakeRefCounted<QueuePicker>(nullptr)) {
523
525
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_weighted_target_trace)) {
524
526
  gpr_log(GPR_INFO, "[weighted_target_lb %p] created WeightedChild %p for %s",
525
527
  weighted_target_policy_.get(), this, name_.c_str());
@@ -764,15 +766,7 @@ class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
764
766
 
765
767
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
766
768
  ParseLoadBalancingConfig(const Json& json) const override {
767
- if (json.type() == Json::Type::kNull) {
768
- // weighted_target was mentioned as a policy in the deprecated
769
- // loadBalancingPolicy field or in the client API.
770
- return absl::InvalidArgumentError(
771
- "field:loadBalancingPolicy error:weighted_target policy requires "
772
- "configuration. Please use loadBalancingConfig field of service "
773
- "config instead.");
774
- }
775
- return LoadRefCountedFromJson<WeightedTargetLbConfig>(
769
+ return LoadFromJson<RefCountedPtr<WeightedTargetLbConfig>>(
776
770
  json, JsonArgs(), "errors validating weighted_target LB policy config");
777
771
  }
778
772
  };
@@ -36,6 +36,7 @@
36
36
  #include <grpc/grpc.h>
37
37
  #include <grpc/grpc_security.h>
38
38
  #include <grpc/impl/connectivity_state.h>
39
+ #include <grpc/support/json.h>
39
40
  #include <grpc/support/log.h>
40
41
 
41
42
  #include "src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h"
@@ -406,59 +407,68 @@ absl::StatusOr<bool> CdsLb::GenerateDiscoveryMechanismForCluster(
406
407
  return !missing_cluster;
407
408
  }
408
409
  Json::Object mechanism = {
409
- {"clusterName", name},
410
- {"max_concurrent_requests", state.update->max_concurrent_requests},
410
+ {"clusterName", Json::FromString(name)},
411
+ {"max_concurrent_requests",
412
+ Json::FromNumber(state.update->max_concurrent_requests)},
411
413
  };
412
414
  if (state.update->outlier_detection.has_value()) {
413
415
  auto& outlier_detection_update = state.update->outlier_detection.value();
414
416
  Json::Object outlier_detection;
415
417
  outlier_detection["interval"] =
416
- outlier_detection_update.interval.ToJsonString();
417
- outlier_detection["baseEjectionTime"] =
418
- outlier_detection_update.base_ejection_time.ToJsonString();
419
- outlier_detection["maxEjectionTime"] =
420
- outlier_detection_update.max_ejection_time.ToJsonString();
418
+ Json::FromString(outlier_detection_update.interval.ToJsonString());
419
+ outlier_detection["baseEjectionTime"] = Json::FromString(
420
+ outlier_detection_update.base_ejection_time.ToJsonString());
421
+ outlier_detection["maxEjectionTime"] = Json::FromString(
422
+ outlier_detection_update.max_ejection_time.ToJsonString());
421
423
  outlier_detection["maxEjectionPercent"] =
422
- outlier_detection_update.max_ejection_percent;
424
+ Json::FromNumber(outlier_detection_update.max_ejection_percent);
423
425
  if (outlier_detection_update.success_rate_ejection.has_value()) {
424
- outlier_detection["successRateEjection"] = Json::Object{
426
+ outlier_detection["successRateEjection"] = Json::FromObject({
425
427
  {"stdevFactor",
426
- outlier_detection_update.success_rate_ejection->stdev_factor},
428
+ Json::FromNumber(
429
+ outlier_detection_update.success_rate_ejection->stdev_factor)},
427
430
  {"enforcementPercentage",
428
- outlier_detection_update.success_rate_ejection
429
- ->enforcement_percentage},
431
+ Json::FromNumber(outlier_detection_update.success_rate_ejection
432
+ ->enforcement_percentage)},
430
433
  {"minimumHosts",
431
- outlier_detection_update.success_rate_ejection->minimum_hosts},
434
+ Json::FromNumber(
435
+ outlier_detection_update.success_rate_ejection->minimum_hosts)},
432
436
  {"requestVolume",
433
- outlier_detection_update.success_rate_ejection->request_volume},
434
- };
437
+ Json::FromNumber(
438
+ outlier_detection_update.success_rate_ejection->request_volume)},
439
+ });
435
440
  }
436
441
  if (outlier_detection_update.failure_percentage_ejection.has_value()) {
437
- outlier_detection["failurePercentageEjection"] = Json::Object{
442
+ outlier_detection["failurePercentageEjection"] = Json::FromObject({
438
443
  {"threshold",
439
- outlier_detection_update.failure_percentage_ejection->threshold},
444
+ Json::FromNumber(outlier_detection_update
445
+ .failure_percentage_ejection->threshold)},
440
446
  {"enforcementPercentage",
441
- outlier_detection_update.failure_percentage_ejection
442
- ->enforcement_percentage},
447
+ Json::FromNumber(
448
+ outlier_detection_update.failure_percentage_ejection
449
+ ->enforcement_percentage)},
443
450
  {"minimumHosts",
444
- outlier_detection_update.failure_percentage_ejection->minimum_hosts},
445
- {"requestVolume", outlier_detection_update
446
- .failure_percentage_ejection->request_volume},
447
- };
451
+ Json::FromNumber(outlier_detection_update
452
+ .failure_percentage_ejection->minimum_hosts)},
453
+ {"requestVolume",
454
+ Json::FromNumber(outlier_detection_update
455
+ .failure_percentage_ejection->request_volume)},
456
+ });
448
457
  }
449
- mechanism["outlierDetection"] = std::move(outlier_detection);
458
+ mechanism["outlierDetection"] =
459
+ Json::FromObject(std::move(outlier_detection));
450
460
  }
451
461
  Match(
452
462
  state.update->type,
453
463
  [&](const XdsClusterResource::Eds& eds) {
454
- mechanism["type"] = "EDS";
464
+ mechanism["type"] = Json::FromString("EDS");
455
465
  if (!eds.eds_service_name.empty()) {
456
- mechanism["edsServiceName"] = eds.eds_service_name;
466
+ mechanism["edsServiceName"] = Json::FromString(eds.eds_service_name);
457
467
  }
458
468
  },
459
469
  [&](const XdsClusterResource::LogicalDns& logical_dns) {
460
- mechanism["type"] = "LOGICAL_DNS";
461
- mechanism["dnsHostname"] = logical_dns.hostname;
470
+ mechanism["type"] = Json::FromString("LOGICAL_DNS");
471
+ mechanism["dnsHostname"] = Json::FromString(logical_dns.hostname);
462
472
  },
463
473
  [&](const XdsClusterResource::Aggregate&) { GPR_ASSERT(0); });
464
474
  if (state.update->lrs_load_reporting_server.has_value()) {
@@ -468,11 +478,11 @@ absl::StatusOr<bool> CdsLb::GenerateDiscoveryMechanismForCluster(
468
478
  if (!state.update->override_host_statuses.empty()) {
469
479
  Json::Array status_list;
470
480
  for (const auto& status : state.update->override_host_statuses) {
471
- status_list.emplace_back(status.ToString());
481
+ status_list.emplace_back(Json::FromString(status.ToString()));
472
482
  }
473
- mechanism["overrideHostStatus"] = std::move(status_list);
483
+ mechanism["overrideHostStatus"] = Json::FromArray(std::move(status_list));
474
484
  }
475
- discovery_mechanisms->emplace_back(std::move(mechanism));
485
+ discovery_mechanisms->emplace_back(Json::FromObject(std::move(mechanism)));
476
486
  return true;
477
487
  }
478
488
 
@@ -514,15 +524,17 @@ void CdsLb::OnClusterChanged(const std::string& name,
514
524
  auto it = watchers_.find(config_->cluster());
515
525
  GPR_ASSERT(it != watchers_.end());
516
526
  // Construct config for child policy.
517
- Json json = Json::Array{
518
- Json::Object{
527
+ Json json = Json::FromArray({
528
+ Json::FromObject({
519
529
  {"xds_cluster_resolver_experimental",
520
- Json::Object{
521
- {"xdsLbPolicy", it->second.update->lb_policy_config},
522
- {"discoveryMechanisms", std::move(discovery_mechanisms)},
523
- }},
524
- },
525
- };
530
+ Json::FromObject({
531
+ {"xdsLbPolicy",
532
+ Json::FromArray(it->second.update->lb_policy_config)},
533
+ {"discoveryMechanisms",
534
+ Json::FromArray(std::move(discovery_mechanisms))},
535
+ })},
536
+ }),
537
+ });
526
538
  if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
527
539
  gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s",
528
540
  this, JsonDump(json, /*indent=*/1).c_str());
@@ -743,14 +755,7 @@ class CdsLbFactory : public LoadBalancingPolicyFactory {
743
755
 
744
756
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
745
757
  ParseLoadBalancingConfig(const Json& json) const override {
746
- if (json.type() == Json::Type::kNull) {
747
- // xds was mentioned as a policy in the deprecated loadBalancingPolicy
748
- // field or in the client API.
749
- return absl::InvalidArgumentError(
750
- "field:loadBalancingPolicy error:cds policy requires configuration. "
751
- "Please use loadBalancingConfig field of service config instead.");
752
- }
753
- return LoadRefCountedFromJson<CdsLbConfig>(
758
+ return LoadFromJson<RefCountedPtr<CdsLbConfig>>(
754
759
  json, JsonArgs(), "errors validating cds LB policy config");
755
760
  }
756
761
  };
@@ -777,15 +777,7 @@ class XdsClusterImplLbFactory : public LoadBalancingPolicyFactory {
777
777
 
778
778
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
779
779
  ParseLoadBalancingConfig(const Json& json) const override {
780
- if (json.type() == Json::Type::kNull) {
781
- // This policy was configured in the deprecated loadBalancingPolicy
782
- // field or in the client API.
783
- return absl::InvalidArgumentError(
784
- "field:loadBalancingPolicy error:xds_cluster_impl policy requires "
785
- "configuration. Please use loadBalancingConfig field of service "
786
- "config instead.");
787
- }
788
- return LoadRefCountedFromJson<XdsClusterImplLbConfig>(
780
+ return LoadFromJson<RefCountedPtr<XdsClusterImplLbConfig>>(
789
781
  json, JsonArgs(),
790
782
  "errors validating xds_cluster_impl LB policy config");
791
783
  }
@@ -19,6 +19,7 @@
19
19
  #include <stddef.h>
20
20
 
21
21
  #include <algorithm>
22
+ #include <functional>
22
23
  #include <map>
23
24
  #include <memory>
24
25
  #include <string>
@@ -123,8 +124,8 @@ class XdsClusterManagerLb : public LoadBalancingPolicy {
123
124
  class ClusterPicker : public SubchannelPicker {
124
125
  public:
125
126
  // Maintains a map of cluster names to pickers.
126
- using ClusterMap =
127
- std::map<std::string /*cluster_name*/, RefCountedPtr<SubchannelPicker>>;
127
+ using ClusterMap = std::map<std::string /*cluster_name*/,
128
+ RefCountedPtr<SubchannelPicker>, std::less<>>;
128
129
 
129
130
  // It is required that the keys of cluster_map have to live at least as long
130
131
  // as the ClusterPicker instance.
@@ -199,7 +200,7 @@ class XdsClusterManagerLb : public LoadBalancingPolicy {
199
200
  OrphanablePtr<LoadBalancingPolicy> child_policy_;
200
201
 
201
202
  RefCountedPtr<SubchannelPicker> picker_;
202
- grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;
203
+ grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_CONNECTING;
203
204
 
204
205
  // States for delayed removal.
205
206
  absl::optional<EventEngine::TaskHandle> delayed_removal_timer_handle_;
@@ -230,9 +231,13 @@ class XdsClusterManagerLb : public LoadBalancingPolicy {
230
231
  XdsClusterManagerLb::PickResult XdsClusterManagerLb::ClusterPicker::Pick(
231
232
  PickArgs args) {
232
233
  auto* call_state = static_cast<ClientChannelLbCallState*>(args.call_state);
233
- auto cluster_name =
234
- call_state->GetCallAttribute(XdsClusterAttributeTypeName());
235
- auto it = cluster_map_.find(std::string(cluster_name));
234
+ auto* cluster_name_attribute = static_cast<XdsClusterAttribute*>(
235
+ call_state->GetCallAttribute(XdsClusterAttribute::TypeName()));
236
+ absl::string_view cluster_name;
237
+ if (cluster_name_attribute != nullptr) {
238
+ cluster_name = cluster_name_attribute->cluster();
239
+ }
240
+ auto it = cluster_map_.find(cluster_name);
236
241
  if (it != cluster_map_.end()) {
237
242
  return it->second->Pick(args);
238
243
  }
@@ -404,7 +409,8 @@ XdsClusterManagerLb::ClusterChild::ClusterChild(
404
409
  RefCountedPtr<XdsClusterManagerLb> xds_cluster_manager_policy,
405
410
  const std::string& name)
406
411
  : xds_cluster_manager_policy_(std::move(xds_cluster_manager_policy)),
407
- name_(name) {
412
+ name_(name),
413
+ picker_(MakeRefCounted<QueuePicker>(nullptr)) {
408
414
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) {
409
415
  gpr_log(GPR_INFO,
410
416
  "[xds_cluster_manager_lb %p] created ClusterChild %p for %s",
@@ -672,15 +678,7 @@ class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory {
672
678
 
673
679
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
674
680
  ParseLoadBalancingConfig(const Json& json) const override {
675
- if (json.type() == Json::Type::kNull) {
676
- // xds_cluster_manager was mentioned as a policy in the deprecated
677
- // loadBalancingPolicy field or in the client API.
678
- return absl::InvalidArgumentError(
679
- "field:loadBalancingPolicy error:xds_cluster_manager policy requires "
680
- "configuration. Please use loadBalancingConfig field of service "
681
- "config instead.");
682
- }
683
- return LoadRefCountedFromJson<XdsClusterManagerLbConfig>(
681
+ return LoadFromJson<RefCountedPtr<XdsClusterManagerLbConfig>>(
684
682
  json, JsonArgs(),
685
683
  "errors validating xds_cluster_manager LB policy config");
686
684
  }