grpc 1.36.0 → 1.37.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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +65 -37
  3. data/include/grpc/grpc.h +15 -1
  4. data/include/grpc/impl/codegen/port_platform.h +2 -0
  5. data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
  6. data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
  7. data/src/core/ext/filters/client_channel/config_selector.h +8 -0
  8. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
  9. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
  10. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
  11. data/src/core/ext/filters/client_channel/lb_policy.cc +3 -0
  12. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +7 -22
  15. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
  17. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
  18. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
  19. data/src/core/ext/filters/client_channel/resolver.cc +3 -0
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
  23. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
  24. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
  25. data/src/core/ext/filters/client_channel/server_address.cc +3 -0
  26. data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
  27. data/src/core/ext/filters/client_channel/subchannel.h +63 -95
  28. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
  29. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
  30. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  31. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
  32. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
  33. data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
  34. data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
  35. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
  36. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  37. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
  38. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
  39. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
  40. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
  41. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
  42. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
  43. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
  44. data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
  45. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  46. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  47. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
  48. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
  49. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
  50. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
  51. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
  52. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
  53. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
  54. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
  55. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
  56. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
  57. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -0
  58. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -0
  59. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
  60. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
  61. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
  62. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
  63. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
  64. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
  65. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +6 -5
  66. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
  67. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
  68. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
  69. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
  70. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
  71. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
  72. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
  73. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
  74. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
  75. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
  76. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
  77. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
  78. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
  79. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
  80. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
  81. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
  82. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
  83. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
  84. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
  85. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +13 -7
  86. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  87. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
  88. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
  89. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
  90. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
  91. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
  92. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
  93. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +21 -20
  94. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
  95. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
  96. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
  97. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
  98. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
  99. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
  100. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
  101. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
  102. data/src/core/ext/xds/xds_api.cc +1591 -279
  103. data/src/core/ext/xds/xds_api.h +279 -39
  104. data/src/core/ext/xds/xds_bootstrap.cc +21 -5
  105. data/src/core/ext/xds/xds_bootstrap.h +5 -1
  106. data/src/core/ext/xds/xds_client.cc +168 -23
  107. data/src/core/ext/xds/xds_client.h +26 -0
  108. data/src/core/ext/xds/xds_client_stats.h +2 -2
  109. data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
  110. data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
  111. data/src/core/ext/xds/xds_http_filters.cc +114 -0
  112. data/src/core/ext/xds/xds_http_filters.h +130 -0
  113. data/src/core/ext/xds/xds_server_config_fetcher.cc +391 -126
  114. data/src/core/lib/channel/channel_stack.cc +12 -0
  115. data/src/core/lib/channel/channel_stack.h +7 -0
  116. data/src/core/lib/channel/channelz.cc +92 -4
  117. data/src/core/lib/channel/channelz.h +30 -1
  118. data/src/core/lib/channel/channelz_registry.cc +14 -0
  119. data/src/core/lib/channel/handshaker.cc +0 -39
  120. data/src/core/lib/channel/handshaker.h +0 -17
  121. data/src/core/lib/channel/status_util.cc +12 -2
  122. data/src/core/lib/channel/status_util.h +5 -0
  123. data/src/core/lib/gpr/sync_abseil.cc +3 -6
  124. data/src/core/lib/gpr/sync_windows.cc +2 -2
  125. data/src/core/lib/gprpp/atomic.h +3 -3
  126. data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
  127. data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
  128. data/src/core/lib/gprpp/thd.h +1 -1
  129. data/src/core/lib/iomgr/buffer_list.h +1 -1
  130. data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
  131. data/src/core/lib/iomgr/error.h +1 -1
  132. data/src/core/lib/iomgr/ev_apple.cc +1 -1
  133. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
  134. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  135. data/src/core/lib/iomgr/exec_ctx.cc +6 -2
  136. data/src/core/lib/iomgr/resource_quota.cc +1 -1
  137. data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
  138. data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
  139. data/src/core/lib/iomgr/tcp_posix.cc +1 -4
  140. data/src/core/lib/iomgr/tcp_uv.cc +2 -2
  141. data/src/core/lib/iomgr/timer_generic.cc +2 -2
  142. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  143. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  144. data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
  145. data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
  146. data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
  147. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
  148. data/src/core/lib/security/transport/security_handshaker.cc +32 -2
  149. data/src/core/lib/slice/slice_intern.cc +6 -7
  150. data/src/core/lib/surface/channel.h +3 -3
  151. data/src/core/lib/surface/completion_queue.cc +1 -1
  152. data/src/core/lib/surface/lame_client.cc +38 -19
  153. data/src/core/lib/surface/lame_client.h +4 -3
  154. data/src/core/lib/surface/server.cc +40 -33
  155. data/src/core/lib/surface/server.h +74 -15
  156. data/src/core/lib/surface/version.cc +1 -1
  157. data/src/core/lib/transport/metadata_batch.cc +27 -0
  158. data/src/core/lib/transport/metadata_batch.h +14 -0
  159. data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
  160. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
  161. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  162. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
  163. data/src/core/tsi/fake_transport_security.cc +10 -1
  164. data/src/ruby/ext/grpc/extconf.rb +9 -1
  165. data/src/ruby/ext/grpc/rb_channel.c +10 -1
  166. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
  167. data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
  168. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  169. data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
  170. data/src/ruby/ext/grpc/rb_grpc.c +4 -0
  171. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  172. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  173. data/src/ruby/ext/grpc/rb_server.c +13 -1
  174. data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
  175. data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
  176. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
  177. data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
  178. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
  179. data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
  180. data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
  181. data/src/ruby/lib/grpc/version.rb +1 -1
  182. data/src/ruby/spec/call_spec.rb +1 -1
  183. data/src/ruby/spec/channel_credentials_spec.rb +32 -0
  184. data/src/ruby/spec/channel_spec.rb +17 -6
  185. data/src/ruby/spec/client_auth_spec.rb +27 -1
  186. data/src/ruby/spec/errors_spec.rb +1 -1
  187. data/src/ruby/spec/generic/active_call_spec.rb +2 -2
  188. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  189. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
  190. data/src/ruby/spec/server_credentials_spec.rb +25 -0
  191. data/src/ruby/spec/server_spec.rb +22 -0
  192. data/third_party/boringssl-with-bazel/err_data.c +255 -255
  193. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
  194. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
  195. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
  196. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
  197. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
  198. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  200. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
  201. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
  202. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
  203. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
  204. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
  205. data/third_party/xxhash/xxhash.h +5443 -0
  206. metadata +93 -49
  207. data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
  208. data/src/core/lib/security/authorization/authorization_engine.h +0 -84
  209. data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
  210. data/src/core/lib/security/authorization/evaluate_args.h +0 -59
  211. data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
  212. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
  213. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
  214. data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -99
  215. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
  216. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
  217. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
  218. data/third_party/upb/upb/json_decode.c +0 -1443
  219. data/third_party/upb/upb/json_decode.h +0 -23
  220. data/third_party/upb/upb/json_encode.c +0 -713
  221. data/third_party/upb/upb/json_encode.h +0 -36
