grpc 1.49.1 → 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 +33 -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 +112 -96
- 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 +84 -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 +13 -15
- 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 +1 -1
- 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 +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -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/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 +33 -19
- 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:
|
@@ -472,7 +512,7 @@ class GrpcLb : public LoadBalancingPolicy {
|
|
472
512
|
void ShutdownLocked() override;
|
473
513
|
|
474
514
|
// Helper functions used in UpdateLocked().
|
475
|
-
|
515
|
+
absl::Status UpdateBalancerChannelLocked(const ChannelArgs& args);
|
476
516
|
|
477
517
|
void CancelBalancerChannelConnectivityWatchLocked();
|
478
518
|
|
@@ -867,7 +907,7 @@ GrpcLb::BalancerCallState::BalancerCallState(
|
|
867
907
|
const Timestamp deadline =
|
868
908
|
grpclb_policy()->lb_call_timeout_ == Duration::Zero()
|
869
909
|
? Timestamp::InfFuture()
|
870
|
-
:
|
910
|
+
: Timestamp::Now() + grpclb_policy()->lb_call_timeout_;
|
871
911
|
lb_call_ = grpc_channel_create_pollset_set_call(
|
872
912
|
grpclb_policy()->lb_channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
|
873
913
|
grpclb_policy_->interested_parties(),
|
@@ -1353,6 +1393,47 @@ ServerAddressList ExtractBalancerAddresses(const ChannelArgs& args) {
|
|
1353
1393
|
ChannelArgs BuildBalancerChannelArgs(
|
1354
1394
|
FakeResolverResponseGenerator* response_generator,
|
1355
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
|
+
}
|
1356
1437
|
// Create channel args for channel credentials that does not contain bearer
|
1357
1438
|
// token credentials.
|
1358
1439
|
auto* channel_credentials = args.GetObject<grpc_channel_credentials>();
|
@@ -1360,36 +1441,7 @@ ChannelArgs BuildBalancerChannelArgs(
|
|
1360
1441
|
RefCountedPtr<grpc_channel_credentials> creds_sans_call_creds =
|
1361
1442
|
channel_credentials->duplicate_without_call_credentials();
|
1362
1443
|
GPR_ASSERT(creds_sans_call_creds != nullptr);
|
1363
|
-
return
|
1364
|
-
// LB policy name, since we want to use the default (pick_first) in
|
1365
|
-
// the LB channel.
|
1366
|
-
.Remove(GRPC_ARG_LB_POLICY_NAME)
|
1367
|
-
// Strip out the service config, since we don't want the LB policy
|
1368
|
-
// config specified for the parent channel to affect the LB channel.
|
1369
|
-
.Remove(GRPC_ARG_SERVICE_CONFIG)
|
1370
|
-
// The channel arg for the server URI, since that will be different for
|
1371
|
-
// the LB channel than for the parent channel. The client channel
|
1372
|
-
// factory will re-add this arg with the right value.
|
1373
|
-
.Remove(GRPC_ARG_SERVER_URI)
|
1374
|
-
// The fake resolver response generator, because we are replacing it
|
1375
|
-
// with the one from the grpclb policy, used to propagate updates to
|
1376
|
-
// the LB channel.
|
1377
|
-
.Remove(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR)
|
1378
|
-
// The LB channel should use the authority indicated by the target
|
1379
|
-
// authority table (see \a ModifyGrpclbBalancerChannelArgs),
|
1380
|
-
// as opposed to the authority from the parent channel.
|
1381
|
-
.Remove(GRPC_ARG_DEFAULT_AUTHORITY)
|
1382
|
-
// Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should be
|
1383
|
-
// treated as a stand-alone channel and not inherit this argument from the
|
1384
|
-
// args of the parent channel.
|
1385
|
-
.Remove(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)
|
1386
|
-
// Don't want to pass down channelz node from parent; the balancer
|
1387
|
-
// channel will get its own.
|
1388
|
-
.Remove(GRPC_ARG_CHANNELZ_CHANNEL_NODE)
|
1389
|
-
// Remove the channel args for channel credentials and replace it
|
1390
|
-
// with a version that does not contain call credentials. The loadbalancer
|
1391
|
-
// is not necessarily trusted to handle bearer token credentials.
|
1392
|
-
.Remove(GRPC_ARG_CHANNEL_CREDENTIALS)
|
1444
|
+
return grpclb_channel_args
|
1393
1445
|
// A channel arg indicating the target is a grpclb load balancer.
|
1394
1446
|
.Set(GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER, 1)
|
1395
1447
|
// Tells channelz that this is an internal channel.
|
@@ -1507,7 +1559,7 @@ void GrpcLb::ResetBackoffLocked() {
|
|
1507
1559
|
}
|
1508
1560
|
}
|
1509
1561
|
|
1510
|
-
|
1562
|
+
absl::Status GrpcLb::UpdateLocked(UpdateArgs args) {
|
1511
1563
|
const bool is_initial_update = lb_channel_ == nullptr;
|
1512
1564
|
config_ = args.config;
|
1513
1565
|
GPR_ASSERT(config_ != nullptr);
|
@@ -1523,7 +1575,7 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1523
1575
|
}
|
1524
1576
|
resolution_note_ = std::move(args.resolution_note);
|
1525
1577
|
// Update balancer channel.
|
1526
|
-
UpdateBalancerChannelLocked(args.args);
|
1578
|
+
absl::Status status = UpdateBalancerChannelLocked(args.args);
|
1527
1579
|
// Update the existing child policy, if any.
|
1528
1580
|
if (child_policy_ != nullptr) CreateOrUpdateChildPolicyLocked();
|
1529
1581
|
// If this is the initial update, start the fallback-at-startup checks
|
@@ -1531,7 +1583,7 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1531
1583
|
if (is_initial_update) {
|
1532
1584
|
fallback_at_startup_checks_pending_ = true;
|
1533
1585
|
// Start timer.
|
1534
|
-
Timestamp deadline =
|
1586
|
+
Timestamp deadline = Timestamp::Now() + fallback_at_startup_timeout_;
|
1535
1587
|
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Ref for callback
|
1536
1588
|
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
|
1537
1589
|
// Start watching the channel's connectivity state. If the channel
|
@@ -1548,18 +1600,24 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
|
|
1548
1600
|
// Start balancer call.
|
1549
1601
|
StartBalancerCallLocked();
|
1550
1602
|
}
|
1603
|
+
return status;
|
1551
1604
|
}
|
1552
1605
|
|
1553
1606
|
//
|
1554
1607
|
// helpers for UpdateLocked()
|
1555
1608
|
//
|
1556
1609
|
|
1557
|
-
|
1610
|
+
absl::Status GrpcLb::UpdateBalancerChannelLocked(const ChannelArgs& args) {
|
1558
1611
|
// Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
|
1559
1612
|
// since we use this to trigger the client_load_reporting filter.
|
1560
1613
|
args_ = args.Set(GRPC_ARG_LB_POLICY_NAME, "grpclb");
|
1561
|
-
//
|
1614
|
+
// Get balancer addresses.
|
1562
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.
|
1563
1621
|
ChannelArgs lb_channel_args =
|
1564
1622
|
BuildBalancerChannelArgs(response_generator_.get(), args);
|
1565
1623
|
// Create balancer channel if needed.
|
@@ -1587,6 +1645,8 @@ void GrpcLb::UpdateBalancerChannelLocked(const ChannelArgs& args) {
|
|
1587
1645
|
result.addresses = std::move(balancer_addresses);
|
1588
1646
|
result.args = lb_channel_args;
|
1589
1647
|
response_generator_->SetResponse(std::move(result));
|
1648
|
+
// Return status.
|
1649
|
+
return status;
|
1590
1650
|
}
|
1591
1651
|
|
1592
1652
|
void GrpcLb::CancelBalancerChannelConnectivityWatchLocked() {
|
@@ -1618,7 +1678,7 @@ void GrpcLb::StartBalancerCallRetryTimerLocked() {
|
|
1618
1678
|
Timestamp next_try = lb_call_backoff_.NextAttemptTime();
|
1619
1679
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
|
1620
1680
|
gpr_log(GPR_INFO, "[grpclb %p] Connection to LB server lost...", this);
|
1621
|
-
Duration timeout = next_try -
|
1681
|
+
Duration timeout = next_try - Timestamp::Now();
|
1622
1682
|
if (timeout > Duration::Zero()) {
|
1623
1683
|
gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRId64 "ms.",
|
1624
1684
|
this, timeout.millis());
|
@@ -1777,7 +1837,9 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
|
|
1777
1837
|
gpr_log(GPR_INFO, "[grpclb %p] Updating child policy handler %p", this,
|
1778
1838
|
child_policy_.get());
|
1779
1839
|
}
|
1780
|
-
|
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));
|
1781
1843
|
}
|
1782
1844
|
|
1783
1845
|
//
|
@@ -1786,7 +1848,7 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
|
|
1786
1848
|
|
1787
1849
|
void GrpcLb::CacheDeletedSubchannelLocked(
|
1788
1850
|
RefCountedPtr<SubchannelInterface> subchannel) {
|
1789
|
-
Timestamp deletion_time =
|
1851
|
+
Timestamp deletion_time = Timestamp::Now() + subchannel_cache_interval_;
|
1790
1852
|
cached_subchannels_[deletion_time].push_back(std::move(subchannel));
|
1791
1853
|
if (!subchannel_cache_timer_pending_) {
|
1792
1854
|
Ref(DEBUG_LOCATION, "OnSubchannelCacheTimer").release();
|
@@ -1845,48 +1907,8 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1845
1907
|
|
1846
1908
|
absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
|
1847
1909
|
ParseLoadBalancingConfig(const Json& json) const override {
|
1848
|
-
|
1849
|
-
|
1850
|
-
}
|
1851
|
-
std::vector<std::string> error_list;
|
1852
|
-
std::string service_name;
|
1853
|
-
auto it = json.object_value().find("serviceName");
|
1854
|
-
if (it != json.object_value().end()) {
|
1855
|
-
const Json& service_name_json = it->second;
|
1856
|
-
if (service_name_json.type() != Json::Type::STRING) {
|
1857
|
-
error_list.emplace_back(
|
1858
|
-
"field:serviceName error:type should be string");
|
1859
|
-
} else {
|
1860
|
-
service_name = service_name_json.string_value();
|
1861
|
-
}
|
1862
|
-
}
|
1863
|
-
Json child_policy_config_json_tmp;
|
1864
|
-
const Json* child_policy_config_json;
|
1865
|
-
it = json.object_value().find("childPolicy");
|
1866
|
-
if (it == json.object_value().end()) {
|
1867
|
-
child_policy_config_json_tmp = Json::Array{Json::Object{
|
1868
|
-
{"round_robin", Json::Object()},
|
1869
|
-
}};
|
1870
|
-
child_policy_config_json = &child_policy_config_json_tmp;
|
1871
|
-
} else {
|
1872
|
-
child_policy_config_json = &it->second;
|
1873
|
-
}
|
1874
|
-
auto child_policy_config =
|
1875
|
-
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
|
1876
|
-
*child_policy_config_json);
|
1877
|
-
if (!child_policy_config.ok()) {
|
1878
|
-
error_list.emplace_back(
|
1879
|
-
absl::StrCat("error parsing childPolicy field: ",
|
1880
|
-
child_policy_config.status().message()));
|
1881
|
-
}
|
1882
|
-
if (error_list.empty()) {
|
1883
|
-
return MakeRefCounted<GrpcLbConfig>(std::move(*child_policy_config),
|
1884
|
-
std::move(service_name));
|
1885
|
-
} else {
|
1886
|
-
return absl::InvalidArgumentError(
|
1887
|
-
absl::StrCat("errors parsing grpclb LB policy config: [",
|
1888
|
-
absl::StrJoin(error_list, "; "), "]"));
|
1889
|
-
}
|
1910
|
+
return LoadRefCountedFromJson<GrpcLbConfig>(
|
1911
|
+
json, JsonArgs(), "errors validating grpclb LB policy config");
|
1890
1912
|
}
|
1891
1913
|
};
|
1892
1914
|
|
@@ -1898,16 +1920,10 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
|
|
1898
1920
|
// Plugin registration
|
1899
1921
|
//
|
1900
1922
|
|
1901
|
-
void grpc_lb_policy_grpclb_init() {
|
1902
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
1903
|
-
RegisterLoadBalancingPolicyFactory(
|
1904
|
-
absl::make_unique<grpc_core::GrpcLbFactory>());
|
1905
|
-
}
|
1906
|
-
|
1907
|
-
void grpc_lb_policy_grpclb_shutdown() {}
|
1908
|
-
|
1909
1923
|
namespace grpc_core {
|
1910
|
-
void
|
1924
|
+
void RegisterGrpcLbPolicy(CoreConfiguration::Builder* builder) {
|
1925
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
1926
|
+
absl::make_unique<GrpcLbFactory>());
|
1911
1927
|
builder->channel_init()->RegisterStage(
|
1912
1928
|
GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
1913
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
|
}
|