grpc 1.49.0.pre1 → 1.50.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 +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +41 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +114 -103
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +87 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +38 -18
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +19 -16
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +5 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +5 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/ext/grpc/extconf.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +31 -17
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -114,6 +114,7 @@
|
|
114
114
|
#include "src/core/lib/gprpp/ref_counted.h"
|
115
115
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
116
116
|
#include "src/core/lib/gprpp/time.h"
|
117
|
+
#include "src/core/lib/gprpp/validation_errors.h"
|
117
118
|
#include "src/core/lib/gprpp/work_serializer.h"
|
118
119
|
#include "src/core/lib/iomgr/closure.h"
|
119
120
|
#include "src/core/lib/iomgr/error.h"
|
@@ -124,6 +125,8 @@
|
|
124
125
|
#include "src/core/lib/iomgr/socket_utils.h"
|
125
126
|
#include "src/core/lib/iomgr/timer.h"
|
126
127
|
#include "src/core/lib/json/json.h"
|
128
|
+
#include "src/core/lib/json/json_args.h"
|
129
|
+
#include "src/core/lib/json/json_object_loader.h"
|
127
130
|
#include "src/core/lib/load_balancing/lb_policy.h"
|
128
131
|
#include "src/core/lib/load_balancing/lb_policy_factory.h"
|
129
132
|
#include "src/core/lib/load_balancing/lb_policy_registry.h"
|
@@ -164,10 +167,47 @@ constexpr absl::string_view kGrpclb = "grpclb";
|
|
164
167
|
|
165
168
|
class GrpcLbConfig : public LoadBalancingPolicy::Config {
|
166
169
|
public:
|
167
|
-
GrpcLbConfig(
|
168
|
-
|
169
|
-
|
170
|
-
|
170
|
+
GrpcLbConfig() = default;
|
171
|
+
|
172
|
+
GrpcLbConfig(const GrpcLbConfig&) = delete;
|
173
|
+
GrpcLbConfig& operator=(const GrpcLbConfig&) = delete;
|
174
|
+
|
175
|
+
GrpcLbConfig(GrpcLbConfig&& other) = delete;
|
176
|
+
GrpcLbConfig& operator=(GrpcLbConfig&& other) = delete;
|
177
|
+
|
178
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&) {
|
179
|
+
static const auto* loader =
|
180
|
+
JsonObjectLoader<GrpcLbConfig>()
|
181
|
+
// Note: "childPolicy" field requires custom parsing, so
|
182
|
+
// it's handled in JsonPostLoad() instead.
|
183
|
+
.OptionalField("serviceName", &GrpcLbConfig::service_name_)
|
184
|
+
.Finish();
|
185
|
+
return loader;
|
186
|
+
}
|
187
|
+
|
188
|
+
void JsonPostLoad(const Json& json, const JsonArgs&,
|
189
|
+
ValidationErrors* errors) {
|
190
|
+
ValidationErrors::ScopedField field(errors, ".childPolicy");
|
191
|
+
Json child_policy_config_json_tmp;
|
192
|
+
const Json* child_policy_config_json;
|
193
|
+
auto it = json.object_value().find("childPolicy");
|
194
|
+
if (it == json.object_value().end()) {
|
195
|
+
child_policy_config_json_tmp = Json::Array{Json::Object{
|
196
|
+
{"round_robin", Json::Object()},
|
197
|
+
}};
|
198
|
+
child_policy_config_json = &child_policy_config_json_tmp;
|
199
|
+
} else {
|
200
|
+
child_policy_config_json = &it->second;
|
201
|
+
}
|
202
|
+
auto child_policy_config =
|
203
|
+
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
|
204
|
+
*child_policy_config_json);
|
205
|
+
if (!child_policy_config.ok()) {
|
206
|
+
errors->AddError(child_policy_config.status().message());
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
child_policy_ = std::move(*child_policy_config);
|
210
|
+
}
|
171
211
|
|
172
212
|
absl::string_view name() const override { return kGrpclb; }
|
173
213
|
|
@@ -188,7 +228,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
188
228
|
|
189
229
|
absl::string_view name() const override { return kGrpclb; }
|
190
230
|
|
191
|
-
|
231
|
+
absl::Status UpdateLocked(UpdateArgs args) override;
|
192
232
|
void ResetBackoffLocked() override;
|
193
233
|
|
194
234
|
private:
|
@@ -219,7 +259,6 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
219
259
|
void SendClientLoadReportLocked();
|
220
260
|
|
221
261
|
// EventEngine callbacks
|
222
|
-
void MaybeSendClientLoadReport();
|
223
262
|
void MaybeSendClientLoadReportLocked();
|
224
263
|
|
225
264
|
static void ClientLoadReportDone(void* arg, grpc_error_handle error);
|
@@ -473,7 +512,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
473
512
|
void ShutdownLocked() override;
|
474
513
|
|
475
514
|
// Helper functions used in UpdateLocked().
|
476
|
-
|
515
|
+
absl::Status UpdateBalancerChannelLocked(const ChannelArgs& args);
|
477
516
|
|
478
517
|
void CancelBalancerChannelConnectivityWatchLocked();
|
479
518
|
|
@@ -868,7 +907,7 @@ GrpcLb::BalancerCallState::BalancerCallState(
|
|
868
907
|
const Timestamp deadline =
|
869
908
|
grpclb_policy()->lb_call_timeout_ == Duration::Zero()
|
870
909
|
? Timestamp::InfFuture()
|
871
|
-
:
|
910
|
+
: Timestamp::Now() + grpclb_policy()->lb_call_timeout_;
|
872
911
|
lb_call_ = grpc_channel_create_pollset_set_call(
|
873
912
|
grpclb_policy()->lb_channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
|
874
913
|
grpclb_policy_->interested_parties(),
|
@@ -996,15 +1035,11 @@ void GrpcLb::BalancerCallState::ScheduleNextClientLoadReportLocked() {
|
|
996
1035
|
GetDefaultEventEngine()->RunAfter(client_stats_report_interval_, [this] {
|
997
1036
|
ApplicationCallbackExecCtx callback_exec_ctx;
|
998
1037
|
ExecCtx exec_ctx;
|
999
|
-
|
1038
|
+
grpclb_policy()->work_serializer()->Run(
|
1039
|
+
[this] { MaybeSendClientLoadReportLocked(); }, DEBUG_LOCATION);
|
1000
1040
|
});
|
1001
1041
|
}
|
1002
1042
|
|
1003
|
-
void GrpcLb::BalancerCallState::MaybeSendClientLoadReport() {
|
1004
|
-
grpclb_policy()->work_serializer()->Run(
|
1005
|
-
[this] { MaybeSendClientLoadReportLocked(); }, DEBUG_LOCATION);
|
1006
|
-
}
|
1007
|
-
|
1008
1043
|
void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked() {
|
1009
1044
|
client_load_report_handle_.reset();
|
1010
1045
|
if (this != grpclb_policy()->lb_calld_.get()) {
|
@@ -1358,6 +1393,47 @@ ServerAddressList ExtractBalancerAddresses(const ChannelArgs& args) {
|
|
1358
1393
|
ChannelArgs BuildBalancerChannelArgs(
|
1359
1394
|
FakeResolverResponseGenerator* response_generator,
|
1360
1395
|
const ChannelArgs& args) {
|
1396
|
+
ChannelArgs grpclb_channel_args;
|
1397
|
+
const grpc_channel_args* lb_channel_specific_args =
|
1398
|
+
args.GetPointer<grpc_channel_args>(
|
1399
|
+
GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS);
|
1400
|
+
if (lb_channel_specific_args != nullptr) {
|
1401
|
+
grpclb_channel_args = ChannelArgs::FromC(lb_channel_specific_args);
|
1402
|
+
} else {
|
1403
|
+
// Set grpclb_channel_args based on the parent channel's channel args.
|
1404
|
+
grpclb_channel_args =
|
1405
|
+
args
|
1406
|
+
// LB policy name, since we want to use the default (pick_first) in
|
1407
|
+
// the LB channel.
|
1408
|
+
.Remove(GRPC_ARG_LB_POLICY_NAME)
|
1409
|
+
// Strip out the service config, since we don't want the LB policy
|
1410
|
+
// config specified for the parent channel to affect the LB channel.
|
1411
|
+
.Remove(GRPC_ARG_SERVICE_CONFIG)
|
1412
|
+
// The channel arg for the server URI, since that will be different
|
1413
|
+
// for the LB channel than for the parent channel. The client
|
1414
|
+
// channel factory will re-add this arg with the right value.
|
1415
|
+
.Remove(GRPC_ARG_SERVER_URI)
|
1416
|
+
// The fake resolver response generator, because we are replacing it
|
1417
|
+
// with the one from the grpclb policy, used to propagate updates to
|
1418
|
+
// the LB channel.
|
1419
|
+
.Remove(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR)
|
1420
|
+
// The LB channel should use the authority indicated by the target
|
1421
|
+
// authority table (see \a ModifyGrpclbBalancerChannelArgs),
|
1422
|
+
// as opposed to the authority from the parent channel.
|
1423
|
+
.Remove(GRPC_ARG_DEFAULT_AUTHORITY)
|
1424
|
+
// Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should
|
1425
|
+
// be treated as a stand-alone channel and not inherit this argument
|
1426
|
+
// from the args of the parent channel.
|
1427
|
+
.Remove(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)
|
1428
|
+
// Don't want to pass down channelz node from parent; the balancer
|
1429
|
+
// channel will get its own.
|
1430
|
+
.Remove(GRPC_ARG_CHANNELZ_CHANNEL_NODE)
|
1431
|
+
// Remove the channel args for channel credentials and replace it
|
1432
|
+
// with a version that does not contain call credentials. The
|
1433
|
+
// loadbalancer is not necessarily trusted to handle bearer token
|
1434
|
+
// credentials.
|
1435
|
+
.Remove(GRPC_ARG_CHANNEL_CREDENTIALS);
|
1436
|
+
}
|
1361
1437
|
// Create channel args for channel credentials that does not contain bearer
|
1362
1438
|
// token credentials.
|
1363
1439
|
auto* channel_credentials = args.GetObject<grpc_channel_credentials>();
|
@@ -1365,36 +1441,7 @@ ChannelArgs BuildBalancerChannelArgs(
|
|
1365
1441
|
RefCountedPtr<grpc_channel_credentials> creds_sans_call_creds =
|
1366
1442
|
channel_credentials->duplicate_without_call_credentials();
|
1367
1443
|
GPR_ASSERT(creds_sans_call_creds != nullptr);
|
1368
|
-
return
|
1369
|
-
// LB policy name, since we want to use the default (pick_first) in
|
1370
|
-
// the LB channel.
|
1371
|
-
.Remove(GRPC_ARG_LB_POLICY_NAME)
|
1372
|
-
// Strip out the service config, since we don't want the LB policy
|
1373
|
-
// config specified for the parent channel to affect the LB channel.
|
1374
|
-
.Remove(GRPC_ARG_SERVICE_CONFIG)
|
1375
|
-
// The channel arg for the server URI, since that will be different for
|
1376
|
-
// the LB channel than for the parent channel. The client channel
|
1377
|
-
// factory will re-add this arg with the right value.
|
1378
|
-
.Remove(GRPC_ARG_SERVER_URI)
|
1379
|
-
// The fake resolver response generator, because we are replacing it
|
1380
|
-
// with the one from the grpclb policy, used to propagate updates to
|
1381
|
-
// the LB channel.
|
1382
|
-
.Remove(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR)
|
1383
|
-
// The LB channel should use the authority indicated by the target
|
1384
|
-
// authority table (see \a ModifyGrpclbBalancerChannelArgs),
|
1385
|
-
// as opposed to the authority from the parent channel.
|
1386
|
-
.Remove(GRPC_ARG_DEFAULT_AUTHORITY)
|
1387
|
-
// Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should be
|
1388
|
-
// treated as a stand-alone channel and not inherit this argument from the
|
1389
|
-
// args of the parent channel.
|
1390
|
-
.Remove(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)
|
1391
|
-
// Don't want to pass down channelz node from parent; the balancer
|
1392
|
-
// channel will get its own.
|
1393
|
-
.Remove(GRPC_ARG_CHANNELZ_CHANNEL_NODE)
|
1394
|
-
// Remove the channel args for channel credentials and replace it
|
1395
|
-
// with a version that does not contain call credentials. The loadbalancer
|
1396
|
-
// is not necessarily trusted to handle bearer token credentials.
|
1397
|
-
.Remove(GRPC_ARG_CHANNEL_CREDENTIALS)
|
1444
|
+
return grpclb_channel_args
|
1398
1445
|
// A channel arg indicating the target is a grpclb load balancer.
|
1399
1446
|
.Set(GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER, 1)
|
1400
1447
|
// Tells channelz that this is an internal channel.
|
@@ -1512,7 +1559,7 @@ void GrpcLb::ResetBackoffLocked() {
|
|
1512
1559
|
}
|
1513
1560
|
}
|
1514
1561
|
|
1515
|
-
|
1562
|
+
absl::Status GrpcLb::UpdateLocked(UpdateArgs args) {
|
1516
1563
|
const bool is_initial_update = lb_channel_ == nullptr;
|
1517
1564
|
config_ = args.config;
|
1518
1565
|
GPR_ASSERT(config_ != nullptr);
|
@@ -1528,7 +1575,7 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1528
1575
|
}
|
1529
1576
|
resolution_note_ = std::move(args.resolution_note);
|
1530
1577
|
// Update balancer channel.
|
1531
|
-
UpdateBalancerChannelLocked(args.args);
|
1578
|
+
absl::Status status = UpdateBalancerChannelLocked(args.args);
|
1532
1579
|
// Update the existing child policy, if any.
|
1533
1580
|
if (child_policy_ != nullptr) CreateOrUpdateChildPolicyLocked();
|
1534
1581
|
// If this is the initial update, start the fallback-at-startup checks
|
@@ -1536,7 +1583,7 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1536
1583
|
if (is_initial_update) {
|
1537
1584
|
fallback_at_startup_checks_pending_ = true;
|
1538
1585
|
// Start timer.
|
1539
|
-
Timestamp deadline =
|
1586
|
+
Timestamp deadline = Timestamp::Now() + fallback_at_startup_timeout_;
|
1540
1587
|
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Ref for callback
|
1541
1588
|
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
|
1542
1589
|
// Start watching the channel's connectivity state. If the channel
|
@@ -1553,18 +1600,24 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1553
1600
|
// Start balancer call.
|
1554
1601
|
StartBalancerCallLocked();
|
1555
1602
|
}
|
1603
|
+
return status;
|
1556
1604
|
}
|
1557
1605
|
|
1558
1606
|
//
|
1559
1607
|
// helpers for UpdateLocked()
|
1560
1608
|
//
|
1561
1609
|
|
1562
|
-
|
1610
|
+
absl::Status GrpcLb::UpdateBalancerChannelLocked(const ChannelArgs& args) {
|
1563
1611
|
// Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
|
1564
1612
|
// since we use this to trigger the client_load_reporting filter.
|
1565
1613
|
args_ = args.Set(GRPC_ARG_LB_POLICY_NAME, "grpclb");
|
1566
|
-
//
|
1614
|
+
// Get balancer addresses.
|
1567
1615
|
ServerAddressList balancer_addresses = ExtractBalancerAddresses(args);
|
1616
|
+
absl::Status status;
|
1617
|
+
if (balancer_addresses.empty()) {
|
1618
|
+
status = absl::UnavailableError("balancer address list must be non-empty");
|
1619
|
+
}
|
1620
|
+
// Construct args for balancer channel.
|
1568
1621
|
ChannelArgs lb_channel_args =
|
1569
1622
|
BuildBalancerChannelArgs(response_generator_.get(), args);
|
1570
1623
|
// Create balancer channel if needed.
|
@@ -1592,6 +1645,8 @@ void GrpcLb::UpdateBalancerChannelLocked(const ChannelArgs& args) {
|
|
1592
1645
|
result.addresses = std::move(balancer_addresses);
|
1593
1646
|
result.args = lb_channel_args;
|
1594
1647
|
response_generator_->SetResponse(std::move(result));
|
1648
|
+
// Return status.
|
1649
|
+
return status;
|
1595
1650
|
}
|
1596
1651
|
|
1597
1652
|
void GrpcLb::CancelBalancerChannelConnectivityWatchLocked() {
|
@@ -1623,7 +1678,7 @@ void GrpcLb::StartBalancerCallRetryTimerLocked() {
|
|
1623
1678
|
Timestamp next_try = lb_call_backoff_.NextAttemptTime();
|
1624
1679
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1625
1680
|
gpr_log(GPR_INFO, "[grpclb %p] Connection to LB server lost...", this);
|
1626
|
-
Duration timeout = next_try -
|
1681
|
+
Duration timeout = next_try - Timestamp::Now();
|
1627
1682
|
if (timeout > Duration::Zero()) {
|
1628
1683
|
gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRId64 "ms.",
|
1629
1684
|
this, timeout.millis());
|
@@ -1782,7 +1837,9 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
|
|
1782
1837
|
gpr_log(GPR_INFO, "[grpclb %p] Updating child policy handler %p", this,
|
1783
1838
|
child_policy_.get());
|
1784
1839
|
}
|
1785
|
-
|
1840
|
+
// TODO(roth): If we're in fallback mode and the child policy rejects the
|
1841
|
+
// update, we should propagate that failure back to the resolver somehow.
|
1842
|
+
(void)child_policy_->UpdateLocked(std::move(update_args));
|
1786
1843
|
}
|
1787
1844
|
|
1788
1845
|
//
|
@@ -1791,7 +1848,7 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
|
|
1791
1848
|
|
1792
1849
|
void GrpcLb::CacheDeletedSubchannelLocked(
|
1793
1850
|
RefCountedPtr<SubchannelInterface> subchannel) {
|
1794
|
-
Timestamp deletion_time =
|
1851
|
+
Timestamp deletion_time = Timestamp::Now() + subchannel_cache_interval_;
|
1795
1852
|
cached_subchannels_[deletion_time].push_back(std::move(subchannel));
|
1796
1853
|
if (!subchannel_cache_timer_pending_) {
|
1797
1854
|
Ref(DEBUG_LOCATION, "OnSubchannelCacheTimer").release();
|
@@ -1850,48 +1907,8 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1850
1907
|
|
1851
1908
|
absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
|
1852
1909
|
ParseLoadBalancingConfig(const Json& json) const override {
|
1853
|
-
|
1854
|
-
|
1855
|
-
}
|
1856
|
-
std::vector<std::string> error_list;
|
1857
|
-
std::string service_name;
|
1858
|
-
auto it = json.object_value().find("serviceName");
|
1859
|
-
if (it != json.object_value().end()) {
|
1860
|
-
const Json& service_name_json = it->second;
|
1861
|
-
if (service_name_json.type() != Json::Type::STRING) {
|
1862
|
-
error_list.emplace_back(
|
1863
|
-
"field:serviceName error:type should be string");
|
1864
|
-
} else {
|
1865
|
-
service_name = service_name_json.string_value();
|
1866
|
-
}
|
1867
|
-
}
|
1868
|
-
Json child_policy_config_json_tmp;
|
1869
|
-
const Json* child_policy_config_json;
|
1870
|
-
it = json.object_value().find("childPolicy");
|
1871
|
-
if (it == json.object_value().end()) {
|
1872
|
-
child_policy_config_json_tmp = Json::Array{Json::Object{
|
1873
|
-
{"round_robin", Json::Object()},
|
1874
|
-
}};
|
1875
|
-
child_policy_config_json = &child_policy_config_json_tmp;
|
1876
|
-
} else {
|
1877
|
-
child_policy_config_json = &it->second;
|
1878
|
-
}
|
1879
|
-
auto child_policy_config =
|
1880
|
-
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
|
1881
|
-
*child_policy_config_json);
|
1882
|
-
if (!child_policy_config.ok()) {
|
1883
|
-
error_list.emplace_back(
|
1884
|
-
absl::StrCat("error parsing childPolicy field: ",
|
1885
|
-
child_policy_config.status().message()));
|
1886
|
-
}
|
1887
|
-
if (error_list.empty()) {
|
1888
|
-
return MakeRefCounted<GrpcLbConfig>(std::move(*child_policy_config),
|
1889
|
-
std::move(service_name));
|
1890
|
-
} else {
|
1891
|
-
return absl::InvalidArgumentError(
|
1892
|
-
absl::StrCat("errors parsing grpclb LB policy config: [",
|
1893
|
-
absl::StrJoin(error_list, "; "), "]"));
|
1894
|
-
}
|
1910
|
+
return LoadRefCountedFromJson<GrpcLbConfig>(
|
1911
|
+
json, JsonArgs(), "errors validating grpclb LB policy config");
|
1895
1912
|
}
|
1896
1913
|
};
|
1897
1914
|
|
@@ -1903,16 +1920,10 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1903
1920
|
// Plugin registration
|
1904
1921
|
//
|
1905
1922
|
|
1906
|
-
void grpc_lb_policy_grpclb_init() {
|
1907
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
1908
|
-
RegisterLoadBalancingPolicyFactory(
|
1909
|
-
absl::make_unique<grpc_core::GrpcLbFactory>());
|
1910
|
-
}
|
1911
|
-
|
1912
|
-
void grpc_lb_policy_grpclb_shutdown() {}
|
1913
|
-
|
1914
1923
|
namespace grpc_core {
|
1915
|
-
void
|
1924
|
+
void RegisterGrpcLbPolicy(CoreConfiguration::Builder* builder) {
|
1925
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
1926
|
+
absl::make_unique<GrpcLbFactory>());
|
1916
1927
|
builder->channel_init()->RegisterStage(
|
1917
1928
|
GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
1918
1929
|
[](ChannelStackBuilder* builder) {
|
@@ -76,7 +76,7 @@ class OrcaWatcher;
|
|
76
76
|
// registered watchers.
|
77
77
|
class OrcaProducer : public Subchannel::DataProducerInterface {
|
78
78
|
public:
|
79
|
-
|
79
|
+
void Start(RefCountedPtr<Subchannel> subchannel);
|
80
80
|
|
81
81
|
void Orphan() override;
|
82
82
|
|
@@ -288,9 +288,8 @@ class OrcaProducer::OrcaStreamEventHandler
|
|
288
288
|
// OrcaProducer
|
289
289
|
//
|
290
290
|
|
291
|
-
OrcaProducer::
|
292
|
-
|
293
|
-
subchannel_->AddDataProducer(this);
|
291
|
+
void OrcaProducer::Start(RefCountedPtr<Subchannel> subchannel) {
|
292
|
+
subchannel_ = std::move(subchannel);
|
294
293
|
connected_subchannel_ = subchannel_->connected_subchannel();
|
295
294
|
auto connectivity_watcher = MakeRefCounted<ConnectivityWatcher>(WeakRef());
|
296
295
|
connectivity_watcher_ = connectivity_watcher.get();
|
@@ -304,6 +303,7 @@ void OrcaProducer::Orphan() {
|
|
304
303
|
MutexLock lock(&mu_);
|
305
304
|
stream_client_.reset();
|
306
305
|
}
|
306
|
+
GPR_ASSERT(subchannel_ != nullptr); // Should not be called before Start().
|
307
307
|
subchannel_->CancelConnectivityStateWatch(
|
308
308
|
/*health_check_service_name=*/absl::nullopt, connectivity_watcher_);
|
309
309
|
subchannel_->RemoveDataProducer(this);
|
@@ -384,14 +384,23 @@ OrcaWatcher::~OrcaWatcher() {
|
|
384
384
|
}
|
385
385
|
|
386
386
|
void OrcaWatcher::SetSubchannel(Subchannel* subchannel) {
|
387
|
+
bool created = false;
|
387
388
|
// Check if our producer is already registered with the subchannel.
|
388
|
-
// If not, create a new one
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
389
|
+
// If not, create a new one.
|
390
|
+
subchannel->GetOrAddDataProducer(
|
391
|
+
OrcaProducer::Type(), [&](Subchannel::DataProducerInterface** producer) {
|
392
|
+
if (*producer != nullptr) producer_ = (*producer)->RefIfNonZero();
|
393
|
+
if (producer_ == nullptr) {
|
394
|
+
producer_ = MakeRefCounted<OrcaProducer>();
|
395
|
+
*producer = producer_.get();
|
396
|
+
created = true;
|
397
|
+
}
|
398
|
+
});
|
399
|
+
// If we just created the producer, start it.
|
400
|
+
// This needs to be done outside of the lambda passed to
|
401
|
+
// GetOrAddDataProducer() to avoid deadlocking by re-acquiring the
|
402
|
+
// subchannel lock while already holding it.
|
403
|
+
if (created) producer_->Start(subchannel->Ref());
|
395
404
|
// Register ourself with the producer.
|
396
405
|
producer_->AddWatcher(this);
|
397
406
|
}
|