@@ -54,7 +54,7 @@ class XdsBootstrap {
54
54
  std::string cluster;
55
55
  std::string locality_region;
56
56
  std::string locality_zone;
57
- std::string locality_subzone;
57
+ std::string locality_sub_zone;
58
58
  Json metadata;
59
59
  };
60
60
 
@@ -88,6 +88,9 @@ class XdsBootstrap {
88
88
  // add support for fallback for the xds channel.
89
89
  const XdsServer& server() const { return servers_[0]; }
90
90
  const Node* node() const { return node_.get(); }
91
+ const std::string& server_listener_resource_name_template() const {
92
+ return server_listener_resource_name_template_;
93
+ }
91
94
 
92
95
  const CertificateProviderStore::PluginDefinitionMap& certificate_providers()
93
96
  const {
@@ -108,6 +111,7 @@ class XdsBootstrap {
108
111
 
109
112
  absl::InlinedVector<XdsServer, 1> servers_;
110
113
  std::unique_ptr<Node> node_;
114
+ std::string server_listener_resource_name_template_;
111
115
  CertificateProviderStore::PluginDefinitionMap certificate_providers_;
112
116
  };
113
117
 
@@ -35,9 +35,11 @@
35
35
  #include "src/core/ext/filters/client_channel/client_channel.h"
36
36
  #include "src/core/ext/filters/client_channel/service_config.h"
37
37
  #include "src/core/ext/xds/xds_api.h"
38
+ #include "src/core/ext/xds/xds_bootstrap.h"
38
39
  #include "src/core/ext/xds/xds_channel_args.h"
39
40
  #include "src/core/ext/xds/xds_client.h"
40
41
  #include "src/core/ext/xds/xds_client_stats.h"
42
+ #include "src/core/ext/xds/xds_http_filters.h"
41
43
  #include "src/core/lib/backoff/backoff.h"
42
44
  #include "src/core/lib/channel/channel_args.h"
43
45
  #include "src/core/lib/channel/channel_stack.h"
@@ -194,28 +196,34 @@ class XdsClient::ChannelState::AdsCallState
194
196
  "timeout obtaining resource {type=%s name=%s} from xds server",
195
197
  type_url_, name_)
196
198
  .c_str());
