grpc 1.28.0.pre2 → 1.31.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.
- checksums.yaml +4 -4
- data/Makefile +8313 -11862
- data/include/grpc/grpc.h +2 -2
- data/include/grpc/grpc_security.h +30 -9
- data/include/grpc/grpc_security_constants.h +4 -0
- data/include/grpc/impl/codegen/grpc_types.h +23 -23
- data/include/grpc/impl/codegen/port_platform.h +6 -34
- data/include/grpc/module.modulemap +24 -39
- data/src/core/ext/filters/client_channel/backend_metric.cc +18 -12
- data/src/core/ext/filters/client_channel/client_channel.cc +618 -482
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -2
- data/src/core/ext/filters/client_channel/config_selector.cc +62 -0
- data/src/core/ext/filters/client_channel/config_selector.h +93 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +9 -22
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +6 -5
- data/src/core/ext/filters/client_channel/http_proxy.cc +23 -14
- data/src/core/ext/filters/client_channel/lb_policy.cc +19 -18
- data/src/core/ext/filters/client_channel/lb_policy.h +44 -33
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +83 -0
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +99 -0
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +297 -0
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +83 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +311 -497
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +11 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +871 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -17
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +734 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +117 -41
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +938 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +528 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +1142 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +10 -7
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +2 -1
- data/src/core/ext/filters/client_channel/parse_address.cc +22 -21
- data/src/core/ext/filters/client_channel/resolver.cc +5 -8
- data/src/core/ext/filters/client_channel/resolver.h +12 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +78 -61
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +41 -40
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +8 -7
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +22 -24
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +12 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +79 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +199 -163
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +7 -4
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +46 -45
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +93 -102
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +0 -4
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +64 -12
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -2
- data/src/core/ext/filters/client_channel/resolver_registry.cc +19 -17
- data/src/core/ext/filters/client_channel/resolver_registry.h +8 -8
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +21 -22
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +19 -16
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +73 -217
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +45 -27
- data/src/core/ext/filters/client_channel/server_address.cc +6 -9
- data/src/core/ext/filters/client_channel/server_address.h +6 -12
- data/src/core/ext/filters/client_channel/service_config.cc +104 -144
- data/src/core/ext/filters/client_channel/service_config.h +28 -98
- data/src/core/ext/filters/client_channel/service_config_call_data.h +68 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +142 -0
- data/src/core/ext/filters/client_channel/service_config_parser.cc +87 -0
- data/src/core/ext/filters/client_channel/service_config_parser.h +89 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +55 -25
- data/src/core/ext/filters/client_channel/subchannel.h +35 -11
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +1200 -246
- data/src/core/ext/filters/client_channel/xds/xds_api.h +130 -44
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +90 -29
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +9 -4
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +4 -2
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +839 -431
- data/src/core/ext/filters/client_channel/xds/xds_client.h +84 -33
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +11 -12
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +40 -28
- data/src/core/ext/filters/http/client/http_client_filter.cc +28 -33
- data/src/core/ext/filters/http/client_authority_filter.cc +4 -4
- data/src/core/ext/filters/http/http_filters_plugin.cc +28 -12
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +258 -221
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +399 -0
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +31 -0
- data/src/core/ext/filters/message_size/message_size_filter.cc +61 -88
- data/src/core/ext/filters/message_size/message_size_filter.h +10 -4
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +386 -350
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +6 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -13
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +42 -26
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +25 -30
- data/src/core/ext/transport/chttp2/transport/flow_control.h +14 -16
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +9 -12
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +4 -6
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +12 -13
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +9 -12
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +29 -16
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +25 -29
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +13 -17
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +4 -5
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +2 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +27 -21
- data/src/core/ext/transport/chttp2/transport/parsing.cc +33 -43
- data/src/core/ext/transport/chttp2/transport/stream_map.h +2 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +24 -22
- data/src/core/ext/transport/inproc/inproc_transport.cc +54 -15
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +3 -4
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +4 -229
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +5 -876
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +114 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +429 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +72 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +198 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +105 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +388 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +23 -10
- data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +352 -310
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +42 -34
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +7 -7
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +79 -61
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +55 -49
- data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +79 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +48 -27
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +258 -214
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +51 -45
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +71 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +107 -100
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +24 -20
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +157 -122
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +9 -9
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +38 -18
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +173 -73
- data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +88 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +95 -101
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +49 -65
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +9 -6
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +53 -38
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +70 -62
- data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +15 -10
- data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +95 -63
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +91 -80
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +9 -10
- data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +36 -31
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +68 -46
- data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +770 -722
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +16 -15
- data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +2 -1
- data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +95 -88
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +48 -28
- data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +305 -210
- data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +5 -5
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +51 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +125 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +1 -2
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +4 -2
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +22 -16
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +0 -1
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +48 -11
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +14 -14
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +23 -23
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.h +8 -9
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/range.upb.h +15 -16
- data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +7 -8
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +36 -35
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -1
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +0 -1
- data/src/core/ext/upb-generated/google/api/http.upb.h +29 -28
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +12 -11
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +421 -389
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +1 -2
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +33 -54
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +5 -6
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +27 -28
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +8 -8
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +1 -1
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +32 -45
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +4 -4
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +157 -178
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +14 -13
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +6 -7
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +59 -56
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +11 -12
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +0 -1
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +64 -0
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +6 -6
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +41 -68
- data/src/core/ext/upb-generated/validate/validate.upb.c +21 -20
- data/src/core/ext/upb-generated/validate/validate.upb.h +569 -562
- data/src/core/lib/channel/channel_args.cc +15 -14
- data/src/core/lib/channel/channel_args.h +3 -1
- data/src/core/lib/channel/channel_stack.h +20 -13
- data/src/core/lib/channel/channel_trace.cc +2 -6
- data/src/core/lib/channel/channelz.cc +10 -21
- data/src/core/lib/channel/channelz.h +3 -2
- data/src/core/lib/channel/channelz_registry.cc +5 -3
- data/src/core/lib/channel/connected_channel.cc +7 -5
- data/src/core/lib/channel/context.h +1 -1
- data/src/core/lib/channel/handshaker.cc +11 -13
- data/src/core/lib/channel/handshaker.h +4 -2
- data/src/core/lib/channel/handshaker_registry.cc +5 -17
- data/src/core/lib/channel/status_util.cc +2 -3
- data/src/core/lib/compression/message_compress.cc +5 -1
- data/src/core/lib/debug/stats.cc +21 -27
- data/src/core/lib/debug/stats.h +3 -1
- data/src/core/lib/gpr/log_linux.cc +6 -8
- data/src/core/lib/gpr/log_posix.cc +6 -8
- data/src/core/lib/gpr/spinlock.h +2 -3
- data/src/core/lib/gpr/string.cc +10 -33
- data/src/core/lib/gpr/string.h +4 -18
- data/src/core/lib/gpr/sync_abseil.cc +2 -0
- data/src/core/lib/gpr/time.cc +4 -0
- data/src/core/lib/gpr/time_posix.cc +1 -1
- data/src/core/lib/gprpp/atomic.h +6 -6
- data/src/core/lib/gprpp/fork.cc +1 -1
- data/src/core/lib/gprpp/global_config_env.cc +8 -6
- data/src/core/lib/gprpp/host_port.cc +29 -35
- data/src/core/lib/gprpp/host_port.h +14 -17
- data/src/core/lib/gprpp/map.h +5 -11
- data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
- data/src/core/lib/gprpp/sync.h +9 -0
- data/src/core/lib/http/format_request.cc +46 -65
- data/src/core/lib/http/httpcli.cc +15 -13
- data/src/core/lib/http/httpcli.h +2 -3
- data/src/core/lib/http/httpcli_security_connector.cc +10 -10
- data/src/core/lib/http/parser.h +2 -3
- data/src/core/lib/iomgr/buffer_list.h +22 -21
- data/src/core/lib/iomgr/call_combiner.h +3 -2
- data/src/core/lib/iomgr/cfstream_handle.cc +4 -2
- data/src/core/lib/iomgr/closure.h +2 -3
- data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -3
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +10 -10
- data/src/core/lib/iomgr/error.cc +6 -9
- data/src/core/lib/iomgr/error.h +0 -1
- data/src/core/lib/iomgr/error_cfstream.cc +9 -8
- data/src/core/lib/iomgr/ev_apple.cc +356 -0
- data/src/core/lib/iomgr/ev_apple.h +43 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +25 -29
- data/src/core/lib/iomgr/ev_epollex_linux.cc +17 -24
- data/src/core/lib/iomgr/ev_poll_posix.cc +9 -8
- data/src/core/lib/iomgr/ev_posix.cc +4 -3
- data/src/core/lib/iomgr/exec_ctx.h +14 -2
- data/src/core/lib/iomgr/iomgr.cc +10 -0
- data/src/core/lib/iomgr/iomgr.h +10 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +84 -20
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +14 -0
- data/src/core/lib/iomgr/pollset_set_custom.cc +10 -10
- data/src/core/lib/{gprpp/optional.h → iomgr/pollset_uv.h} +11 -12
- data/src/core/lib/iomgr/port.h +2 -21
- data/src/core/lib/iomgr/python_util.h +46 -0
- data/src/core/lib/iomgr/resolve_address.h +4 -6
- data/src/core/lib/iomgr/resolve_address_custom.cc +42 -57
- data/src/core/lib/iomgr/resolve_address_custom.h +4 -2
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -11
- data/src/core/lib/iomgr/resolve_address_windows.cc +16 -25
- data/src/core/lib/iomgr/resource_quota.cc +38 -37
- data/src/core/lib/iomgr/sockaddr_utils.cc +29 -33
- data/src/core/lib/iomgr/sockaddr_utils.h +10 -15
- data/src/core/lib/iomgr/socket_factory_posix.h +2 -3
- data/src/core/lib/iomgr/socket_mutator.h +2 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +102 -81
- data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
- data/src/core/lib/iomgr/socket_windows.cc +4 -5
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -18
- data/src/core/lib/iomgr/tcp_client_custom.cc +6 -9
- data/src/core/lib/iomgr/tcp_client_posix.cc +30 -36
- data/src/core/lib/iomgr/tcp_client_windows.cc +10 -11
- data/src/core/lib/iomgr/tcp_custom.cc +3 -4
- data/src/core/lib/iomgr/tcp_custom.h +1 -1
- data/src/core/lib/iomgr/tcp_server.cc +3 -4
- data/src/core/lib/iomgr/tcp_server.h +7 -5
- data/src/core/lib/iomgr/tcp_server_custom.cc +11 -23
- data/src/core/lib/iomgr/tcp_server_posix.cc +38 -44
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -8
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +10 -18
- data/src/core/lib/iomgr/tcp_server_windows.cc +16 -16
- data/src/core/lib/iomgr/tcp_uv.cc +3 -2
- data/src/core/lib/iomgr/time_averaged_stats.h +2 -3
- data/src/core/lib/iomgr/timer_generic.cc +15 -15
- data/src/core/lib/{gprpp/inlined_vector.h → iomgr/timer_generic.h} +19 -17
- data/src/core/lib/iomgr/timer_heap.h +2 -3
- data/src/core/lib/iomgr/udp_server.cc +32 -36
- data/src/core/lib/iomgr/udp_server.h +5 -2
- data/src/core/lib/iomgr/unix_sockets_posix.cc +9 -14
- data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +5 -2
- data/src/core/lib/json/json.h +3 -2
- data/src/core/lib/json/json_reader.cc +25 -26
- data/src/core/lib/json/json_writer.cc +13 -12
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +12 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +6 -3
- data/src/core/lib/security/credentials/credentials.cc +0 -84
- data/src/core/lib/security/credentials/credentials.h +13 -62
- data/src/core/lib/security/credentials/fake/fake_credentials.h +4 -0
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +8 -6
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -17
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +8 -6
- data/src/core/lib/security/credentials/iam/iam_credentials.h +4 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -5
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +12 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +8 -15
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +73 -54
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +9 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +19 -6
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +23 -13
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +48 -11
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +21 -6
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +17 -17
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.cc +2 -0
- data/src/core/lib/security/security_connector/security_connector.h +2 -2
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +38 -36
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +8 -5
- data/src/core/lib/security/security_connector/ssl_utils.cc +89 -21
- data/src/core/lib/security/security_connector/ssl_utils.h +18 -12
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +101 -72
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +27 -5
- data/src/core/lib/security/transport/auth_filters.h +0 -5
- data/src/core/lib/security/transport/client_auth_filter.cc +11 -11
- data/src/core/lib/security/util/json_util.cc +12 -13
- data/src/core/lib/slice/slice.cc +38 -1
- data/src/core/lib/slice/slice_intern.cc +2 -3
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_utils.h +9 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +2 -47
- data/src/core/lib/surface/call.cc +42 -44
- data/src/core/lib/surface/call_log_batch.cc +50 -58
- data/src/core/lib/surface/channel.cc +53 -31
- data/src/core/lib/surface/channel.h +35 -4
- data/src/core/lib/surface/channel_ping.cc +2 -3
- data/src/core/lib/surface/completion_queue.cc +304 -47
- data/src/core/lib/surface/completion_queue.h +8 -0
- data/src/core/lib/surface/event_string.cc +18 -25
- data/src/core/lib/surface/event_string.h +3 -1
- data/src/core/lib/surface/init.cc +2 -0
- data/src/core/lib/surface/init_secure.cc +1 -4
- data/src/core/lib/surface/server.cc +971 -837
- data/src/core/lib/surface/server.h +66 -12
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +7 -2
- data/src/core/lib/transport/connectivity_state.cc +7 -6
- data/src/core/lib/transport/connectivity_state.h +5 -3
- data/src/core/lib/transport/metadata.cc +3 -3
- data/src/core/lib/transport/metadata_batch.h +2 -3
- data/src/core/lib/transport/static_metadata.h +1 -1
- data/src/core/lib/transport/status_conversion.cc +6 -14
- data/src/core/lib/transport/transport.cc +2 -3
- data/src/core/lib/transport/transport.h +9 -2
- data/src/core/lib/transport/transport_op_string.cc +61 -102
- data/src/core/lib/uri/uri_parser.cc +8 -15
- data/src/core/lib/uri/uri_parser.h +2 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +24 -4
- data/src/core/tsi/alts/crypt/aes_gcm.cc +0 -2
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +31 -14
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +8 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +34 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +9 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +2 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +2 -3
- data/src/core/tsi/fake_transport_security.cc +10 -15
- data/src/core/tsi/ssl/session_cache/ssl_session.h +0 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +0 -2
- data/src/core/tsi/ssl_transport_security.cc +154 -50
- data/src/core/tsi/ssl_transport_security.h +22 -10
- data/src/core/tsi/ssl_types.h +0 -2
- data/src/core/tsi/transport_security.h +6 -9
- data/src/core/tsi/transport_security_grpc.h +2 -3
- data/src/core/tsi/transport_security_interface.h +8 -3
- data/src/ruby/ext/grpc/extconf.rb +5 -2
- data/src/ruby/ext/grpc/rb_call.c +12 -3
- data/src/ruby/ext/grpc/rb_call.h +4 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +57 -12
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc/errors.rb +103 -42
- data/src/ruby/lib/grpc/generic/active_call.rb +2 -3
- data/src/ruby/lib/grpc/generic/interceptors.rb +5 -5
- data/src/ruby/lib/grpc/generic/rpc_server.rb +9 -10
- data/src/ruby/lib/grpc/generic/service.rb +5 -4
- data/src/ruby/lib/grpc/structs.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +5 -3
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +11 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +16 -0
- data/src/ruby/spec/debug_message_spec.rb +134 -0
- data/src/ruby/spec/generic/service_spec.rb +2 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +7 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +7 -1
- data/src/ruby/spec/support/services.rb +10 -4
- data/src/ruby/spec/testdata/ca.pem +18 -13
- data/src/ruby/spec/testdata/client.key +26 -14
- data/src/ruby/spec/testdata/client.pem +18 -12
- data/src/ruby/spec/testdata/server1.key +26 -14
- data/src/ruby/spec/testdata/server1.pem +20 -14
- data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
- data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
- data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
- data/third_party/abseil-cpp/absl/time/clock.h +74 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +922 -0
- data/third_party/abseil-cpp/absl/time/format.cc +153 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +622 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +384 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +922 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +121 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +958 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +138 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +308 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +115 -0
- data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
- data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
- data/third_party/abseil-cpp/absl/time/time.cc +499 -0
- data/third_party/abseil-cpp/absl/time/time.h +1584 -0
- data/third_party/boringssl-with-bazel/err_data.c +335 -297
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +7 -5
- data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +13 -4
- data/third_party/boringssl-with-bazel/src/crypto/crypto.c +11 -0
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519.c +18 -26
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519_tables.h +13 -21
- data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/internal.h +14 -22
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/dh/dh.c +15 -0
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +10 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +385 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +33 -32
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +143 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +17 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +25 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +30 -154
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +289 -117
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +13 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +96 -55
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +25 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +434 -161
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +63 -71
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +18 -25
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9481 -9485
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +104 -122
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +740 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +90 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +125 -148
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +189 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +61 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +20 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +41 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +32 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +24 -114
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +51 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +15 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +44 -35
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +47 -16
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +15 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -5
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +6 -10
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +16 -0
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +249 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1227 -0
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +682 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +13 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +10 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +57 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +4 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +33 -9
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +25 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +35 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +0 -154
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +28 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +74 -35
- data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +16 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +22 -22
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +9 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +20 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +16 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +2 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +69 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +5 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +3 -17
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +31 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +26 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +191 -79
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +282 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +791 -715
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +1 -0
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +0 -4
- data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +3 -3
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -4
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +146 -57
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +23 -5
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +30 -22
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +21 -4
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +74 -54
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +10 -10
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +21 -21
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +29 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -1
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +13 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +44 -5
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +6 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +5 -5
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +51 -26
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +47 -53
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +129 -48
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +23 -75
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +55 -22
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +63 -25
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +245 -175
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +135 -75
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +1593 -1672
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +512 -503
- data/third_party/upb/upb/decode.c +467 -504
- data/third_party/upb/upb/encode.c +163 -121
- data/third_party/upb/upb/msg.c +130 -64
- data/third_party/upb/upb/msg.h +418 -14
- data/third_party/upb/upb/port_def.inc +35 -6
- data/third_party/upb/upb/port_undef.inc +8 -1
- data/third_party/upb/upb/table.c +53 -75
- data/third_party/upb/upb/table.int.h +11 -43
- data/third_party/upb/upb/upb.c +148 -124
- data/third_party/upb/upb/upb.h +65 -147
- data/third_party/upb/upb/upb.hpp +86 -0
- metadata +122 -41
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +0 -1908
- data/src/core/lib/gprpp/string_view.h +0 -60
- data/src/core/tsi/grpc_shadow_boringssl.h +0 -3311
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256.c +0 -1063
- data/third_party/upb/upb/generated_util.h +0 -105
@@ -21,6 +21,8 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include <deque>
|
25
|
+
|
24
26
|
#include "src/core/ext/filters/client_channel/client_channel_channelz.h"
|
25
27
|
#include "src/core/ext/filters/client_channel/connector.h"
|
26
28
|
#include "src/core/ext/filters/client_channel/subchannel_pool_interface.h"
|
@@ -176,24 +178,44 @@ class SubchannelCall {
|
|
176
178
|
class Subchannel {
|
177
179
|
public:
|
178
180
|
class ConnectivityStateWatcherInterface
|
179
|
-
: public
|
181
|
+
: public RefCounted<ConnectivityStateWatcherInterface> {
|
180
182
|
public:
|
183
|
+
struct ConnectivityStateChange {
|
184
|
+
grpc_connectivity_state state;
|
185
|
+
RefCountedPtr<ConnectedSubchannel> connected_subchannel;
|
186
|
+
};
|
187
|
+
|
181
188
|
virtual ~ConnectivityStateWatcherInterface() = default;
|
182
189
|
|
183
190
|
// Will be invoked whenever the subchannel's connectivity state
|
184
191
|
// changes. There will be only one invocation of this method on a
|
185
192
|
// given watcher instance at any given time.
|
186
|
-
//
|
193
|
+
// Implementations should call PopConnectivityStateChange to get the next
|
194
|
+
// connectivity state change.
|
195
|
+
virtual void OnConnectivityStateChange() = 0;
|
196
|
+
|
197
|
+
virtual grpc_pollset_set* interested_parties() = 0;
|
198
|
+
|
199
|
+
// Enqueues connectivity state change notifications.
|
187
200
|
// When the state changes to READY, connected_subchannel will
|
188
201
|
// contain a ref to the connected subchannel. When it changes from
|
189
202
|
// READY to some other state, the implementation must release its
|
190
203
|
// ref to the connected subchannel.
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
204
|
+
// TODO(yashkt): This is currently needed to send the state updates in the
|
205
|
+
// right order when asynchronously notifying. This will no longer be
|
206
|
+
// necessary when we have access to EventManager.
|
207
|
+
void PushConnectivityStateChange(ConnectivityStateChange state_change);
|
195
208
|
|
196
|
-
|
209
|
+
// Dequeues connectivity state change notifications.
|
210
|
+
ConnectivityStateChange PopConnectivityStateChange();
|
211
|
+
|
212
|
+
private:
|
213
|
+
// Keeps track of the updates that the watcher instance must be notified of.
|
214
|
+
// TODO(yashkt): This is currently needed to send the state updates in the
|
215
|
+
// right order when asynchronously notifying. This will no longer be
|
216
|
+
// necessary when we have access to EventManager.
|
217
|
+
std::deque<ConnectivityStateChange> connectivity_state_queue_;
|
218
|
+
Mutex mu_; // protects the queue
|
197
219
|
};
|
198
220
|
|
199
221
|
// The ctor and dtor are not intended to use directly.
|
@@ -243,7 +265,7 @@ class Subchannel {
|
|
243
265
|
void WatchConnectivityState(
|
244
266
|
grpc_connectivity_state initial_state,
|
245
267
|
grpc_core::UniquePtr<char> health_check_service_name,
|
246
|
-
|
268
|
+
RefCountedPtr<ConnectivityStateWatcherInterface> watcher);
|
247
269
|
|
248
270
|
// Cancels a connectivity state watch.
|
249
271
|
// If the watcher has already been destroyed, this is a no-op.
|
@@ -280,7 +302,7 @@ class Subchannel {
|
|
280
302
|
~ConnectivityStateWatcherList() { Clear(); }
|
281
303
|
|
282
304
|
void AddWatcherLocked(
|
283
|
-
|
305
|
+
RefCountedPtr<ConnectivityStateWatcherInterface> watcher);
|
284
306
|
void RemoveWatcherLocked(ConnectivityStateWatcherInterface* watcher);
|
285
307
|
|
286
308
|
// Notifies all watchers in the list about a change to state.
|
@@ -294,7 +316,7 @@ class Subchannel {
|
|
294
316
|
// TODO(roth): Once we can use C++-14 heterogeneous lookups, this can
|
295
317
|
// be a set instead of a map.
|
296
318
|
std::map<ConnectivityStateWatcherInterface*,
|
297
|
-
|
319
|
+
RefCountedPtr<ConnectivityStateWatcherInterface>>
|
298
320
|
watchers_;
|
299
321
|
};
|
300
322
|
|
@@ -312,7 +334,7 @@ class Subchannel {
|
|
312
334
|
void AddWatcherLocked(
|
313
335
|
Subchannel* subchannel, grpc_connectivity_state initial_state,
|
314
336
|
grpc_core::UniquePtr<char> health_check_service_name,
|
315
|
-
|
337
|
+
RefCountedPtr<ConnectivityStateWatcherInterface> watcher);
|
316
338
|
void RemoveWatcherLocked(const char* health_check_service_name,
|
317
339
|
ConnectivityStateWatcherInterface* watcher);
|
318
340
|
|
@@ -332,6 +354,8 @@ class Subchannel {
|
|
332
354
|
|
333
355
|
class ConnectedSubchannelStateWatcher;
|
334
356
|
|
357
|
+
class AsyncWatcherNotifierLocked;
|
358
|
+
|
335
359
|
// Sets the subchannel's connectivity state to \a state.
|
336
360
|
void SetConnectivityStateLocked(grpc_connectivity_state state);
|
337
361
|
|
@@ -23,13 +23,20 @@
|
|
23
23
|
#include <cstdlib>
|
24
24
|
|
25
25
|
#include "absl/strings/str_cat.h"
|
26
|
+
#include "absl/strings/str_format.h"
|
27
|
+
#include "absl/strings/str_join.h"
|
28
|
+
#include "absl/strings/str_split.h"
|
29
|
+
|
30
|
+
#include "upb/upb.hpp"
|
26
31
|
|
27
32
|
#include <grpc/impl/codegen/log.h>
|
28
33
|
#include <grpc/support/alloc.h>
|
29
34
|
#include <grpc/support/string_util.h>
|
30
35
|
|
31
36
|
#include "src/core/ext/filters/client_channel/xds/xds_api.h"
|
32
|
-
#include "src/core/lib/
|
37
|
+
#include "src/core/lib/gpr/env.h"
|
38
|
+
#include "src/core/lib/gpr/string.h"
|
39
|
+
#include "src/core/lib/gpr/useful.h"
|
33
40
|
#include "src/core/lib/iomgr/error.h"
|
34
41
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
35
42
|
|
@@ -48,7 +55,9 @@
|
|
48
55
|
#include "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h"
|
49
56
|
#include "envoy/config/listener/v2/api_listener.upb.h"
|
50
57
|
#include "envoy/service/load_stats/v2/lrs.upb.h"
|
58
|
+
#include "envoy/type/matcher/regex.upb.h"
|
51
59
|
#include "envoy/type/percent.upb.h"
|
60
|
+
#include "envoy/type/range.upb.h"
|
52
61
|
#include "google/protobuf/any.upb.h"
|
53
62
|
#include "google/protobuf/duration.upb.h"
|
54
63
|
#include "google/protobuf/struct.upb.h"
|
@@ -125,8 +134,99 @@ const char* XdsApi::kCdsTypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
|
|
125
134
|
const char* XdsApi::kEdsTypeUrl =
|
126
135
|
"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
|
127
136
|
|
128
|
-
XdsApi::
|
129
|
-
|
137
|
+
std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString()
|
138
|
+
const {
|
139
|
+
std::string path_type_string;
|
140
|
+
switch (type) {
|
141
|
+
case PathMatcherType::PATH:
|
142
|
+
path_type_string = "path match";
|
143
|
+
break;
|
144
|
+
case PathMatcherType::PREFIX:
|
145
|
+
path_type_string = "prefix match";
|
146
|
+
break;
|
147
|
+
case PathMatcherType::REGEX:
|
148
|
+
path_type_string = "regex match";
|
149
|
+
break;
|
150
|
+
default:
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
return absl::StrFormat("Path %s:/%s/", path_type_string,
|
154
|
+
type == PathMatcherType::REGEX
|
155
|
+
? regex_matcher->pattern()
|
156
|
+
: string_matcher);
|
157
|
+
}
|
158
|
+
|
159
|
+
std::string XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::ToString()
|
160
|
+
const {
|
161
|
+
switch (type) {
|
162
|
+
case HeaderMatcherType::EXACT:
|
163
|
+
return absl::StrFormat("Header exact match:%s %s:%s",
|
164
|
+
invert_match ? " not" : "", name, string_matcher);
|
165
|
+
case HeaderMatcherType::REGEX:
|
166
|
+
return absl::StrFormat("Header regex match:%s %s:%s",
|
167
|
+
invert_match ? " not" : "", name,
|
168
|
+
regex_match->pattern());
|
169
|
+
case HeaderMatcherType::RANGE:
|
170
|
+
return absl::StrFormat("Header range match:%s %s:[%d, %d)",
|
171
|
+
invert_match ? " not" : "", name, range_start,
|
172
|
+
range_end);
|
173
|
+
case HeaderMatcherType::PRESENT:
|
174
|
+
return absl::StrFormat("Header present match:%s %s:%s",
|
175
|
+
invert_match ? " not" : "", name,
|
176
|
+
present_match ? "true" : "false");
|
177
|
+
case HeaderMatcherType::PREFIX:
|
178
|
+
return absl::StrFormat("Header prefix match:%s %s:%s",
|
179
|
+
invert_match ? " not" : "", name, string_matcher);
|
180
|
+
case HeaderMatcherType::SUFFIX:
|
181
|
+
return absl::StrFormat("Header suffix match:%s %s:%s",
|
182
|
+
invert_match ? " not" : "", name, string_matcher);
|
183
|
+
default:
|
184
|
+
return "";
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
std::string XdsApi::RdsUpdate::RdsRoute::Matchers::ToString() const {
|
189
|
+
std::vector<std::string> contents;
|
190
|
+
contents.push_back(path_matcher.ToString());
|
191
|
+
for (const auto& header_it : header_matchers) {
|
192
|
+
contents.push_back(header_it.ToString());
|
193
|
+
}
|
194
|
+
if (fraction_per_million.has_value()) {
|
195
|
+
contents.push_back(absl::StrFormat("Fraction Per Million %d",
|
196
|
+
fraction_per_million.value()));
|
197
|
+
}
|
198
|
+
return absl::StrJoin(contents, "\n");
|
199
|
+
}
|
200
|
+
|
201
|
+
std::string XdsApi::RdsUpdate::RdsRoute::ClusterWeight::ToString() const {
|
202
|
+
return absl::StrFormat("{cluster=%s, weight=%d}", name, weight);
|
203
|
+
}
|
204
|
+
|
205
|
+
std::string XdsApi::RdsUpdate::RdsRoute::ToString() const {
|
206
|
+
std::vector<std::string> contents;
|
207
|
+
contents.push_back(matchers.ToString());
|
208
|
+
if (!cluster_name.empty()) {
|
209
|
+
contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
|
210
|
+
}
|
211
|
+
for (const auto& weighted_it : weighted_clusters) {
|
212
|
+
contents.push_back(weighted_it.ToString());
|
213
|
+
}
|
214
|
+
return absl::StrJoin(contents, "\n");
|
215
|
+
}
|
216
|
+
|
217
|
+
std::string XdsApi::RdsUpdate::ToString() const {
|
218
|
+
std::vector<std::string> contents;
|
219
|
+
for (const auto& route_it : routes) {
|
220
|
+
contents.push_back(route_it.ToString());
|
221
|
+
}
|
222
|
+
return absl::StrJoin(contents, ",\n");
|
223
|
+
}
|
224
|
+
|
225
|
+
XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
|
226
|
+
const XdsBootstrap::Node* node)
|
227
|
+
: client_(client),
|
228
|
+
tracer_(tracer),
|
229
|
+
node_(node),
|
130
230
|
build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
|
131
231
|
grpc_version_string())),
|
132
232
|
user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {}
|
@@ -147,13 +247,10 @@ void PopulateListValue(upb_arena* arena, google_protobuf_ListValue* list_value,
|
|
147
247
|
void PopulateMetadata(upb_arena* arena, google_protobuf_Struct* metadata_pb,
|
148
248
|
const Json::Object& metadata) {
|
149
249
|
for (const auto& p : metadata) {
|
150
|
-
|
151
|
-
google_protobuf_Struct_add_fields(metadata_pb, arena);
|
152
|
-
google_protobuf_Struct_FieldsEntry_set_key(
|
153
|
-
field, upb_strview_makez(p.first.c_str()));
|
154
|
-
google_protobuf_Value* value =
|
155
|
-
google_protobuf_Struct_FieldsEntry_mutable_value(field, arena);
|
250
|
+
google_protobuf_Value* value = google_protobuf_Value_new(arena);
|
156
251
|
PopulateMetadataValue(arena, value, p.second);
|
252
|
+
google_protobuf_Struct_fields_set(
|
253
|
+
metadata_pb, upb_strview_makez(p.first.c_str()), value, arena);
|
157
254
|
}
|
158
255
|
}
|
159
256
|
|
@@ -214,14 +311,12 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node,
|
|
214
311
|
if (!server_name.empty()) {
|
215
312
|
google_protobuf_Struct* metadata =
|
216
313
|
envoy_api_v2_core_Node_mutable_metadata(node_msg, arena);
|
217
|
-
|
218
|
-
google_protobuf_Struct_add_fields(metadata, arena);
|
219
|
-
google_protobuf_Struct_FieldsEntry_set_key(
|
220
|
-
field, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"));
|
221
|
-
google_protobuf_Value* value =
|
222
|
-
google_protobuf_Struct_FieldsEntry_mutable_value(field, arena);
|
314
|
+
google_protobuf_Value* value = google_protobuf_Value_new(arena);
|
223
315
|
google_protobuf_Value_set_string_value(
|
224
316
|
value, upb_strview_make(server_name.data(), server_name.size()));
|
317
|
+
google_protobuf_Struct_fields_set(
|
318
|
+
metadata, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"), value,
|
319
|
+
arena);
|
225
320
|
}
|
226
321
|
if (!node->locality_region.empty() || !node->locality_zone.empty() ||
|
227
322
|
!node->locality_subzone.empty()) {
|
@@ -253,24 +348,206 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node,
|
|
253
348
|
arena);
|
254
349
|
}
|
255
350
|
|
256
|
-
|
257
|
-
|
258
|
-
|
351
|
+
inline absl::string_view UpbStringToAbsl(const upb_strview& str) {
|
352
|
+
return absl::string_view(str.data, str.size);
|
353
|
+
}
|
354
|
+
|
355
|
+
inline std::string UpbStringToStdString(const upb_strview& str) {
|
356
|
+
return std::string(str.data, str.size);
|
357
|
+
}
|
358
|
+
|
359
|
+
inline void AddStringField(const char* name, const upb_strview& value,
|
360
|
+
std::vector<std::string>* fields,
|
361
|
+
bool add_if_empty = false) {
|
362
|
+
if (value.size > 0 || add_if_empty) {
|
363
|
+
fields->emplace_back(
|
364
|
+
absl::StrCat(name, ": \"", UpbStringToAbsl(value), "\""));
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
inline void AddUInt32ValueField(const char* name,
|
369
|
+
const google_protobuf_UInt32Value* value,
|
370
|
+
std::vector<std::string>* fields) {
|
371
|
+
if (value != nullptr) {
|
372
|
+
fields->emplace_back(absl::StrCat(
|
373
|
+
name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
inline void AddLocalityField(int indent_level,
|
378
|
+
const envoy_api_v2_core_Locality* locality,
|
379
|
+
std::vector<std::string>* fields) {
|
380
|
+
std::string indent =
|
381
|
+
absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
|
382
|
+
// region
|
383
|
+
std::string field = absl::StrCat(indent, "region");
|
384
|
+
AddStringField(field.c_str(), envoy_api_v2_core_Locality_region(locality),
|
385
|
+
fields);
|
386
|
+
// zone
|
387
|
+
field = absl::StrCat(indent, "zone");
|
388
|
+
AddStringField(field.c_str(), envoy_api_v2_core_Locality_zone(locality),
|
389
|
+
fields);
|
390
|
+
// sub_zone
|
391
|
+
field = absl::StrCat(indent, "sub_zone");
|
392
|
+
AddStringField(field.c_str(), envoy_api_v2_core_Locality_sub_zone(locality),
|
393
|
+
fields);
|
394
|
+
}
|
395
|
+
|
396
|
+
void AddNodeLogFields(const envoy_api_v2_core_Node* node,
|
397
|
+
std::vector<std::string>* fields) {
|
398
|
+
fields->emplace_back("node {");
|
399
|
+
// id
|
400
|
+
AddStringField(" id", envoy_api_v2_core_Node_id(node), fields);
|
401
|
+
// metadata
|
402
|
+
const google_protobuf_Struct* metadata =
|
403
|
+
envoy_api_v2_core_Node_metadata(node);
|
404
|
+
if (metadata != nullptr) {
|
405
|
+
fields->emplace_back(" metadata {");
|
406
|
+
size_t entry_idx = UPB_MAP_BEGIN;
|
407
|
+
while (true) {
|
408
|
+
const google_protobuf_Struct_FieldsEntry* entry =
|
409
|
+
google_protobuf_Struct_fields_next(metadata, &entry_idx);
|
410
|
+
if (entry == nullptr) break;
|
411
|
+
fields->emplace_back(" field {");
|
412
|
+
// key
|
413
|
+
AddStringField(" key", google_protobuf_Struct_FieldsEntry_key(entry),
|
414
|
+
fields);
|
415
|
+
// value
|
416
|
+
const google_protobuf_Value* value =
|
417
|
+
google_protobuf_Struct_FieldsEntry_value(entry);
|
418
|
+
if (value != nullptr) {
|
419
|
+
std::string value_str;
|
420
|
+
if (google_protobuf_Value_has_string_value(value)) {
|
421
|
+
value_str = absl::StrCat(
|
422
|
+
"string_value: \"",
|
423
|
+
UpbStringToAbsl(google_protobuf_Value_string_value(value)), "\"");
|
424
|
+
} else if (google_protobuf_Value_has_null_value(value)) {
|
425
|
+
value_str = "null_value: NULL_VALUE";
|
426
|
+
} else if (google_protobuf_Value_has_number_value(value)) {
|
427
|
+
value_str = absl::StrCat("double_value: ",
|
428
|
+
google_protobuf_Value_number_value(value));
|
429
|
+
} else if (google_protobuf_Value_has_bool_value(value)) {
|
430
|
+
value_str = absl::StrCat("bool_value: ",
|
431
|
+
google_protobuf_Value_bool_value(value));
|
432
|
+
} else if (google_protobuf_Value_has_struct_value(value)) {
|
433
|
+
value_str = "struct_value: <not printed>";
|
434
|
+
} else if (google_protobuf_Value_has_list_value(value)) {
|
435
|
+
value_str = "list_value: <not printed>";
|
436
|
+
} else {
|
437
|
+
value_str = "<unknown>";
|
438
|
+
}
|
439
|
+
fields->emplace_back(absl::StrCat(" value { ", value_str, " }"));
|
440
|
+
}
|
441
|
+
fields->emplace_back(" }");
|
442
|
+
}
|
443
|
+
fields->emplace_back(" }");
|
444
|
+
}
|
445
|
+
// locality
|
446
|
+
const envoy_api_v2_core_Locality* locality =
|
447
|
+
envoy_api_v2_core_Node_locality(node);
|
448
|
+
if (locality != nullptr) {
|
449
|
+
fields->emplace_back(" locality {");
|
450
|
+
AddLocalityField(2, locality, fields);
|
451
|
+
fields->emplace_back(" }");
|
452
|
+
}
|
453
|
+
// build_version
|
454
|
+
AddStringField(" build_version", envoy_api_v2_core_Node_build_version(node),
|
455
|
+
fields);
|
456
|
+
// user_agent_name
|
457
|
+
AddStringField(" user_agent_name",
|
458
|
+
envoy_api_v2_core_Node_user_agent_name(node), fields);
|
459
|
+
// user_agent_version
|
460
|
+
AddStringField(" user_agent_version",
|
461
|
+
envoy_api_v2_core_Node_user_agent_version(node), fields);
|
462
|
+
// client_features
|
463
|
+
size_t num_client_features;
|
464
|
+
const upb_strview* client_features =
|
465
|
+
envoy_api_v2_core_Node_client_features(node, &num_client_features);
|
466
|
+
for (size_t i = 0; i < num_client_features; ++i) {
|
467
|
+
AddStringField(" client_features", client_features[i], fields);
|
468
|
+
}
|
469
|
+
fields->emplace_back("}");
|
470
|
+
}
|
471
|
+
|
472
|
+
void MaybeLogDiscoveryRequest(XdsClient* client, TraceFlag* tracer,
|
473
|
+
const envoy_api_v2_DiscoveryRequest* request) {
|
474
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
475
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
476
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
477
|
+
// the raw proto instead of doing this manually.
|
478
|
+
std::vector<std::string> fields;
|
479
|
+
// version_info
|
480
|
+
AddStringField("version_info",
|
481
|
+
envoy_api_v2_DiscoveryRequest_version_info(request),
|
482
|
+
&fields);
|
483
|
+
// node
|
484
|
+
const envoy_api_v2_core_Node* node =
|
485
|
+
envoy_api_v2_DiscoveryRequest_node(request);
|
486
|
+
if (node != nullptr) AddNodeLogFields(node, &fields);
|
487
|
+
// resource_names
|
488
|
+
size_t num_resource_names;
|
489
|
+
const upb_strview* resource_names =
|
490
|
+
envoy_api_v2_DiscoveryRequest_resource_names(request,
|
491
|
+
&num_resource_names);
|
492
|
+
for (size_t i = 0; i < num_resource_names; ++i) {
|
493
|
+
AddStringField("resource_names", resource_names[i], &fields);
|
494
|
+
}
|
495
|
+
// type_url
|
496
|
+
AddStringField("type_url", envoy_api_v2_DiscoveryRequest_type_url(request),
|
497
|
+
&fields);
|
498
|
+
// response_nonce
|
499
|
+
AddStringField("response_nonce",
|
500
|
+
envoy_api_v2_DiscoveryRequest_response_nonce(request),
|
501
|
+
&fields);
|
502
|
+
// error_detail
|
503
|
+
const struct google_rpc_Status* error_detail =
|
504
|
+
envoy_api_v2_DiscoveryRequest_error_detail(request);
|
505
|
+
if (error_detail != nullptr) {
|
506
|
+
fields.emplace_back("error_detail {");
|
507
|
+
// code
|
508
|
+
int32_t code = google_rpc_Status_code(error_detail);
|
509
|
+
if (code != 0) fields.emplace_back(absl::StrCat(" code: ", code));
|
510
|
+
// message
|
511
|
+
AddStringField(" message", google_rpc_Status_message(error_detail),
|
512
|
+
&fields);
|
513
|
+
fields.emplace_back("}");
|
514
|
+
}
|
515
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s", client,
|
516
|
+
absl::StrJoin(fields, "\n").c_str());
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
grpc_slice SerializeDiscoveryRequest(upb_arena* arena,
|
521
|
+
envoy_api_v2_DiscoveryRequest* request) {
|
522
|
+
size_t output_length;
|
523
|
+
char* output =
|
524
|
+
envoy_api_v2_DiscoveryRequest_serialize(request, arena, &output_length);
|
525
|
+
return grpc_slice_from_copied_buffer(output, output_length);
|
526
|
+
}
|
527
|
+
|
528
|
+
} // namespace
|
529
|
+
|
530
|
+
grpc_slice XdsApi::CreateAdsRequest(
|
531
|
+
const std::string& type_url,
|
532
|
+
const std::set<absl::string_view>& resource_names,
|
533
|
+
const std::string& version, const std::string& nonce, grpc_error* error,
|
534
|
+
bool populate_node) {
|
535
|
+
upb::Arena arena;
|
259
536
|
// Create a request.
|
260
537
|
envoy_api_v2_DiscoveryRequest* request =
|
261
|
-
envoy_api_v2_DiscoveryRequest_new(arena);
|
538
|
+
envoy_api_v2_DiscoveryRequest_new(arena.ptr());
|
262
539
|
// Set type_url.
|
263
|
-
envoy_api_v2_DiscoveryRequest_set_type_url(
|
264
|
-
|
540
|
+
envoy_api_v2_DiscoveryRequest_set_type_url(
|
541
|
+
request, upb_strview_make(type_url.data(), type_url.size()));
|
265
542
|
// Set version_info.
|
266
543
|
if (!version.empty()) {
|
267
544
|
envoy_api_v2_DiscoveryRequest_set_version_info(
|
268
|
-
request,
|
545
|
+
request, upb_strview_make(version.data(), version.size()));
|
269
546
|
}
|
270
547
|
// Set nonce.
|
271
548
|
if (!nonce.empty()) {
|
272
549
|
envoy_api_v2_DiscoveryRequest_set_response_nonce(
|
273
|
-
request,
|
550
|
+
request, upb_strview_make(nonce.data(), nonce.size()));
|
274
551
|
}
|
275
552
|
// Set error_detail if it's a NACK.
|
276
553
|
if (error != GRPC_ERROR_NONE) {
|
@@ -282,39 +559,11 @@ envoy_api_v2_DiscoveryRequest* CreateDiscoveryRequest(
|
|
282
559
|
GPR_SLICE_START_PTR(error_description_slice)),
|
283
560
|
GPR_SLICE_LENGTH(error_description_slice));
|
284
561
|
google_rpc_Status* error_detail =
|
285
|
-
envoy_api_v2_DiscoveryRequest_mutable_error_detail(request,
|
562
|
+
envoy_api_v2_DiscoveryRequest_mutable_error_detail(request,
|
563
|
+
arena.ptr());
|
286
564
|
google_rpc_Status_set_message(error_detail, error_description_strview);
|
287
565
|
GRPC_ERROR_UNREF(error);
|
288
566
|
}
|
289
|
-
return request;
|
290
|
-
}
|
291
|
-
|
292
|
-
grpc_slice SerializeDiscoveryRequest(upb_arena* arena,
|
293
|
-
envoy_api_v2_DiscoveryRequest* request) {
|
294
|
-
size_t output_length;
|
295
|
-
char* output =
|
296
|
-
envoy_api_v2_DiscoveryRequest_serialize(request, arena, &output_length);
|
297
|
-
return grpc_slice_from_copied_buffer(output, output_length);
|
298
|
-
}
|
299
|
-
|
300
|
-
} // namespace
|
301
|
-
|
302
|
-
grpc_slice XdsApi::CreateUnsupportedTypeNackRequest(const std::string& type_url,
|
303
|
-
const std::string& nonce,
|
304
|
-
grpc_error* error) {
|
305
|
-
upb::Arena arena;
|
306
|
-
envoy_api_v2_DiscoveryRequest* request = CreateDiscoveryRequest(
|
307
|
-
arena.ptr(), type_url.c_str(), /*version=*/"", nonce, error);
|
308
|
-
return SerializeDiscoveryRequest(arena.ptr(), request);
|
309
|
-
}
|
310
|
-
|
311
|
-
grpc_slice XdsApi::CreateLdsRequest(const std::string& server_name,
|
312
|
-
const std::string& version,
|
313
|
-
const std::string& nonce, grpc_error* error,
|
314
|
-
bool populate_node) {
|
315
|
-
upb::Arena arena;
|
316
|
-
envoy_api_v2_DiscoveryRequest* request =
|
317
|
-
CreateDiscoveryRequest(arena.ptr(), kLdsTypeUrl, version, nonce, error);
|
318
567
|
// Populate node.
|
319
568
|
if (populate_node) {
|
320
569
|
envoy_api_v2_core_Node* node_msg =
|
@@ -322,82 +571,376 @@ grpc_slice XdsApi::CreateLdsRequest(const std::string& server_name,
|
|
322
571
|
PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_, "",
|
323
572
|
node_msg);
|
324
573
|
}
|
325
|
-
// Add
|
326
|
-
|
327
|
-
|
328
|
-
|
574
|
+
// Add resource_names.
|
575
|
+
for (const auto& resource_name : resource_names) {
|
576
|
+
envoy_api_v2_DiscoveryRequest_add_resource_names(
|
577
|
+
request, upb_strview_make(resource_name.data(), resource_name.size()),
|
578
|
+
arena.ptr());
|
579
|
+
}
|
580
|
+
MaybeLogDiscoveryRequest(client_, tracer_, request);
|
329
581
|
return SerializeDiscoveryRequest(arena.ptr(), request);
|
330
582
|
}
|
331
583
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
584
|
+
namespace {
|
585
|
+
|
586
|
+
void MaybeLogDiscoveryResponse(XdsClient* client, TraceFlag* tracer,
|
587
|
+
const envoy_api_v2_DiscoveryResponse* response) {
|
588
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
589
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
590
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
591
|
+
// the raw proto instead of doing this manually.
|
592
|
+
std::vector<std::string> fields;
|
593
|
+
// version_info
|
594
|
+
AddStringField("version_info",
|
595
|
+
envoy_api_v2_DiscoveryResponse_version_info(response),
|
596
|
+
&fields);
|
597
|
+
// resources
|
598
|
+
size_t num_resources;
|
599
|
+
envoy_api_v2_DiscoveryResponse_resources(response, &num_resources);
|
600
|
+
fields.emplace_back(
|
601
|
+
absl::StrCat("resources: <", num_resources, " element(s)>"));
|
602
|
+
// type_url
|
603
|
+
AddStringField("type_url",
|
604
|
+
envoy_api_v2_DiscoveryResponse_type_url(response), &fields);
|
605
|
+
// nonce
|
606
|
+
AddStringField("nonce", envoy_api_v2_DiscoveryResponse_nonce(response),
|
607
|
+
&fields);
|
608
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
|
609
|
+
absl::StrJoin(fields, "\n").c_str());
|
345
610
|
}
|
346
|
-
// Add resource_name.
|
347
|
-
envoy_api_v2_DiscoveryRequest_add_resource_names(
|
348
|
-
request,
|
349
|
-
upb_strview_make(route_config_name.data(), route_config_name.size()),
|
350
|
-
arena.ptr());
|
351
|
-
return SerializeDiscoveryRequest(arena.ptr(), request);
|
352
611
|
}
|
353
612
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
613
|
+
void MaybeLogRouteConfiguration(
|
614
|
+
XdsClient* client, TraceFlag* tracer,
|
615
|
+
const envoy_api_v2_RouteConfiguration* route_config) {
|
616
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
617
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
618
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
619
|
+
// the raw proto instead of doing this manually.
|
620
|
+
std::vector<std::string> fields;
|
621
|
+
// name
|
622
|
+
AddStringField("name", envoy_api_v2_RouteConfiguration_name(route_config),
|
623
|
+
&fields);
|
624
|
+
// virtual_hosts
|
625
|
+
size_t num_virtual_hosts;
|
626
|
+
const envoy_api_v2_route_VirtualHost* const* virtual_hosts =
|
627
|
+
envoy_api_v2_RouteConfiguration_virtual_hosts(route_config,
|
628
|
+
&num_virtual_hosts);
|
629
|
+
for (size_t i = 0; i < num_virtual_hosts; ++i) {
|
630
|
+
const auto* virtual_host = virtual_hosts[i];
|
631
|
+
fields.push_back("virtual_hosts {");
|
632
|
+
// name
|
633
|
+
AddStringField(
|
634
|
+
" name", envoy_api_v2_route_VirtualHost_name(virtual_host), &fields);
|
635
|
+
// domains
|
636
|
+
size_t num_domains;
|
637
|
+
const upb_strview* const domains =
|
638
|
+
envoy_api_v2_route_VirtualHost_domains(virtual_host, &num_domains);
|
639
|
+
for (size_t j = 0; j < num_domains; ++j) {
|
640
|
+
AddStringField(" domains", domains[j], &fields);
|
641
|
+
}
|
642
|
+
// routes
|
643
|
+
size_t num_routes;
|
644
|
+
const envoy_api_v2_route_Route* const* routes =
|
645
|
+
envoy_api_v2_route_VirtualHost_routes(virtual_host, &num_routes);
|
646
|
+
for (size_t j = 0; j < num_routes; ++j) {
|
647
|
+
const auto* route = routes[j];
|
648
|
+
fields.push_back(" route {");
|
649
|
+
// name
|
650
|
+
AddStringField(" name", envoy_api_v2_route_Route_name(route),
|
651
|
+
&fields);
|
652
|
+
// match
|
653
|
+
const envoy_api_v2_route_RouteMatch* match =
|
654
|
+
envoy_api_v2_route_Route_match(route);
|
655
|
+
if (match != nullptr) {
|
656
|
+
fields.emplace_back(" match {");
|
657
|
+
// path matching
|
658
|
+
if (envoy_api_v2_route_RouteMatch_has_prefix(match)) {
|
659
|
+
AddStringField(" prefix",
|
660
|
+
envoy_api_v2_route_RouteMatch_prefix(match), &fields,
|
661
|
+
/*add_if_empty=*/true);
|
662
|
+
} else if (envoy_api_v2_route_RouteMatch_has_path(match)) {
|
663
|
+
AddStringField(" path",
|
664
|
+
envoy_api_v2_route_RouteMatch_path(match), &fields,
|
665
|
+
/*add_if_empty=*/true);
|
666
|
+
} else if (envoy_api_v2_route_RouteMatch_has_regex(match)) {
|
667
|
+
AddStringField(" regex",
|
668
|
+
envoy_api_v2_route_RouteMatch_regex(match), &fields,
|
669
|
+
/*add_if_empty=*/true);
|
670
|
+
} else if (envoy_api_v2_route_RouteMatch_has_safe_regex(match)) {
|
671
|
+
fields.emplace_back(" safe_regex: <not printed>");
|
672
|
+
} else {
|
673
|
+
fields.emplace_back(" <unknown path matching type>");
|
674
|
+
}
|
675
|
+
// header matching
|
676
|
+
size_t num_headers;
|
677
|
+
envoy_api_v2_route_RouteMatch_headers(match, &num_headers);
|
678
|
+
if (num_headers > 0) {
|
679
|
+
fields.emplace_back(
|
680
|
+
absl::StrCat(" headers: <", num_headers, " element(s)>"));
|
681
|
+
}
|
682
|
+
fields.emplace_back(" }");
|
683
|
+
}
|
684
|
+
// action
|
685
|
+
if (envoy_api_v2_route_Route_has_route(route)) {
|
686
|
+
const envoy_api_v2_route_RouteAction* action =
|
687
|
+
envoy_api_v2_route_Route_route(route);
|
688
|
+
fields.emplace_back(" route {");
|
689
|
+
if (envoy_api_v2_route_RouteAction_has_cluster(action)) {
|
690
|
+
AddStringField(" cluster",
|
691
|
+
envoy_api_v2_route_RouteAction_cluster(action),
|
692
|
+
&fields);
|
693
|
+
} else if (envoy_api_v2_route_RouteAction_has_cluster_header(
|
694
|
+
action)) {
|
695
|
+
AddStringField(
|
696
|
+
" cluster_header",
|
697
|
+
envoy_api_v2_route_RouteAction_cluster_header(action), &fields);
|
698
|
+
} else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
|
699
|
+
action)) {
|
700
|
+
const envoy_api_v2_route_WeightedCluster* weighted_clusters =
|
701
|
+
envoy_api_v2_route_RouteAction_weighted_clusters(action);
|
702
|
+
fields.emplace_back(" weighted_clusters {");
|
703
|
+
size_t num_cluster_weights;
|
704
|
+
const envoy_api_v2_route_WeightedCluster_ClusterWeight* const*
|
705
|
+
cluster_weights = envoy_api_v2_route_WeightedCluster_clusters(
|
706
|
+
weighted_clusters, &num_cluster_weights);
|
707
|
+
for (size_t i = 0; i < num_cluster_weights; ++i) {
|
708
|
+
const envoy_api_v2_route_WeightedCluster_ClusterWeight*
|
709
|
+
cluster_weight = cluster_weights[i];
|
710
|
+
fields.emplace_back(" clusters {");
|
711
|
+
AddStringField(
|
712
|
+
" name",
|
713
|
+
envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
|
714
|
+
cluster_weight),
|
715
|
+
&fields);
|
716
|
+
AddUInt32ValueField(
|
717
|
+
" weight",
|
718
|
+
envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
|
719
|
+
cluster_weight),
|
720
|
+
&fields);
|
721
|
+
fields.emplace_back(" }");
|
722
|
+
}
|
723
|
+
AddUInt32ValueField(" total_weight",
|
724
|
+
envoy_api_v2_route_WeightedCluster_total_weight(
|
725
|
+
weighted_clusters),
|
726
|
+
&fields);
|
727
|
+
fields.emplace_back(" }");
|
728
|
+
}
|
729
|
+
fields.emplace_back(" }");
|
730
|
+
} else if (envoy_api_v2_route_Route_has_redirect(route)) {
|
731
|
+
fields.emplace_back(" redirect: <not printed>");
|
732
|
+
} else if (envoy_api_v2_route_Route_has_direct_response(route)) {
|
733
|
+
fields.emplace_back(" direct_response: <not printed>");
|
734
|
+
} else if (envoy_api_v2_route_Route_has_filter_action(route)) {
|
735
|
+
fields.emplace_back(" filter_action: <not printed>");
|
736
|
+
}
|
737
|
+
fields.push_back(" }");
|
738
|
+
}
|
739
|
+
fields.push_back("}");
|
740
|
+
}
|
741
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client,
|
742
|
+
absl::StrJoin(fields, "\n").c_str());
|
373
743
|
}
|
374
|
-
return SerializeDiscoveryRequest(arena.ptr(), request);
|
375
744
|
}
|
376
745
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
746
|
+
void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
|
747
|
+
const envoy_api_v2_Cluster* cluster) {
|
748
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
749
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
750
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
751
|
+
// the raw proto instead of doing this manually.
|
752
|
+
std::vector<std::string> fields;
|
753
|
+
// name
|
754
|
+
AddStringField("name", envoy_api_v2_Cluster_name(cluster), &fields);
|
755
|
+
// type
|
756
|
+
if (envoy_api_v2_Cluster_has_type(cluster)) {
|
757
|
+
fields.emplace_back(
|
758
|
+
absl::StrCat("type: ", envoy_api_v2_Cluster_type(cluster)));
|
759
|
+
} else if (envoy_api_v2_Cluster_has_cluster_type(cluster)) {
|
760
|
+
fields.emplace_back("cluster_type: <not printed>");
|
761
|
+
} else {
|
762
|
+
fields.emplace_back("<unknown type>");
|
763
|
+
}
|
764
|
+
// eds_cluster_config
|
765
|
+
const envoy_api_v2_Cluster_EdsClusterConfig* eds_cluster_config =
|
766
|
+
envoy_api_v2_Cluster_eds_cluster_config(cluster);
|
767
|
+
if (eds_cluster_config != nullptr) {
|
768
|
+
fields.emplace_back("eds_cluster_config {");
|
769
|
+
// eds_config
|
770
|
+
const struct envoy_api_v2_core_ConfigSource* eds_config =
|
771
|
+
envoy_api_v2_Cluster_EdsClusterConfig_eds_config(eds_cluster_config);
|
772
|
+
if (eds_config != nullptr) {
|
773
|
+
if (envoy_api_v2_core_ConfigSource_has_ads(eds_config)) {
|
774
|
+
fields.emplace_back(" eds_config { ads {} }");
|
775
|
+
} else {
|
776
|
+
fields.emplace_back(" eds_config: <non-ADS type>");
|
777
|
+
}
|
778
|
+
}
|
779
|
+
// service_name
|
780
|
+
AddStringField(" service_name",
|
781
|
+
envoy_api_v2_Cluster_EdsClusterConfig_service_name(
|
782
|
+
eds_cluster_config),
|
783
|
+
&fields);
|
784
|
+
fields.emplace_back("}");
|
785
|
+
}
|
786
|
+
// lb_policy
|
787
|
+
fields.emplace_back(
|
788
|
+
absl::StrCat("lb_policy: ", envoy_api_v2_Cluster_lb_policy(cluster)));
|
789
|
+
// lrs_server
|
790
|
+
const envoy_api_v2_core_ConfigSource* lrs_server =
|
791
|
+
envoy_api_v2_Cluster_lrs_server(cluster);
|
792
|
+
if (lrs_server != nullptr) {
|
793
|
+
if (envoy_api_v2_core_ConfigSource_has_self(lrs_server)) {
|
794
|
+
fields.emplace_back("lrs_server { self {} }");
|
795
|
+
} else {
|
796
|
+
fields.emplace_back("lrs_server: <non-self type>");
|
797
|
+
}
|
798
|
+
}
|
799
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client,
|
800
|
+
absl::StrJoin(fields, "\n").c_str());
|
396
801
|
}
|
397
|
-
return SerializeDiscoveryRequest(arena.ptr(), request);
|
398
802
|
}
|
399
803
|
|
400
|
-
|
804
|
+
void MaybeLogClusterLoadAssignment(
|
805
|
+
XdsClient* client, TraceFlag* tracer,
|
806
|
+
const envoy_api_v2_ClusterLoadAssignment* cla) {
|
807
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
808
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
809
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
810
|
+
// the raw proto instead of doing this manually.
|
811
|
+
std::vector<std::string> fields;
|
812
|
+
// cluster_name
|
813
|
+
AddStringField("cluster_name",
|
814
|
+
envoy_api_v2_ClusterLoadAssignment_cluster_name(cla),
|
815
|
+
&fields);
|
816
|
+
// endpoints
|
817
|
+
size_t num_localities;
|
818
|
+
const struct envoy_api_v2_endpoint_LocalityLbEndpoints* const*
|
819
|
+
locality_endpoints =
|
820
|
+
envoy_api_v2_ClusterLoadAssignment_endpoints(cla, &num_localities);
|
821
|
+
for (size_t i = 0; i < num_localities; ++i) {
|
822
|
+
const auto* locality_endpoint = locality_endpoints[i];
|
823
|
+
fields.emplace_back("endpoints {");
|
824
|
+
// locality
|
825
|
+
const auto* locality =
|
826
|
+
envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_endpoint);
|
827
|
+
if (locality != nullptr) {
|
828
|
+
fields.emplace_back(" locality {");
|
829
|
+
AddLocalityField(2, locality, &fields);
|
830
|
+
fields.emplace_back(" }");
|
831
|
+
}
|
832
|
+
// lb_endpoints
|
833
|
+
size_t num_lb_endpoints;
|
834
|
+
const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints =
|
835
|
+
envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(
|
836
|
+
locality_endpoint, &num_lb_endpoints);
|
837
|
+
for (size_t j = 0; j < num_lb_endpoints; ++j) {
|
838
|
+
const auto* lb_endpoint = lb_endpoints[j];
|
839
|
+
fields.emplace_back(" lb_endpoints {");
|
840
|
+
// health_status
|
841
|
+
uint32_t health_status =
|
842
|
+
envoy_api_v2_endpoint_LbEndpoint_health_status(lb_endpoint);
|
843
|
+
if (health_status > 0) {
|
844
|
+
fields.emplace_back(
|
845
|
+
absl::StrCat(" health_status: ", health_status));
|
846
|
+
}
|
847
|
+
// endpoint
|
848
|
+
const envoy_api_v2_endpoint_Endpoint* endpoint =
|
849
|
+
envoy_api_v2_endpoint_LbEndpoint_endpoint(lb_endpoint);
|
850
|
+
if (endpoint != nullptr) {
|
851
|
+
fields.emplace_back(" endpoint {");
|
852
|
+
// address
|
853
|
+
const auto* address =
|
854
|
+
envoy_api_v2_endpoint_Endpoint_address(endpoint);
|
855
|
+
if (address != nullptr) {
|
856
|
+
fields.emplace_back(" address {");
|
857
|
+
// socket_address
|
858
|
+
const auto* socket_address =
|
859
|
+
envoy_api_v2_core_Address_socket_address(address);
|
860
|
+
if (socket_address != nullptr) {
|
861
|
+
fields.emplace_back(" socket_address {");
|
862
|
+
// address
|
863
|
+
AddStringField(
|
864
|
+
" address",
|
865
|
+
envoy_api_v2_core_SocketAddress_address(socket_address),
|
866
|
+
&fields);
|
867
|
+
// port_value
|
868
|
+
if (envoy_api_v2_core_SocketAddress_has_port_value(
|
869
|
+
socket_address)) {
|
870
|
+
fields.emplace_back(
|
871
|
+
absl::StrCat(" port_value: ",
|
872
|
+
envoy_api_v2_core_SocketAddress_port_value(
|
873
|
+
socket_address)));
|
874
|
+
} else {
|
875
|
+
fields.emplace_back(" <non-numeric port>");
|
876
|
+
}
|
877
|
+
fields.emplace_back(" }");
|
878
|
+
} else {
|
879
|
+
fields.emplace_back(" <non-socket address>");
|
880
|
+
}
|
881
|
+
fields.emplace_back(" }");
|
882
|
+
}
|
883
|
+
fields.emplace_back(" }");
|
884
|
+
}
|
885
|
+
fields.emplace_back(" }");
|
886
|
+
}
|
887
|
+
// load_balancing_weight
|
888
|
+
AddUInt32ValueField(
|
889
|
+
" load_balancing_weight",
|
890
|
+
envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(
|
891
|
+
locality_endpoint),
|
892
|
+
&fields);
|
893
|
+
// priority
|
894
|
+
uint32_t priority =
|
895
|
+
envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_endpoint);
|
896
|
+
if (priority > 0) {
|
897
|
+
fields.emplace_back(absl::StrCat(" priority: ", priority));
|
898
|
+
}
|
899
|
+
fields.emplace_back("}");
|
900
|
+
}
|
901
|
+
// policy
|
902
|
+
const envoy_api_v2_ClusterLoadAssignment_Policy* policy =
|
903
|
+
envoy_api_v2_ClusterLoadAssignment_policy(cla);
|
904
|
+
if (policy != nullptr) {
|
905
|
+
fields.emplace_back("policy {");
|
906
|
+
// drop_overloads
|
907
|
+
size_t num_drop_overloads;
|
908
|
+
const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const*
|
909
|
+
drop_overloads =
|
910
|
+
envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(
|
911
|
+
policy, &num_drop_overloads);
|
912
|
+
for (size_t i = 0; i < num_drop_overloads; ++i) {
|
913
|
+
auto* drop_overload = drop_overloads[i];
|
914
|
+
fields.emplace_back(" drop_overloads {");
|
915
|
+
// category
|
916
|
+
AddStringField(
|
917
|
+
" category",
|
918
|
+
envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_category(
|
919
|
+
drop_overload),
|
920
|
+
&fields);
|
921
|
+
// drop_percentage
|
922
|
+
const auto* drop_percentage =
|
923
|
+
envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
|
924
|
+
drop_overload);
|
925
|
+
if (drop_percentage != nullptr) {
|
926
|
+
fields.emplace_back(" drop_percentage {");
|
927
|
+
fields.emplace_back(absl::StrCat(
|
928
|
+
" numerator: ",
|
929
|
+
envoy_type_FractionalPercent_numerator(drop_percentage)));
|
930
|
+
fields.emplace_back(absl::StrCat(
|
931
|
+
" denominator: ",
|
932
|
+
envoy_type_FractionalPercent_denominator(drop_percentage)));
|
933
|
+
fields.emplace_back(" }");
|
934
|
+
}
|
935
|
+
fields.emplace_back(" }");
|
936
|
+
}
|
937
|
+
// overprovisioning_factor
|
938
|
+
fields.emplace_back("}");
|
939
|
+
}
|
940
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s", client,
|
941
|
+
absl::StrJoin(fields, "\n").c_str());
|
942
|
+
}
|
943
|
+
}
|
401
944
|
|
402
945
|
// Better match type has smaller value.
|
403
946
|
enum MatchType {
|
@@ -423,16 +966,18 @@ bool DomainMatch(MatchType match_type, std::string domain_pattern,
|
|
423
966
|
} else if (match_type == SUFFIX_MATCH) {
|
424
967
|
// Asterisk must match at least one char.
|
425
968
|
if (expected_host_name.size() < domain_pattern.size()) return false;
|
426
|
-
|
427
|
-
|
428
|
-
|
969
|
+
absl::string_view pattern_suffix(domain_pattern.c_str() + 1);
|
970
|
+
absl::string_view host_suffix(expected_host_name.c_str() +
|
971
|
+
expected_host_name.size() -
|
972
|
+
pattern_suffix.size());
|
429
973
|
return pattern_suffix == host_suffix;
|
430
974
|
} else if (match_type == PREFIX_MATCH) {
|
431
975
|
// Asterisk must match at least one char.
|
432
976
|
if (expected_host_name.size() < domain_pattern.size()) return false;
|
433
|
-
|
434
|
-
|
435
|
-
|
977
|
+
absl::string_view pattern_prefix(domain_pattern.c_str(),
|
978
|
+
domain_pattern.size() - 1);
|
979
|
+
absl::string_view host_prefix(expected_host_name.c_str(),
|
980
|
+
pattern_prefix.size());
|
436
981
|
return pattern_prefix == host_prefix;
|
437
982
|
} else {
|
438
983
|
return match_type == UNIVERSE_MATCH;
|
@@ -448,12 +993,272 @@ MatchType DomainPatternMatchType(const std::string& domain_pattern) {
|
|
448
993
|
return INVALID_MATCH;
|
449
994
|
}
|
450
995
|
|
996
|
+
grpc_error* RoutePathMatchParse(const envoy_api_v2_route_RouteMatch* match,
|
997
|
+
XdsApi::RdsUpdate::RdsRoute* rds_route,
|
998
|
+
bool* ignore_route) {
|
999
|
+
if (envoy_api_v2_route_RouteMatch_has_prefix(match)) {
|
1000
|
+
upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
|
1001
|
+
// Empty prefix "" is accepted.
|
1002
|
+
if (prefix.size > 0) {
|
1003
|
+
// Prefix "/" is accepted.
|
1004
|
+
if (prefix.data[0] != '/') {
|
1005
|
+
// Prefix which does not start with a / will never match anything, so
|
1006
|
+
// ignore this route.
|
1007
|
+
*ignore_route = true;
|
1008
|
+
return GRPC_ERROR_NONE;
|
1009
|
+
}
|
1010
|
+
std::vector<absl::string_view> prefix_elements =
|
1011
|
+
absl::StrSplit(absl::string_view(prefix.data, prefix.size).substr(1),
|
1012
|
+
absl::MaxSplits('/', 2));
|
1013
|
+
if (prefix_elements.size() > 2) {
|
1014
|
+
// Prefix cannot have more than 2 slashes.
|
1015
|
+
*ignore_route = true;
|
1016
|
+
return GRPC_ERROR_NONE;
|
1017
|
+
} else if (prefix_elements.size() == 2 && prefix_elements[0].empty()) {
|
1018
|
+
// Prefix contains empty string between the 2 slashes
|
1019
|
+
*ignore_route = true;
|
1020
|
+
return GRPC_ERROR_NONE;
|
1021
|
+
}
|
1022
|
+
}
|
1023
|
+
rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
1024
|
+
Matchers::PathMatcher::PathMatcherType::PREFIX;
|
1025
|
+
rds_route->matchers.path_matcher.string_matcher =
|
1026
|
+
UpbStringToStdString(prefix);
|
1027
|
+
} else if (envoy_api_v2_route_RouteMatch_has_path(match)) {
|
1028
|
+
upb_strview path = envoy_api_v2_route_RouteMatch_path(match);
|
1029
|
+
if (path.size == 0) {
|
1030
|
+
// Path that is empty will never match anything, so ignore this route.
|
1031
|
+
*ignore_route = true;
|
1032
|
+
return GRPC_ERROR_NONE;
|
1033
|
+
}
|
1034
|
+
if (path.data[0] != '/') {
|
1035
|
+
// Path which does not start with a / will never match anything, so
|
1036
|
+
// ignore this route.
|
1037
|
+
*ignore_route = true;
|
1038
|
+
return GRPC_ERROR_NONE;
|
1039
|
+
}
|
1040
|
+
std::vector<absl::string_view> path_elements =
|
1041
|
+
absl::StrSplit(absl::string_view(path.data, path.size).substr(1),
|
1042
|
+
absl::MaxSplits('/', 2));
|
1043
|
+
if (path_elements.size() != 2) {
|
1044
|
+
// Path not in the required format of /service/method will never match
|
1045
|
+
// anything, so ignore this route.
|
1046
|
+
*ignore_route = true;
|
1047
|
+
return GRPC_ERROR_NONE;
|
1048
|
+
} else if (path_elements[0].empty()) {
|
1049
|
+
// Path contains empty service name will never match anything, so ignore
|
1050
|
+
// this route.
|
1051
|
+
*ignore_route = true;
|
1052
|
+
return GRPC_ERROR_NONE;
|
1053
|
+
} else if (path_elements[1].empty()) {
|
1054
|
+
// Path contains empty method name will never match anything, so ignore
|
1055
|
+
// this route.
|
1056
|
+
*ignore_route = true;
|
1057
|
+
return GRPC_ERROR_NONE;
|
1058
|
+
}
|
1059
|
+
rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
1060
|
+
Matchers::PathMatcher::PathMatcherType::PATH;
|
1061
|
+
rds_route->matchers.path_matcher.string_matcher =
|
1062
|
+
UpbStringToStdString(path);
|
1063
|
+
} else if (envoy_api_v2_route_RouteMatch_has_safe_regex(match)) {
|
1064
|
+
const envoy_type_matcher_RegexMatcher* regex_matcher =
|
1065
|
+
envoy_api_v2_route_RouteMatch_safe_regex(match);
|
1066
|
+
GPR_ASSERT(regex_matcher != nullptr);
|
1067
|
+
const std::string matcher = UpbStringToStdString(
|
1068
|
+
envoy_type_matcher_RegexMatcher_regex(regex_matcher));
|
1069
|
+
std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
|
1070
|
+
if (!regex->ok()) {
|
1071
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1072
|
+
"Invalid regex string specified in path matcher.");
|
1073
|
+
}
|
1074
|
+
rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
|
1075
|
+
Matchers::PathMatcher::PathMatcherType::REGEX;
|
1076
|
+
rds_route->matchers.path_matcher.regex_matcher = std::move(regex);
|
1077
|
+
} else {
|
1078
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1079
|
+
"Invalid route path specifier specified.");
|
1080
|
+
}
|
1081
|
+
return GRPC_ERROR_NONE;
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
grpc_error* RouteHeaderMatchersParse(const envoy_api_v2_route_RouteMatch* match,
|
1085
|
+
XdsApi::RdsUpdate::RdsRoute* rds_route) {
|
1086
|
+
size_t size;
|
1087
|
+
const envoy_api_v2_route_HeaderMatcher* const* headers =
|
1088
|
+
envoy_api_v2_route_RouteMatch_headers(match, &size);
|
1089
|
+
for (size_t i = 0; i < size; ++i) {
|
1090
|
+
const envoy_api_v2_route_HeaderMatcher* header = headers[i];
|
1091
|
+
XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher header_matcher;
|
1092
|
+
header_matcher.name =
|
1093
|
+
UpbStringToStdString(envoy_api_v2_route_HeaderMatcher_name(header));
|
1094
|
+
if (envoy_api_v2_route_HeaderMatcher_has_exact_match(header)) {
|
1095
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1096
|
+
HeaderMatcher::HeaderMatcherType::EXACT;
|
1097
|
+
header_matcher.string_matcher = UpbStringToStdString(
|
1098
|
+
envoy_api_v2_route_HeaderMatcher_exact_match(header));
|
1099
|
+
} else if (envoy_api_v2_route_HeaderMatcher_has_safe_regex_match(header)) {
|
1100
|
+
const envoy_type_matcher_RegexMatcher* regex_matcher =
|
1101
|
+
envoy_api_v2_route_HeaderMatcher_safe_regex_match(header);
|
1102
|
+
GPR_ASSERT(regex_matcher != nullptr);
|
1103
|
+
const std::string matcher = UpbStringToStdString(
|
1104
|
+
envoy_type_matcher_RegexMatcher_regex(regex_matcher));
|
1105
|
+
std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
|
1106
|
+
if (!regex->ok()) {
|
1107
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1108
|
+
"Invalid regex string specified in header matcher.");
|
1109
|
+
}
|
1110
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1111
|
+
HeaderMatcher::HeaderMatcherType::REGEX;
|
1112
|
+
header_matcher.regex_match = std::move(regex);
|
1113
|
+
} else if (envoy_api_v2_route_HeaderMatcher_has_range_match(header)) {
|
1114
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1115
|
+
HeaderMatcher::HeaderMatcherType::RANGE;
|
1116
|
+
const envoy_type_Int64Range* range_matcher =
|
1117
|
+
envoy_api_v2_route_HeaderMatcher_range_match(header);
|
1118
|
+
header_matcher.range_start = envoy_type_Int64Range_start(range_matcher);
|
1119
|
+
header_matcher.range_end = envoy_type_Int64Range_end(range_matcher);
|
1120
|
+
if (header_matcher.range_end < header_matcher.range_start) {
|
1121
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1122
|
+
"Invalid range header matcher specifier specified: end "
|
1123
|
+
"cannot be smaller than start.");
|
1124
|
+
}
|
1125
|
+
} else if (envoy_api_v2_route_HeaderMatcher_has_present_match(header)) {
|
1126
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1127
|
+
HeaderMatcher::HeaderMatcherType::PRESENT;
|
1128
|
+
header_matcher.present_match =
|
1129
|
+
envoy_api_v2_route_HeaderMatcher_present_match(header);
|
1130
|
+
} else if (envoy_api_v2_route_HeaderMatcher_has_prefix_match(header)) {
|
1131
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1132
|
+
HeaderMatcher::HeaderMatcherType::PREFIX;
|
1133
|
+
header_matcher.string_matcher = UpbStringToStdString(
|
1134
|
+
envoy_api_v2_route_HeaderMatcher_prefix_match(header));
|
1135
|
+
} else if (envoy_api_v2_route_HeaderMatcher_has_suffix_match(header)) {
|
1136
|
+
header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
|
1137
|
+
HeaderMatcher::HeaderMatcherType::SUFFIX;
|
1138
|
+
header_matcher.string_matcher = UpbStringToStdString(
|
1139
|
+
envoy_api_v2_route_HeaderMatcher_suffix_match(header));
|
1140
|
+
} else {
|
1141
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1142
|
+
"Invalid route header matcher specified.");
|
1143
|
+
}
|
1144
|
+
header_matcher.invert_match =
|
1145
|
+
envoy_api_v2_route_HeaderMatcher_invert_match(header);
|
1146
|
+
rds_route->matchers.header_matchers.emplace_back(std::move(header_matcher));
|
1147
|
+
}
|
1148
|
+
return GRPC_ERROR_NONE;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
grpc_error* RouteRuntimeFractionParse(
|
1152
|
+
const envoy_api_v2_route_RouteMatch* match,
|
1153
|
+
XdsApi::RdsUpdate::RdsRoute* rds_route) {
|
1154
|
+
const envoy_api_v2_core_RuntimeFractionalPercent* runtime_fraction =
|
1155
|
+
envoy_api_v2_route_RouteMatch_runtime_fraction(match);
|
1156
|
+
if (runtime_fraction != nullptr) {
|
1157
|
+
const envoy_type_FractionalPercent* fraction =
|
1158
|
+
envoy_api_v2_core_RuntimeFractionalPercent_default_value(
|
1159
|
+
runtime_fraction);
|
1160
|
+
if (fraction != nullptr) {
|
1161
|
+
uint32_t numerator = envoy_type_FractionalPercent_numerator(fraction);
|
1162
|
+
const auto denominator =
|
1163
|
+
static_cast<envoy_type_FractionalPercent_DenominatorType>(
|
1164
|
+
envoy_type_FractionalPercent_denominator(fraction));
|
1165
|
+
// Normalize to million.
|
1166
|
+
switch (denominator) {
|
1167
|
+
case envoy_type_FractionalPercent_HUNDRED:
|
1168
|
+
numerator *= 10000;
|
1169
|
+
break;
|
1170
|
+
case envoy_type_FractionalPercent_TEN_THOUSAND:
|
1171
|
+
numerator *= 100;
|
1172
|
+
break;
|
1173
|
+
case envoy_type_FractionalPercent_MILLION:
|
1174
|
+
break;
|
1175
|
+
default:
|
1176
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1177
|
+
"Unknown denominator type");
|
1178
|
+
}
|
1179
|
+
rds_route->matchers.fraction_per_million = numerator;
|
1180
|
+
}
|
1181
|
+
}
|
1182
|
+
return GRPC_ERROR_NONE;
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
|
1186
|
+
XdsApi::RdsUpdate::RdsRoute* rds_route,
|
1187
|
+
bool* ignore_route) {
|
1188
|
+
if (!envoy_api_v2_route_Route_has_route(route)) {
|
1189
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1190
|
+
"No RouteAction found in route.");
|
1191
|
+
}
|
1192
|
+
const envoy_api_v2_route_RouteAction* route_action =
|
1193
|
+
envoy_api_v2_route_Route_route(route);
|
1194
|
+
// Get the cluster or weighted_clusters in the RouteAction.
|
1195
|
+
if (envoy_api_v2_route_RouteAction_has_cluster(route_action)) {
|
1196
|
+
const upb_strview cluster_name =
|
1197
|
+
envoy_api_v2_route_RouteAction_cluster(route_action);
|
1198
|
+
if (cluster_name.size == 0) {
|
1199
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1200
|
+
"RouteAction cluster contains empty cluster name.");
|
1201
|
+
}
|
1202
|
+
rds_route->cluster_name = UpbStringToStdString(cluster_name);
|
1203
|
+
} else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
|
1204
|
+
route_action)) {
|
1205
|
+
const envoy_api_v2_route_WeightedCluster* weighted_cluster =
|
1206
|
+
envoy_api_v2_route_RouteAction_weighted_clusters(route_action);
|
1207
|
+
uint32_t total_weight = 100;
|
1208
|
+
const google_protobuf_UInt32Value* weight =
|
1209
|
+
envoy_api_v2_route_WeightedCluster_total_weight(weighted_cluster);
|
1210
|
+
if (weight != nullptr) {
|
1211
|
+
total_weight = google_protobuf_UInt32Value_value(weight);
|
1212
|
+
}
|
1213
|
+
size_t clusters_size;
|
1214
|
+
const envoy_api_v2_route_WeightedCluster_ClusterWeight* const* clusters =
|
1215
|
+
envoy_api_v2_route_WeightedCluster_clusters(weighted_cluster,
|
1216
|
+
&clusters_size);
|
1217
|
+
uint32_t sum_of_weights = 0;
|
1218
|
+
for (size_t j = 0; j < clusters_size; ++j) {
|
1219
|
+
const envoy_api_v2_route_WeightedCluster_ClusterWeight* cluster_weight =
|
1220
|
+
clusters[j];
|
1221
|
+
XdsApi::RdsUpdate::RdsRoute::ClusterWeight cluster;
|
1222
|
+
cluster.name = UpbStringToStdString(
|
1223
|
+
envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
|
1224
|
+
cluster_weight));
|
1225
|
+
if (cluster.name.empty()) {
|
1226
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1227
|
+
"RouteAction weighted_cluster cluster contains empty cluster "
|
1228
|
+
"name.");
|
1229
|
+
}
|
1230
|
+
const google_protobuf_UInt32Value* weight =
|
1231
|
+
envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
|
1232
|
+
cluster_weight);
|
1233
|
+
if (weight == nullptr) {
|
1234
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1235
|
+
"RouteAction weighted_cluster cluster missing weight");
|
1236
|
+
}
|
1237
|
+
cluster.weight = google_protobuf_UInt32Value_value(weight);
|
1238
|
+
sum_of_weights += cluster.weight;
|
1239
|
+
rds_route->weighted_clusters.emplace_back(std::move(cluster));
|
1240
|
+
}
|
1241
|
+
if (total_weight != sum_of_weights) {
|
1242
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1243
|
+
"RouteAction weighted_cluster has incorrect total weight");
|
1244
|
+
}
|
1245
|
+
if (rds_route->weighted_clusters.empty()) {
|
1246
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1247
|
+
"RouteAction weighted_cluster has no valid clusters specified.");
|
1248
|
+
}
|
1249
|
+
} else {
|
1250
|
+
// No cluster or weighted_clusters found in RouteAction, ignore this route.
|
1251
|
+
*ignore_route = true;
|
1252
|
+
return GRPC_ERROR_NONE;
|
1253
|
+
}
|
1254
|
+
return GRPC_ERROR_NONE;
|
1255
|
+
}
|
1256
|
+
|
451
1257
|
grpc_error* RouteConfigParse(
|
1258
|
+
XdsClient* client, TraceFlag* tracer,
|
452
1259
|
const envoy_api_v2_RouteConfiguration* route_config,
|
453
1260
|
const std::string& expected_server_name, XdsApi::RdsUpdate* rds_update) {
|
454
|
-
|
455
|
-
size_t pos = expected_server_name.find(':');
|
456
|
-
std::string expected_host_name = expected_server_name.substr(0, pos);
|
1261
|
+
MaybeLogRouteConfiguration(client, tracer, route_config);
|
457
1262
|
// Get the virtual hosts.
|
458
1263
|
size_t size;
|
459
1264
|
const envoy_api_v2_route_VirtualHost* const* virtual_hosts =
|
@@ -490,7 +1295,7 @@ grpc_error* RouteConfigParse(
|
|
490
1295
|
continue;
|
491
1296
|
}
|
492
1297
|
// Skip if match fails.
|
493
|
-
if (!DomainMatch(match_type, domain_pattern,
|
1298
|
+
if (!DomainMatch(match_type, domain_pattern, expected_server_name)) {
|
494
1299
|
continue;
|
495
1300
|
}
|
496
1301
|
// Choose this match.
|
@@ -512,48 +1317,53 @@ grpc_error* RouteConfigParse(
|
|
512
1317
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
513
1318
|
"No route found in the virtual host.");
|
514
1319
|
}
|
515
|
-
//
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
1320
|
+
// Loop over the whole list of routes
|
1321
|
+
for (size_t i = 0; i < size; ++i) {
|
1322
|
+
const envoy_api_v2_route_Route* route = routes[i];
|
1323
|
+
const envoy_api_v2_route_RouteMatch* match =
|
1324
|
+
envoy_api_v2_route_Route_match(route);
|
1325
|
+
size_t query_parameters_size;
|
1326
|
+
static_cast<void>(envoy_api_v2_route_RouteMatch_query_parameters(
|
1327
|
+
match, &query_parameters_size));
|
1328
|
+
if (query_parameters_size > 0) {
|
1329
|
+
continue;
|
1330
|
+
}
|
1331
|
+
XdsApi::RdsUpdate::RdsRoute rds_route;
|
1332
|
+
bool ignore_route = false;
|
1333
|
+
grpc_error* error = RoutePathMatchParse(match, &rds_route, &ignore_route);
|
1334
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1335
|
+
if (ignore_route) continue;
|
1336
|
+
error = RouteHeaderMatchersParse(match, &rds_route);
|
1337
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1338
|
+
error = RouteRuntimeFractionParse(match, &rds_route);
|
1339
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1340
|
+
error = RouteActionParse(route, &rds_route, &ignore_route);
|
1341
|
+
if (error != GRPC_ERROR_NONE) return error;
|
1342
|
+
if (ignore_route) continue;
|
1343
|
+
const google_protobuf_BoolValue* case_sensitive =
|
1344
|
+
envoy_api_v2_route_RouteMatch_case_sensitive(match);
|
1345
|
+
if (case_sensitive != nullptr &&
|
1346
|
+
!google_protobuf_BoolValue_value(case_sensitive)) {
|
1347
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1348
|
+
"case_sensitive if set must be set to true.");
|
1349
|
+
}
|
1350
|
+
rds_update->routes.emplace_back(std::move(rds_route));
|
532
1351
|
}
|
533
|
-
|
534
|
-
|
535
|
-
// Get the cluster in the RouteAction.
|
536
|
-
if (!envoy_api_v2_route_RouteAction_has_cluster(route_action)) {
|
537
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
538
|
-
"No cluster found in RouteAction.");
|
1352
|
+
if (rds_update->routes.empty()) {
|
1353
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified.");
|
539
1354
|
}
|
540
|
-
const upb_strview cluster =
|
541
|
-
envoy_api_v2_route_RouteAction_cluster(route_action);
|
542
|
-
rds_update->cluster_name = std::string(cluster.data, cluster.size);
|
543
1355
|
return GRPC_ERROR_NONE;
|
544
1356
|
}
|
545
1357
|
|
546
|
-
grpc_error* LdsResponseParse(
|
1358
|
+
grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
|
1359
|
+
const envoy_api_v2_DiscoveryResponse* response,
|
547
1360
|
const std::string& expected_server_name,
|
548
|
-
XdsApi::LdsUpdate
|
1361
|
+
absl::optional<XdsApi::LdsUpdate>* lds_update,
|
1362
|
+
upb_arena* arena) {
|
549
1363
|
// Get the resources from the response.
|
550
1364
|
size_t size;
|
551
1365
|
const google_protobuf_Any* const* resources =
|
552
1366
|
envoy_api_v2_DiscoveryResponse_resources(response, &size);
|
553
|
-
if (size < 1) {
|
554
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
555
|
-
"LDS response contains 0 resource.");
|
556
|
-
}
|
557
1367
|
for (size_t i = 0; i < size; ++i) {
|
558
1368
|
// Check the type_url of the resource.
|
559
1369
|
const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
|
@@ -578,7 +1388,7 @@ grpc_error* LdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
578
1388
|
envoy_api_v2_Listener_api_listener(listener);
|
579
1389
|
if (api_listener == nullptr) {
|
580
1390
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
581
|
-
"Listener
|
1391
|
+
"Listener has no ApiListener.");
|
582
1392
|
}
|
583
1393
|
const upb_strview encoded_api_listener = google_protobuf_Any_value(
|
584
1394
|
envoy_config_listener_v2_ApiListener_api_listener(api_listener));
|
@@ -593,14 +1403,11 @@ grpc_error* LdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
593
1403
|
envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_route_config(
|
594
1404
|
http_connection_manager);
|
595
1405
|
XdsApi::RdsUpdate rds_update;
|
596
|
-
grpc_error* error =
|
597
|
-
|
1406
|
+
grpc_error* error = RouteConfigParse(client, tracer, route_config,
|
1407
|
+
expected_server_name, &rds_update);
|
598
1408
|
if (error != GRPC_ERROR_NONE) return error;
|
599
|
-
lds_update->
|
600
|
-
|
601
|
-
envoy_api_v2_RouteConfiguration_name(route_config);
|
602
|
-
lds_update->route_config_name =
|
603
|
-
std::string(route_config_name.data, route_config_name.size);
|
1409
|
+
lds_update->emplace();
|
1410
|
+
(*lds_update)->rds_update.emplace(std::move(rds_update));
|
604
1411
|
return GRPC_ERROR_NONE;
|
605
1412
|
}
|
606
1413
|
// Validate that RDS must be used to get the route_config dynamically.
|
@@ -609,33 +1416,41 @@ grpc_error* LdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
609
1416
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
610
1417
|
"HttpConnectionManager neither has inlined route_config nor RDS.");
|
611
1418
|
}
|
612
|
-
// Get the route_config_name.
|
613
1419
|
const envoy_config_filter_network_http_connection_manager_v2_Rds* rds =
|
614
1420
|
envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_rds(
|
615
1421
|
http_connection_manager);
|
616
|
-
|
617
|
-
|
1422
|
+
// Check that the ConfigSource specifies ADS.
|
1423
|
+
const envoy_api_v2_core_ConfigSource* config_source =
|
1424
|
+
envoy_config_filter_network_http_connection_manager_v2_Rds_config_source(
|
618
1425
|
rds);
|
619
|
-
|
620
|
-
|
1426
|
+
if (config_source == nullptr) {
|
1427
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1428
|
+
"HttpConnectionManager missing config_source for RDS.");
|
1429
|
+
}
|
1430
|
+
if (!envoy_api_v2_core_ConfigSource_has_ads(config_source)) {
|
1431
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1432
|
+
"HttpConnectionManager ConfigSource for RDS does not specify ADS.");
|
1433
|
+
}
|
1434
|
+
// Get the route_config_name.
|
1435
|
+
lds_update->emplace();
|
1436
|
+
(*lds_update)->route_config_name = UpbStringToStdString(
|
1437
|
+
envoy_config_filter_network_http_connection_manager_v2_Rds_route_config_name(
|
1438
|
+
rds));
|
621
1439
|
return GRPC_ERROR_NONE;
|
622
1440
|
}
|
623
|
-
return
|
624
|
-
"No listener found for expected server name.");
|
1441
|
+
return GRPC_ERROR_NONE;
|
625
1442
|
}
|
626
1443
|
|
627
|
-
grpc_error* RdsResponseParse(
|
628
|
-
|
629
|
-
|
630
|
-
|
1444
|
+
grpc_error* RdsResponseParse(
|
1445
|
+
XdsClient* client, TraceFlag* tracer,
|
1446
|
+
const envoy_api_v2_DiscoveryResponse* response,
|
1447
|
+
const std::string& expected_server_name,
|
1448
|
+
const std::set<absl::string_view>& expected_route_configuration_names,
|
1449
|
+
absl::optional<XdsApi::RdsUpdate>* rds_update, upb_arena* arena) {
|
631
1450
|
// Get the resources from the response.
|
632
1451
|
size_t size;
|
633
1452
|
const google_protobuf_Any* const* resources =
|
634
1453
|
envoy_api_v2_DiscoveryResponse_resources(response, &size);
|
635
|
-
if (size < 1) {
|
636
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
637
|
-
"RDS response contains 0 resource.");
|
638
|
-
}
|
639
1454
|
for (size_t i = 0; i < size; ++i) {
|
640
1455
|
// Check the type_url of the resource.
|
641
1456
|
const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
|
@@ -652,33 +1467,34 @@ grpc_error* RdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
652
1467
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
|
653
1468
|
}
|
654
1469
|
// Check route_config_name. Ignore unexpected route_config.
|
655
|
-
const upb_strview
|
656
|
-
|
657
|
-
|
658
|
-
|
1470
|
+
const upb_strview route_config_name =
|
1471
|
+
envoy_api_v2_RouteConfiguration_name(route_config);
|
1472
|
+
absl::string_view route_config_name_strview(route_config_name.data,
|
1473
|
+
route_config_name.size);
|
1474
|
+
if (expected_route_configuration_names.find(route_config_name_strview) ==
|
1475
|
+
expected_route_configuration_names.end()) {
|
1476
|
+
continue;
|
1477
|
+
}
|
659
1478
|
// Parse the route_config.
|
660
1479
|
XdsApi::RdsUpdate local_rds_update;
|
661
|
-
grpc_error* error =
|
662
|
-
|
1480
|
+
grpc_error* error = RouteConfigParse(
|
1481
|
+
client, tracer, route_config, expected_server_name, &local_rds_update);
|
663
1482
|
if (error != GRPC_ERROR_NONE) return error;
|
664
|
-
|
1483
|
+
rds_update->emplace(std::move(local_rds_update));
|
665
1484
|
return GRPC_ERROR_NONE;
|
666
1485
|
}
|
667
|
-
return
|
668
|
-
"No route config found for expected name.");
|
1486
|
+
return GRPC_ERROR_NONE;
|
669
1487
|
}
|
670
1488
|
|
671
|
-
grpc_error* CdsResponseParse(
|
672
|
-
|
673
|
-
|
1489
|
+
grpc_error* CdsResponseParse(
|
1490
|
+
XdsClient* client, TraceFlag* tracer,
|
1491
|
+
const envoy_api_v2_DiscoveryResponse* response,
|
1492
|
+
const std::set<absl::string_view>& expected_cluster_names,
|
1493
|
+
XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
|
674
1494
|
// Get the resources from the response.
|
675
1495
|
size_t size;
|
676
1496
|
const google_protobuf_Any* const* resources =
|
677
1497
|
envoy_api_v2_DiscoveryResponse_resources(response, &size);
|
678
|
-
if (size < 1) {
|
679
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
680
|
-
"CDS response contains 0 resource.");
|
681
|
-
}
|
682
1498
|
// Parse all the resources in the CDS response.
|
683
1499
|
for (size_t i = 0; i < size; ++i) {
|
684
1500
|
XdsApi::CdsUpdate cds_update;
|
@@ -694,6 +1510,15 @@ grpc_error* CdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
694
1510
|
if (cluster == nullptr) {
|
695
1511
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode cluster.");
|
696
1512
|
}
|
1513
|
+
MaybeLogCluster(client, tracer, cluster);
|
1514
|
+
// Ignore unexpected cluster names.
|
1515
|
+
upb_strview cluster_name = envoy_api_v2_Cluster_name(cluster);
|
1516
|
+
absl::string_view cluster_name_strview(cluster_name.data,
|
1517
|
+
cluster_name.size);
|
1518
|
+
if (expected_cluster_names.find(cluster_name_strview) ==
|
1519
|
+
expected_cluster_names.end()) {
|
1520
|
+
continue;
|
1521
|
+
}
|
697
1522
|
// Check the cluster_discovery_type.
|
698
1523
|
if (!envoy_api_v2_Cluster_has_type(cluster)) {
|
699
1524
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found.");
|
@@ -707,14 +1532,14 @@ grpc_error* CdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
707
1532
|
const envoy_api_v2_core_ConfigSource* eds_config =
|
708
1533
|
envoy_api_v2_Cluster_EdsClusterConfig_eds_config(eds_cluster_config);
|
709
1534
|
if (!envoy_api_v2_core_ConfigSource_has_ads(eds_config)) {
|
710
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1535
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1536
|
+
"EDS ConfigSource is not ADS.");
|
711
1537
|
}
|
712
1538
|
// Record EDS service_name (if any).
|
713
1539
|
upb_strview service_name =
|
714
1540
|
envoy_api_v2_Cluster_EdsClusterConfig_service_name(eds_cluster_config);
|
715
1541
|
if (service_name.size != 0) {
|
716
|
-
cds_update.eds_service_name =
|
717
|
-
std::string(service_name.data, service_name.size);
|
1542
|
+
cds_update.eds_service_name = UpbStringToStdString(service_name);
|
718
1543
|
}
|
719
1544
|
// Check the LB policy.
|
720
1545
|
if (envoy_api_v2_Cluster_lb_policy(cluster) !=
|
@@ -728,12 +1553,11 @@ grpc_error* CdsResponseParse(const envoy_api_v2_DiscoveryResponse* response,
|
|
728
1553
|
if (lrs_server != nullptr) {
|
729
1554
|
if (!envoy_api_v2_core_ConfigSource_has_self(lrs_server)) {
|
730
1555
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
731
|
-
"ConfigSource is not self.");
|
1556
|
+
"LRS ConfigSource is not self.");
|
732
1557
|
}
|
733
1558
|
cds_update.lrs_load_reporting_server_name.emplace("");
|
734
1559
|
}
|
735
|
-
|
736
|
-
cds_update_map->emplace(std::string(cluster_name.data, cluster_name.size),
|
1560
|
+
cds_update_map->emplace(UpbStringToStdString(cluster_name),
|
737
1561
|
std::move(cds_update));
|
738
1562
|
}
|
739
1563
|
return GRPC_ERROR_NONE;
|
@@ -794,8 +1618,8 @@ grpc_error* LocalityParse(
|
|
794
1618
|
upb_strview zone = envoy_api_v2_core_Locality_region(locality);
|
795
1619
|
upb_strview sub_zone = envoy_api_v2_core_Locality_sub_zone(locality);
|
796
1620
|
output_locality->name = MakeRefCounted<XdsLocalityName>(
|
797
|
-
|
798
|
-
|
1621
|
+
UpbStringToStdString(region), UpbStringToStdString(zone),
|
1622
|
+
UpbStringToStdString(sub_zone));
|
799
1623
|
// Parse the addresses.
|
800
1624
|
size_t size;
|
801
1625
|
const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints =
|
@@ -814,7 +1638,7 @@ grpc_error* LocalityParse(
|
|
814
1638
|
|
815
1639
|
grpc_error* DropParseAndAppend(
|
816
1640
|
const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* drop_overload,
|
817
|
-
XdsApi::DropConfig* drop_config
|
1641
|
+
XdsApi::DropConfig* drop_config) {
|
818
1642
|
// Get the category.
|
819
1643
|
upb_strview category =
|
820
1644
|
envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_category(
|
@@ -845,24 +1669,19 @@ grpc_error* DropParseAndAppend(
|
|
845
1669
|
}
|
846
1670
|
// Cap numerator to 1000000.
|
847
1671
|
numerator = GPR_MIN(numerator, 1000000);
|
848
|
-
|
849
|
-
drop_config->AddCategory(std::string(category.data, category.size),
|
850
|
-
numerator);
|
1672
|
+
drop_config->AddCategory(UpbStringToStdString(category), numerator);
|
851
1673
|
return GRPC_ERROR_NONE;
|
852
1674
|
}
|
853
1675
|
|
854
|
-
grpc_error*
|
1676
|
+
grpc_error* EdsResponseParse(
|
1677
|
+
XdsClient* client, TraceFlag* tracer,
|
855
1678
|
const envoy_api_v2_DiscoveryResponse* response,
|
856
|
-
const std::set<
|
1679
|
+
const std::set<absl::string_view>& expected_eds_service_names,
|
857
1680
|
XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
|
858
1681
|
// Get the resources from the response.
|
859
1682
|
size_t size;
|
860
1683
|
const google_protobuf_Any* const* resources =
|
861
1684
|
envoy_api_v2_DiscoveryResponse_resources(response, &size);
|
862
|
-
if (size < 1) {
|
863
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
864
|
-
"EDS response contains 0 resource.");
|
865
|
-
}
|
866
1685
|
for (size_t i = 0; i < size; ++i) {
|
867
1686
|
XdsApi::EdsUpdate eds_update;
|
868
1687
|
// Check the type_url of the resource.
|
@@ -881,11 +1700,13 @@ grpc_error* EdsResponsedParse(
|
|
881
1700
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
882
1701
|
"Can't parse cluster_load_assignment.");
|
883
1702
|
}
|
1703
|
+
MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
|
884
1704
|
// Check the cluster name (which actually means eds_service_name). Ignore
|
885
1705
|
// unexpected names.
|
886
1706
|
upb_strview cluster_name = envoy_api_v2_ClusterLoadAssignment_cluster_name(
|
887
1707
|
cluster_load_assignment);
|
888
|
-
|
1708
|
+
absl::string_view cluster_name_strview(cluster_name.data,
|
1709
|
+
cluster_name.size);
|
889
1710
|
if (expected_eds_service_names.find(cluster_name_strview) ==
|
890
1711
|
expected_eds_service_names.end()) {
|
891
1712
|
continue;
|
@@ -903,6 +1724,14 @@ grpc_error* EdsResponsedParse(
|
|
903
1724
|
if (locality.lb_weight == 0) continue;
|
904
1725
|
eds_update.priority_list_update.Add(locality);
|
905
1726
|
}
|
1727
|
+
for (uint32_t priority = 0;
|
1728
|
+
priority < eds_update.priority_list_update.size(); ++priority) {
|
1729
|
+
auto* locality_map = eds_update.priority_list_update.Find(priority);
|
1730
|
+
if (locality_map == nullptr || locality_map->size() == 0) {
|
1731
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1732
|
+
"EDS update includes sparse priority list");
|
1733
|
+
}
|
1734
|
+
}
|
906
1735
|
// Get the drop config.
|
907
1736
|
eds_update.drop_config = MakeRefCounted<XdsApi::DropConfig>();
|
908
1737
|
const envoy_api_v2_ClusterLoadAssignment_Policy* policy =
|
@@ -915,18 +1744,11 @@ grpc_error* EdsResponsedParse(
|
|
915
1744
|
policy, &drop_size);
|
916
1745
|
for (size_t j = 0; j < drop_size; ++j) {
|
917
1746
|
grpc_error* error =
|
918
|
-
DropParseAndAppend(drop_overload[j], eds_update.drop_config.get()
|
919
|
-
&eds_update.drop_all);
|
1747
|
+
DropParseAndAppend(drop_overload[j], eds_update.drop_config.get());
|
920
1748
|
if (error != GRPC_ERROR_NONE) return error;
|
921
1749
|
}
|
922
1750
|
}
|
923
|
-
|
924
|
-
if (eds_update.priority_list_update.empty() && !eds_update.drop_all) {
|
925
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
926
|
-
"EDS response doesn't contain any valid "
|
927
|
-
"locality but doesn't require to drop all calls.");
|
928
|
-
}
|
929
|
-
eds_update_map->emplace(std::string(cluster_name.data, cluster_name.size),
|
1751
|
+
eds_update_map->emplace(UpbStringToStdString(cluster_name),
|
930
1752
|
std::move(eds_update));
|
931
1753
|
}
|
932
1754
|
return GRPC_ERROR_NONE;
|
@@ -936,9 +1758,11 @@ grpc_error* EdsResponsedParse(
|
|
936
1758
|
|
937
1759
|
grpc_error* XdsApi::ParseAdsResponse(
|
938
1760
|
const grpc_slice& encoded_response, const std::string& expected_server_name,
|
939
|
-
const std::
|
940
|
-
const std::set<
|
941
|
-
|
1761
|
+
const std::set<absl::string_view>& expected_route_configuration_names,
|
1762
|
+
const std::set<absl::string_view>& expected_cluster_names,
|
1763
|
+
const std::set<absl::string_view>& expected_eds_service_names,
|
1764
|
+
absl::optional<LdsUpdate>* lds_update,
|
1765
|
+
absl::optional<RdsUpdate>* rds_update, CdsUpdateMap* cds_update_map,
|
942
1766
|
EdsUpdateMap* eds_update_map, std::string* version, std::string* nonce,
|
943
1767
|
std::string* type_url) {
|
944
1768
|
upb::Arena arena;
|
@@ -953,28 +1777,31 @@ grpc_error* XdsApi::ParseAdsResponse(
|
|
953
1777
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
954
1778
|
"Can't decode the whole response.");
|
955
1779
|
}
|
1780
|
+
MaybeLogDiscoveryResponse(client_, tracer_, response);
|
956
1781
|
// Record the type_url, the version_info, and the nonce of the response.
|
957
1782
|
upb_strview type_url_strview =
|
958
1783
|
envoy_api_v2_DiscoveryResponse_type_url(response);
|
959
|
-
*type_url =
|
1784
|
+
*type_url = UpbStringToStdString(type_url_strview);
|
960
1785
|
upb_strview version_info =
|
961
1786
|
envoy_api_v2_DiscoveryResponse_version_info(response);
|
962
|
-
*version =
|
1787
|
+
*version = UpbStringToStdString(version_info);
|
963
1788
|
upb_strview nonce_strview = envoy_api_v2_DiscoveryResponse_nonce(response);
|
964
|
-
*nonce =
|
1789
|
+
*nonce = UpbStringToStdString(nonce_strview);
|
965
1790
|
// Parse the response according to the resource type.
|
966
1791
|
if (*type_url == kLdsTypeUrl) {
|
967
|
-
return LdsResponseParse(response, expected_server_name,
|
968
|
-
arena.ptr());
|
1792
|
+
return LdsResponseParse(client_, tracer_, response, expected_server_name,
|
1793
|
+
lds_update, arena.ptr());
|
969
1794
|
} else if (*type_url == kRdsTypeUrl) {
|
970
|
-
return RdsResponseParse(response, expected_server_name,
|
971
|
-
|
1795
|
+
return RdsResponseParse(client_, tracer_, response, expected_server_name,
|
1796
|
+
expected_route_configuration_names, rds_update,
|
972
1797
|
arena.ptr());
|
973
1798
|
} else if (*type_url == kCdsTypeUrl) {
|
974
|
-
return CdsResponseParse(response,
|
1799
|
+
return CdsResponseParse(client_, tracer_, response, expected_cluster_names,
|
1800
|
+
cds_update_map, arena.ptr());
|
975
1801
|
} else if (*type_url == kEdsTypeUrl) {
|
976
|
-
return
|
977
|
-
|
1802
|
+
return EdsResponseParse(client_, tracer_, response,
|
1803
|
+
expected_eds_service_names, eds_update_map,
|
1804
|
+
arena.ptr());
|
978
1805
|
} else {
|
979
1806
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
980
1807
|
"Unsupported ADS resource type.");
|
@@ -983,6 +1810,121 @@ grpc_error* XdsApi::ParseAdsResponse(
|
|
983
1810
|
|
984
1811
|
namespace {
|
985
1812
|
|
1813
|
+
void MaybeLogLrsRequest(
|
1814
|
+
XdsClient* client, TraceFlag* tracer,
|
1815
|
+
const envoy_service_load_stats_v2_LoadStatsRequest* request) {
|
1816
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
|
1817
|
+
gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
|
1818
|
+
// TODO(roth): When we can upgrade upb, use upb textformat code to dump
|
1819
|
+
// the raw proto instead of doing this manually.
|
1820
|
+
std::vector<std::string> fields;
|
1821
|
+
// node
|
1822
|
+
const auto* node =
|
1823
|
+
envoy_service_load_stats_v2_LoadStatsRequest_node(request);
|
1824
|
+
if (node != nullptr) {
|
1825
|
+
AddNodeLogFields(node, &fields);
|
1826
|
+
}
|
1827
|
+
// cluster_stats
|
1828
|
+
size_t num_cluster_stats;
|
1829
|
+
const struct envoy_api_v2_endpoint_ClusterStats* const* cluster_stats =
|
1830
|
+
envoy_service_load_stats_v2_LoadStatsRequest_cluster_stats(
|
1831
|
+
request, &num_cluster_stats);
|
1832
|
+
for (size_t i = 0; i < num_cluster_stats; ++i) {
|
1833
|
+
const auto* cluster_stat = cluster_stats[i];
|
1834
|
+
fields.emplace_back("cluster_stats {");
|
1835
|
+
// cluster_name
|
1836
|
+
AddStringField(
|
1837
|
+
" cluster_name",
|
1838
|
+
envoy_api_v2_endpoint_ClusterStats_cluster_name(cluster_stat),
|
1839
|
+
&fields);
|
1840
|
+
// cluster_service_name
|
1841
|
+
AddStringField(
|
1842
|
+
" cluster_service_name",
|
1843
|
+
envoy_api_v2_endpoint_ClusterStats_cluster_service_name(cluster_stat),
|
1844
|
+
&fields);
|
1845
|
+
// upstream_locality_stats
|
1846
|
+
size_t num_stats;
|
1847
|
+
const envoy_api_v2_endpoint_UpstreamLocalityStats* const* stats =
|
1848
|
+
envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(
|
1849
|
+
cluster_stat, &num_stats);
|
1850
|
+
for (size_t j = 0; j < num_stats; ++j) {
|
1851
|
+
const auto* stat = stats[j];
|
1852
|
+
fields.emplace_back(" upstream_locality_stats {");
|
1853
|
+
// locality
|
1854
|
+
const auto* locality =
|
1855
|
+
envoy_api_v2_endpoint_UpstreamLocalityStats_locality(stat);
|
1856
|
+
if (locality != nullptr) {
|
1857
|
+
fields.emplace_back(" locality {");
|
1858
|
+
AddLocalityField(3, locality, &fields);
|
1859
|
+
fields.emplace_back(" }");
|
1860
|
+
}
|
1861
|
+
// total_successful_requests
|
1862
|
+
fields.emplace_back(absl::StrCat(
|
1863
|
+
" total_successful_requests: ",
|
1864
|
+
envoy_api_v2_endpoint_UpstreamLocalityStats_total_successful_requests(
|
1865
|
+
stat)));
|
1866
|
+
// total_requests_in_progress
|
1867
|
+
fields.emplace_back(absl::StrCat(
|
1868
|
+
" total_requests_in_progress: ",
|
1869
|
+
envoy_api_v2_endpoint_UpstreamLocalityStats_total_requests_in_progress(
|
1870
|
+
stat)));
|
1871
|
+
// total_error_requests
|
1872
|
+
fields.emplace_back(absl::StrCat(
|
1873
|
+
" total_error_requests: ",
|
1874
|
+
envoy_api_v2_endpoint_UpstreamLocalityStats_total_error_requests(
|
1875
|
+
stat)));
|
1876
|
+
// total_issued_requests
|
1877
|
+
fields.emplace_back(absl::StrCat(
|
1878
|
+
" total_issued_requests: ",
|
1879
|
+
envoy_api_v2_endpoint_UpstreamLocalityStats_total_issued_requests(
|
1880
|
+
stat)));
|
1881
|
+
fields.emplace_back(" }");
|
1882
|
+
}
|
1883
|
+
// total_dropped_requests
|
1884
|
+
fields.emplace_back(absl::StrCat(
|
1885
|
+
" total_dropped_requests: ",
|
1886
|
+
envoy_api_v2_endpoint_ClusterStats_total_dropped_requests(
|
1887
|
+
cluster_stat)));
|
1888
|
+
// dropped_requests
|
1889
|
+
size_t num_drops;
|
1890
|
+
const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* drops =
|
1891
|
+
envoy_api_v2_endpoint_ClusterStats_dropped_requests(cluster_stat,
|
1892
|
+
&num_drops);
|
1893
|
+
for (size_t j = 0; j < num_drops; ++j) {
|
1894
|
+
const auto* drop = drops[j];
|
1895
|
+
fields.emplace_back(" dropped_requests {");
|
1896
|
+
// category
|
1897
|
+
AddStringField(
|
1898
|
+
" category",
|
1899
|
+
envoy_api_v2_endpoint_ClusterStats_DroppedRequests_category(drop),
|
1900
|
+
&fields);
|
1901
|
+
// dropped_count
|
1902
|
+
fields.emplace_back(absl::StrCat(
|
1903
|
+
" dropped_count: ",
|
1904
|
+
envoy_api_v2_endpoint_ClusterStats_DroppedRequests_dropped_count(
|
1905
|
+
drop)));
|
1906
|
+
fields.emplace_back(" }");
|
1907
|
+
}
|
1908
|
+
// load_report_interval
|
1909
|
+
const auto* load_report_interval =
|
1910
|
+
envoy_api_v2_endpoint_ClusterStats_load_report_interval(cluster_stat);
|
1911
|
+
if (load_report_interval != nullptr) {
|
1912
|
+
fields.emplace_back(" load_report_interval {");
|
1913
|
+
fields.emplace_back(absl::StrCat(
|
1914
|
+
" seconds: ",
|
1915
|
+
google_protobuf_Duration_seconds(load_report_interval)));
|
1916
|
+
fields.emplace_back(
|
1917
|
+
absl::StrCat(" nanos: ",
|
1918
|
+
google_protobuf_Duration_nanos(load_report_interval)));
|
1919
|
+
fields.emplace_back(" }");
|
1920
|
+
}
|
1921
|
+
fields.emplace_back("}");
|
1922
|
+
}
|
1923
|
+
gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s", client,
|
1924
|
+
absl::StrJoin(fields, "\n").c_str());
|
1925
|
+
}
|
1926
|
+
}
|
1927
|
+
|
986
1928
|
grpc_slice SerializeLrsRequest(
|
987
1929
|
const envoy_service_load_stats_v2_LoadStatsRequest* request,
|
988
1930
|
upb_arena* arena) {
|
@@ -1005,6 +1947,10 @@ grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
|
|
1005
1947
|
arena.ptr());
|
1006
1948
|
PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_,
|
1007
1949
|
server_name, node_msg);
|
1950
|
+
envoy_api_v2_core_Node_add_client_features(
|
1951
|
+
node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
|
1952
|
+
arena.ptr());
|
1953
|
+
MaybeLogLrsRequest(client_, tracer_, request);
|
1008
1954
|
return SerializeLrsRequest(request, arena.ptr());
|
1009
1955
|
}
|
1010
1956
|
|
@@ -1117,10 +2063,12 @@ grpc_slice XdsApi::CreateLrsRequest(
|
|
1117
2063
|
google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
|
1118
2064
|
google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
|
1119
2065
|
}
|
2066
|
+
MaybeLogLrsRequest(client_, tracer_, request);
|
1120
2067
|
return SerializeLrsRequest(request, arena.ptr());
|
1121
2068
|
}
|
1122
2069
|
|
1123
2070
|
grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
|
2071
|
+
bool* send_all_clusters,
|
1124
2072
|
std::set<std::string>* cluster_names,
|
1125
2073
|
grpc_millis* load_reporting_interval) {
|
1126
2074
|
upb::Arena arena;
|
@@ -1133,13 +2081,19 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
|
|
1133
2081
|
if (decoded_response == nullptr) {
|
1134
2082
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode response.");
|
1135
2083
|
}
|
1136
|
-
//
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
2084
|
+
// Check send_all_clusters.
|
2085
|
+
if (envoy_service_load_stats_v2_LoadStatsResponse_send_all_clusters(
|
2086
|
+
decoded_response)) {
|
2087
|
+
*send_all_clusters = true;
|
2088
|
+
} else {
|
2089
|
+
// Store the cluster names.
|
2090
|
+
size_t size;
|
2091
|
+
const upb_strview* clusters =
|
2092
|
+
envoy_service_load_stats_v2_LoadStatsResponse_clusters(decoded_response,
|
2093
|
+
&size);
|
2094
|
+
for (size_t i = 0; i < size; ++i) {
|
2095
|
+
cluster_names->emplace(clusters[i].data, clusters[i].size);
|
2096
|
+
}
|
1143
2097
|
}
|
1144
2098
|
// Get the load report interval.
|
1145
2099
|
const google_protobuf_Duration* load_reporting_interval_duration =
|