199
+ watcher_error = grpc_error_set_int(
200
+ watcher_error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
197
201
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
198
202
  gpr_log(GPR_INFO, "[xds_client %p] %s", ads_calld_->xds_client(),
199
203
  grpc_error_string(watcher_error));
200
204
  }
201
205
  if (type_url_ == XdsApi::kLdsTypeUrl) {
202
206
  ListenerState& state = ads_calld_->xds_client()->listener_map_[name_];
207
+ state.meta.client_status = XdsApi::ResourceMetadata::DOES_NOT_EXIST;
203
208
  for (const auto& p : state.watchers) {
204
209
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
205
210
  }
206
211
  } else if (type_url_ == XdsApi::kRdsTypeUrl) {
207
212
  RouteConfigState& state =
208
213
  ads_calld_->xds_client()->route_config_map_[name_];
214
+ state.meta.client_status = XdsApi::ResourceMetadata::DOES_NOT_EXIST;
209
215
  for (const auto& p : state.watchers) {
210
216
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
211
217
  }
212
218
  } else if (type_url_ == XdsApi::kCdsTypeUrl) {
213
219
  ClusterState& state = ads_calld_->xds_client()->cluster_map_[name_];
220
+ state.meta.client_status = XdsApi::ResourceMetadata::DOES_NOT_EXIST;
214
221
  for (const auto& p : state.watchers) {
215
222
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
216
223
  }
217
224
  } else if (type_url_ == XdsApi::kEdsTypeUrl) {
218
225
  EndpointState& state = ads_calld_->xds_client()->endpoint_map_[name_];
226
+ state.meta.client_status = XdsApi::ResourceMetadata::DOES_NOT_EXIST;
219
227
  for (const auto& p : state.watchers) {
220
228
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
221
229
  }
@@ -251,10 +259,14 @@ class XdsClient::ChannelState::AdsCallState
251
259
 
252
260
  void SendMessageLocked(const std::string& type_url);
253
261
 
254
- void AcceptLdsUpdate(XdsApi::LdsUpdateMap lds_update_map);
255
- void AcceptRdsUpdate(XdsApi::RdsUpdateMap rds_update_map);
256
- void AcceptCdsUpdate(XdsApi::CdsUpdateMap cds_update_map);
257
- void AcceptEdsUpdate(XdsApi::EdsUpdateMap eds_update_map);
262
+ void AcceptLdsUpdate(std::string version, grpc_millis update_time,
263
+ XdsApi::LdsUpdateMap lds_update_map);
264
+ void AcceptRdsUpdate(std::string version, grpc_millis update_time,
265
+ XdsApi::RdsUpdateMap rds_update_map);
266
+ void AcceptCdsUpdate(std::string version, grpc_millis update_time,
267
+ XdsApi::CdsUpdateMap cds_update_map);
268
+ void AcceptEdsUpdate(std::string version, grpc_millis update_time,
269
+ XdsApi::EdsUpdateMap eds_update_map);
258
270
 
259
271
  static void OnRequestSent(void* arg, grpc_error* error);
260
272
  void OnRequestSentLocked(grpc_error* error);
@@ -503,7 +515,7 @@ XdsClient::ChannelState::LrsCallState* XdsClient::ChannelState::lrs_calld()
503
515
  }
504
516
 
505
517
  bool XdsClient::ChannelState::HasActiveAdsCall() const {
506
- return ads_calld_->calld() != nullptr;
518
+ return ads_calld_ != nullptr && ads_calld_->calld() != nullptr;
507
519
  }
508
520
 
509
521
  void XdsClient::ChannelState::MaybeStartLrsCall() {
@@ -866,7 +878,24 @@ bool XdsClient::ChannelState::AdsCallState::HasSubscribedResources() const {
866
878
  return false;
867
879
  }
868
880
 
881
+ namespace {
882
+
883
+ // Build a resource metadata struct for ADS result accepting methods and CSDS.
884
+ XdsApi::ResourceMetadata CreateResourceMetadataAcked(
885
+ std::string serialized_proto, std::string version,
886
+ grpc_millis update_time) {
887
+ XdsApi::ResourceMetadata resource_metadata;
888
+ resource_metadata.serialized_proto = std::move(serialized_proto);
889
+ resource_metadata.update_time = update_time;
890
+ resource_metadata.version = std::move(version);
891
+ resource_metadata.client_status = XdsApi::ResourceMetadata::ACKED;
892
+ return resource_metadata;
893
+ }
894
+
895
+ } // namespace
896
+
869
897
  void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
898
+ std::string version, grpc_millis update_time,
870
899
  XdsApi::LdsUpdateMap lds_update_map) {
871
900
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
872
901
  gpr_log(GPR_INFO,
@@ -878,7 +907,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
878
907
  std::set<std::string> rds_resource_names_seen;
879
908
  for (auto& p : lds_update_map) {
880
909
  const std::string& listener_name = p.first;
881
- XdsApi::LdsUpdate& lds_update = p.second;
910
+ XdsApi::LdsUpdate& lds_update = p.second.resource;
882
911
  auto& state = lds_state.subscribed_resources[listener_name];
883
912
  if (state != nullptr) state->Finish();
884
913
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
@@ -886,8 +915,9 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
886
915
  listener_name.c_str(), lds_update.ToString().c_str());
887
916
  }
888
917
  // Record the RDS resource names seen.
889
- if (!lds_update.route_config_name.empty()) {
890
- rds_resource_names_seen.insert(lds_update.route_config_name);
918
+ if (!lds_update.http_connection_manager.route_config_name.empty()) {
919
+ rds_resource_names_seen.insert(
920
+ lds_update.http_connection_manager.route_config_name);
891
921
  }
892
922
  // Ignore identical update.
893
923
  ListenerState& listener_state = xds_client()->listener_map_[listener_name];
@@ -903,6 +933,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
903
933
  }
904
934
  // Update the listener state.
905
935
  listener_state.update = std::move(lds_update);
936
+ listener_state.meta = CreateResourceMetadataAcked(
937
+ std::move(p.second.serialized_proto), version, update_time);
906
938
  // Notify watchers.
907
939
  for (const auto& p : listener_state.watchers) {
908
940
  p.first->OnListenerChanged(*listener_state.update);
@@ -947,6 +979,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
947
979
  }
948
980
 
949
981
  void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
982
+ std::string version, grpc_millis update_time,
950
983
  XdsApi::RdsUpdateMap rds_update_map) {
951
984
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
952
985
  gpr_log(GPR_INFO,
@@ -957,7 +990,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
957
990
  auto& rds_state = state_map_[XdsApi::kRdsTypeUrl];
958
991
  for (auto& p : rds_update_map) {
959
992
  const std::string& route_config_name = p.first;
960
- XdsApi::RdsUpdate& rds_update = p.second;
993
+ XdsApi::RdsUpdate& rds_update = p.second.resource;
961
994
  auto& state = rds_state.subscribed_resources[route_config_name];
962
995
  if (state != nullptr) state->Finish();
963
996
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
@@ -978,6 +1011,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
978
1011
  }
979
1012
  // Update the cache.
980
1013
  route_config_state.update = std::move(rds_update);
1014
+ route_config_state.meta = CreateResourceMetadataAcked(
1015
+ std::move(p.second.serialized_proto), version, update_time);
981
1016
  // Notify all watchers.
982
1017
  for (const auto& p : route_config_state.watchers) {
983
1018
  p.first->OnRouteConfigChanged(*route_config_state.update);
@@ -986,6 +1021,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
986
1021
  }
987
1022
 
988
1023
  void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1024
+ std::string version, grpc_millis update_time,
989
1025
  XdsApi::CdsUpdateMap cds_update_map) {
990
1026
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
991
1027
  gpr_log(GPR_INFO,
@@ -997,7 +1033,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
997
1033
  std::set<std::string> eds_resource_names_seen;
998
1034
  for (auto& p : cds_update_map) {
999
1035
  const char* cluster_name = p.first.c_str();
1000
- XdsApi::CdsUpdate& cds_update = p.second;
1036
+ XdsApi::CdsUpdate& cds_update = p.second.resource;
1001
1037
  auto& state = cds_state.subscribed_resources[cluster_name];
1002
1038
  if (state != nullptr) state->Finish();
1003
1039
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
@@ -1021,6 +1057,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1021
1057
  }
1022
1058
  // Update the cluster state.
1023
1059
  cluster_state.update = std::move(cds_update);
1060
+ cluster_state.meta = CreateResourceMetadataAcked(
1061
+ std::move(p.second.serialized_proto), version, update_time);
1024
1062
  // Notify all watchers.
1025
1063
  for (const auto& p : cluster_state.watchers) {
1026
1064
  p.first->OnClusterChanged(cluster_state.update.value());
@@ -1064,6 +1102,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1064
1102
  }
1065
1103
 
1066
1104
  void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1105
+ std::string version, grpc_millis update_time,
1067
1106
  XdsApi::EdsUpdateMap eds_update_map) {
1068
1107
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1069
1108
  gpr_log(GPR_INFO,
@@ -1074,7 +1113,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1074
1113
  auto& eds_state = state_map_[XdsApi::kEdsTypeUrl];
1075
1114
  for (auto& p : eds_update_map) {
1076
1115
  const char* eds_service_name = p.first.c_str();
1077
- XdsApi::EdsUpdate& eds_update = p.second;
1116
+ XdsApi::EdsUpdate& eds_update = p.second.resource;
1078
1117
  auto& state = eds_state.subscribed_resources[eds_service_name];
1079
1118
  if (state != nullptr) state->Finish();
1080
1119
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
@@ -1095,6 +1134,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1095
1134
  }
1096
1135
  // Update the cluster state.
1097
1136
  endpoint_state.update = std::move(eds_update);
1137
+ endpoint_state.meta = CreateResourceMetadataAcked(
1138
+ std::move(p.second.serialized_proto), version, update_time);
1098
1139
  // Notify all watchers.
1099
1140
  for (const auto& p : endpoint_state.watchers) {
1100
1141
  p.first->OnEndpointChanged(endpoint_state.update.value());
@@ -1161,7 +1202,8 @@ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1161
1202
  recv_message_payload_ = nullptr;
1162
1203
  // Parse and validate the response.
1163
1204
  XdsApi::AdsParseResult result = xds_client()->api_.ParseAdsResponse(
1164
- response_slice, ResourceNamesForRequest(XdsApi::kLdsTypeUrl),
1205
+ chand()->server_, response_slice,
1206
+ ResourceNamesForRequest(XdsApi::kLdsTypeUrl),
1165
1207
  ResourceNamesForRequest(XdsApi::kRdsTypeUrl),
1166
1208
  ResourceNamesForRequest(XdsApi::kCdsTypeUrl),
1167
1209
  ResourceNamesForRequest(XdsApi::kEdsTypeUrl));
@@ -1173,11 +1215,14 @@ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1173
1215
  xds_client(), grpc_error_string(result.parse_error));
1174
1216
  GRPC_ERROR_UNREF(result.parse_error);
1175
1217
  } else {
1218
+ grpc_millis update_time = grpc_core::ExecCtx::Get()->Now();
1176
1219
  // Update nonce.
1177
1220
  auto& state = state_map_[result.type_url];
1178
1221
  state.nonce = std::move(result.nonce);
1179
1222
  // NACK or ACK the response.
1180
1223
  if (result.parse_error != GRPC_ERROR_NONE) {
1224
+ xds_client()->UpdateResourceMetadataWithFailedParseResult(update_time,
1225
+ result);
1181
1226
  GRPC_ERROR_UNREF(state.error);
1182
1227
  state.error = result.parse_error;
1183
1228
  // NACK unacceptable update.
@@ -1191,13 +1236,17 @@ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1191
1236
  seen_response_ = true;
1192
1237
  // Accept the ADS response according to the type_url.
1193
1238
  if (result.type_url == XdsApi::kLdsTypeUrl) {
1194
- AcceptLdsUpdate(std::move(result.lds_update_map));
1239
+ AcceptLdsUpdate(result.version, update_time,
1240
+ std::move(result.lds_update_map));
1195
1241
  } else if (result.type_url == XdsApi::kRdsTypeUrl) {
1196
- AcceptRdsUpdate(std::move(result.rds_update_map));
1242
+ AcceptRdsUpdate(result.version, update_time,
1243
+ std::move(result.rds_update_map));
1197
1244
  } else if (result.type_url == XdsApi::kCdsTypeUrl) {
1198
- AcceptCdsUpdate(std::move(result.cds_update_map));
1245
+ AcceptCdsUpdate(result.version, update_time,
1246
+ std::move(result.cds_update_map));
1199
1247
  } else if (result.type_url == XdsApi::kEdsTypeUrl) {
1200
- AcceptEdsUpdate(std::move(result.eds_update_map));
1248
+ AcceptEdsUpdate(result.version, update_time,
1249
+ std::move(result.eds_update_map));
1201
1250
  }
1202
1251
  xds_client()->resource_version_map_[result.type_url] =
1203
1252
  std::move(result.version);
@@ -2192,27 +2241,109 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshotLocked(
2192
2241
  return snapshot_map;
2193
2242
  }
2194
2243
 
2244
+ void XdsClient::UpdateResourceMetadataWithFailedParseResult(
2245
+ grpc_millis update_time, const XdsApi::AdsParseResult& result) {
2246
+ // ADS update is rejected and the resource names in the failed update is
2247
+ // available.
2248
+ absl::string_view details = grpc_error_string(result.parse_error);
2249
+ for (auto& name : result.resource_names_failed) {
2250
+ XdsApi::ResourceMetadata* resource_metadata = nullptr;
2251
+ if (result.type_url == XdsApi::kLdsTypeUrl) {
2252
+ auto it = listener_map_.find(name);
2253
+ if (it != listener_map_.end()) {
2254
+ resource_metadata = &it->second.meta;
2255
+ }
2256
+ } else if (result.type_url == XdsApi::kRdsTypeUrl) {
2257
+ auto it = route_config_map_.find(name);
2258
+ if (route_config_map_.find(name) != route_config_map_.end()) {
2259
+ resource_metadata = &it->second.meta;
2260
+ }
2261
+ } else if (result.type_url == XdsApi::kCdsTypeUrl) {
2262
+ auto it = cluster_map_.find(name);
2263
+ if (cluster_map_.find(name) != cluster_map_.end()) {
2264
+ resource_metadata = &it->second.meta;
2265
+ }
2266
+ } else if (result.type_url == XdsApi::kEdsTypeUrl) {
2267
+ auto it = endpoint_map_.find(name);
2268
+ if (endpoint_map_.find(name) != endpoint_map_.end()) {
2269
+ resource_metadata = &it->second.meta;
2270
+ }
2271
+ }
2272
+ if (resource_metadata == nullptr) {
2273
+ return;
2274
+ }
2275
+ resource_metadata->client_status = XdsApi::ResourceMetadata::NACKED;
2276
+ resource_metadata->failed_version = result.version;
2277
+ resource_metadata->failed_details = std::string(details);
2278
+ resource_metadata->failed_update_time = update_time;
2279
+ }
2280
+ }
2281
+
2282
+ std::string XdsClient::DumpClientConfigBinary() {
2283
+ MutexLock lock(&mu_);
2284
+ XdsApi::ResourceTypeMetadataMap resource_type_metadata_map;
2285
+ // Update per-xds-type version if available, this version corresponding to the
2286
+ // last successful ADS update version.
2287
+ for (auto& p : resource_version_map_) {
2288
+ resource_type_metadata_map[p.first].version = p.second;
2289
+ }
2290
+ // Collect resource metadata from listeners
2291
+ auto& lds_map =
2292
+ resource_type_metadata_map[XdsApi::kLdsTypeUrl].resource_metadata_map;
2293
+ for (auto& p : listener_map_) {
2294
+ lds_map[p.first] = &p.second.meta;
2295
+ }
2296
+ // Collect resource metadata from route configs
2297
+ auto& rds_map =
2298
+ resource_type_metadata_map[XdsApi::kRdsTypeUrl].resource_metadata_map;
2299
+ for (auto& p : route_config_map_) {
2300
+ rds_map[p.first] = &p.second.meta;
2301
+ }
2302
+ // Collect resource metadata from clusters
2303
+ auto& cds_map =
2304
+ resource_type_metadata_map[XdsApi::kCdsTypeUrl].resource_metadata_map;
2305
+ for (auto& p : cluster_map_) {
2306
+ cds_map[p.first] = &p.second.meta;
2307
+ }
2308
+ // Collect resource metadata from endpoints
2309
+ auto& eds_map =
2310
+ resource_type_metadata_map[XdsApi::kEdsTypeUrl].resource_metadata_map;
2311
+ for (auto& p : endpoint_map_) {
2312
+ eds_map[p.first] = &p.second.meta;
2313
+ }
2314
+ // Assemble config dump messages
2315
+ return api_.AssembleClientConfig(resource_type_metadata_map);
2316
+ }
2317
+
2195
2318
  //
2196
2319
  // accessors for global state
2197
2320
  //
2198
2321
 
2199
- void XdsClientGlobalInit() { g_mu = new Mutex; }
2322
+ void XdsClientGlobalInit() {
2323
+ g_mu = new Mutex;
2324
+ XdsHttpFilterRegistry::Init();
2325
+ }
2200
2326
 
2201
2327
  void XdsClientGlobalShutdown() {
2202
2328
  delete g_mu;
2203
2329
  g_mu = nullptr;
2204
2330
  gpr_free(g_fallback_bootstrap_config);
2205
2331
  g_fallback_bootstrap_config = nullptr;
2332
+ XdsHttpFilterRegistry::Shutdown();
2206
2333
  }
2207
2334
 
2208
2335
  RefCountedPtr<XdsClient> XdsClient::GetOrCreate(grpc_error** error) {
2209
- MutexLock lock(g_mu);
2210
- if (g_xds_client != nullptr) {
2211
- auto xds_client = g_xds_client->RefIfNonZero();
2212
- if (xds_client != nullptr) return xds_client;
2336
+ RefCountedPtr<XdsClient> xds_client;
2337
+ {
2338
+ MutexLock lock(g_mu);
2339
+ if (g_xds_client != nullptr) {
2340
+ auto xds_client = g_xds_client->RefIfNonZero();
2341
+ if (xds_client != nullptr) return xds_client;
2342
+ }
2343
+ xds_client = MakeRefCounted<XdsClient>(error);
2344
+ if (*error != GRPC_ERROR_NONE) return nullptr;
2345
+ g_xds_client = xds_client.get();
2213
2346
  }
2214
- auto xds_client = MakeRefCounted<XdsClient>(error);
2215
- g_xds_client = xds_client.get();
2216
2347
  return xds_client;
2217
2348
  }
2218
2349
 
@@ -2237,3 +2368,17 @@ void SetXdsFallbackBootstrapConfig(const char* config) {
2237
2368
  } // namespace internal
2238
2369
 
2239
2370
  } // namespace grpc_core
2371
+
2372
+ // The returned bytes may contain NULL(0), so we can't use c-string.
2373
+ grpc_slice grpc_dump_xds_configs() {
2374
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
2375
+ grpc_core::ExecCtx exec_ctx;
2376
+ grpc_error* error = GRPC_ERROR_NONE;
2377
+ auto xds_client = grpc_core::XdsClient::GetOrCreate(&error);
2378
+ if (error != GRPC_ERROR_NONE) {
2379
+ // If we isn't using xDS, just return an empty string.
2380
+ GRPC_ERROR_UNREF(error);
2381
+ return grpc_empty_slice();
2382
+ }
2383
+ return grpc_slice_from_cpp_string(xds_client->DumpClientConfigBinary());
2384
+ }
@@ -88,6 +88,12 @@ class XdsClient : public DualRefCounted<XdsClient> {
88
88
  explicit XdsClient(grpc_error** error);
89
89
  ~XdsClient() override;
90
90
 
91
+ const XdsBootstrap& bootstrap() const {
92
+ // bootstrap_ is guaranteed to be non-null since XdsClient::GetOrCreate()
93
+ // would return a null object if bootstrap_ was null.
94
+ return *bootstrap_;
95
+ }
96
+
91
97
  CertificateProviderStore& certificate_provider_store() {
92
98
  return *certificate_provider_store_;
93
99
  }
@@ -185,6 +191,15 @@ class XdsClient : public DualRefCounted<XdsClient> {
185
191
  // Resets connection backoff state.
186
192
  void ResetBackoff();
187
193
 
194
+ // Dumps the active xDS config in JSON format.
195
+ // Individual xDS resource is encoded as envoy.admin.v3.*ConfigDump. Returns
196
+ // envoy.service.status.v3.ClientConfig which also includes the config
197
+ // status (e.g., CLIENT_REQUESTED, CLIENT_ACKED, CLIENT_NACKED).
198
+ //
199
+ // Expected to be invoked by wrapper languages in their CSDS service
200
+ // implementation.
201
+ std::string DumpClientConfigBinary();
202
+
188
203
  private:
189
204
  // Contains a channel to the xds server and all the data related to the
190
205
  // channel. Holds a ref to the xds client object.
@@ -215,6 +230,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
215
230
  void MaybeStartLrsCall();
216
231
  void StopLrsCall();
217
232
 
233
+ bool HasAdsCall() const;
218
234
  bool HasActiveAdsCall() const;
219
235
 
220
236
  void StartConnectivityWatchLocked();
@@ -248,6 +264,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
248
264
  watchers;
249
265
  // The latest data seen from LDS.
250
266
  absl::optional<XdsApi::LdsUpdate> update;
267
+ XdsApi::ResourceMetadata meta;
251
268
  };
252
269
 
253
270
  struct RouteConfigState {
@@ -256,6 +273,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
256
273
  watchers;
257
274
  // The latest data seen from RDS.
258
275
  absl::optional<XdsApi::RdsUpdate> update;
276
+ XdsApi::ResourceMetadata meta;
259
277
  };
260
278
 
261
279
  struct ClusterState {
@@ -263,6 +281,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
263
281
  watchers;
264
282
  // The latest data seen from CDS.
265
283
  absl::optional<XdsApi::CdsUpdate> update;
284
+ XdsApi::ResourceMetadata meta;
266
285
  };
267
286
 
268
287
  struct EndpointState {
@@ -271,6 +290,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
271
290
  watchers;
272
291
  // The latest data seen from EDS.
273
292
  absl::optional<XdsApi::EdsUpdate> update;
293
+ XdsApi::ResourceMetadata meta;
274
294
  };
275
295
 
276
296
  struct LoadReportState {
@@ -293,6 +313,12 @@ class XdsClient : public DualRefCounted<XdsClient> {
293
313
  XdsApi::ClusterLoadReportMap BuildLoadReportSnapshotLocked(
294
314
  bool send_all_clusters, const std::set<std::string>& clusters);
295
315
 
316
+ void UpdateResourceMetadataWithFailedParseResult(
317
+ grpc_millis update_time, const XdsApi::AdsParseResult& result);
318
+ void UpdatePendingResources(
319
+ const std::string& type_url,
320
+ XdsApi::ResourceMetadataMap* resource_metadata_map);
321
+
296
322
  const grpc_millis request_timeout_;
297
323
  grpc_pollset_set* interested_parties_;
298
324
  std::unique_ptr<XdsBootstrap> bootstrap_;