grpc 1.32.0 → 1.33.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 +175 -376
- data/include/grpc/grpc.h +0 -5
- data/include/grpc/grpc_security.h +16 -0
- data/include/grpc/impl/codegen/grpc_types.h +0 -5
- data/src/core/ext/filters/client_channel/client_channel.cc +204 -170
- data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
- data/src/core/ext/filters/client_channel/config_selector.h +34 -5
- data/src/core/ext/filters/client_channel/lb_policy.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +106 -106
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -32
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +198 -126
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +439 -249
- data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +571 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +727 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +553 -358
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -39
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +4 -2
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +44 -43
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -9
- data/src/core/ext/filters/client_channel/server_address.cc +80 -0
- data/src/core/ext/filters/client_channel/server_address.h +25 -36
- data/src/core/ext/filters/client_channel/service_config.cc +16 -13
- data/src/core/ext/filters/client_channel/service_config.h +7 -4
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
- data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
- data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
- data/src/core/ext/filters/client_channel/subchannel_interface.h +44 -0
- data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
- data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +17 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +10 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +5 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +16 -2
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +29 -9
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +66 -0
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +123 -45
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +310 -53
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +17 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +45 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +16 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +38 -15
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +133 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +54 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +123 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +40 -16
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +114 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +85 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +36 -16
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +86 -20
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +23 -6
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +54 -5
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +10 -6
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +28 -11
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +184 -57
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +504 -69
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +11 -7
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +78 -26
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +236 -25
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +8 -9
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +19 -33
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +7 -3
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +16 -0
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +65 -23
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +229 -47
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +20 -10
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +67 -4
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +6 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +753 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +57 -0
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
- data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +53 -0
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
- data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +129 -0
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
- data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +77 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +85 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +160 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
- data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +84 -0
- data/src/core/ext/xds/certificate_provider_factory.h +59 -0
- data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
- data/src/core/ext/xds/certificate_provider_registry.h +57 -0
- data/src/core/ext/xds/certificate_provider_store.h +50 -0
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +377 -0
- data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +102 -0
- data/src/core/ext/xds/xds_api.cc +301 -93
- data/src/core/ext/xds/xds_api.h +129 -92
- data/src/core/ext/xds/xds_channel_args.h +6 -3
- data/src/core/ext/xds/xds_client.cc +498 -410
- data/src/core/ext/xds/xds_client.h +105 -51
- data/src/core/ext/xds/xds_client_stats.cc +18 -12
- data/src/core/ext/xds/xds_client_stats.h +33 -5
- data/src/core/lib/channel/channel_args.h +0 -1
- data/src/core/lib/channel/channelz.cc +10 -45
- data/src/core/lib/channel/channelz.h +11 -19
- data/src/core/lib/channel/channelz_registry.cc +12 -11
- data/src/core/lib/channel/channelz_registry.h +3 -0
- data/src/core/lib/gpr/time_precise.cc +2 -0
- data/src/core/lib/gpr/time_precise.h +6 -2
- data/src/core/lib/gprpp/dual_ref_counted.h +336 -0
- data/src/core/lib/gprpp/ref_counted.h +51 -22
- data/src/core/lib/gprpp/ref_counted_ptr.h +153 -0
- data/src/core/lib/iomgr/endpoint_cfstream.cc +9 -5
- data/src/core/lib/iomgr/exec_ctx.h +10 -8
- data/src/core/lib/json/json_util.cc +58 -0
- data/src/core/lib/json/json_util.h +37 -0
- data/src/core/lib/security/certificate_provider.h +60 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +321 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +214 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +45 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.h +51 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -0
- data/src/core/lib/surface/channel.cc +9 -31
- data/src/core/lib/surface/channel.h +6 -1
- data/src/core/lib/surface/init.cc +26 -9
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.h +2 -1
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/metadata.cc +11 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +35 -20
- data/src/core/tsi/ssl_transport_security.cc +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/err_data.c +465 -463
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -15
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +98 -11
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +51 -6
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +44 -2
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +221 -49
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +64 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +0 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +9 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +26 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +188 -78
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +52 -43
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +9 -9
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +4 -8
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +2 -2
- metadata +72 -42
- data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -537
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1141
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -29
- data/src/core/ext/xds/xds_channel.h +0 -46
- data/src/core/ext/xds/xds_channel_secure.cc +0 -103
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
@@ -84,9 +84,9 @@ class PickFirst : public LoadBalancingPolicy {
|
|
84
84
|
PickFirstSubchannelData> {
|
85
85
|
public:
|
86
86
|
PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer,
|
87
|
-
|
87
|
+
ServerAddressList addresses,
|
88
88
|
const grpc_channel_args& args)
|
89
|
-
: SubchannelList(policy, tracer, addresses,
|
89
|
+
: SubchannelList(policy, tracer, std::move(addresses),
|
90
90
|
policy->channel_control_helper(), args) {
|
91
91
|
// Need to maintain a ref to the LB policy as long as we maintain
|
92
92
|
// any references to subchannels, since the subchannels'
|
@@ -155,7 +155,7 @@ class PriorityLb : public LoadBalancingPolicy {
|
|
155
155
|
~Helper() { priority_.reset(DEBUG_LOCATION, "Helper"); }
|
156
156
|
|
157
157
|
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
158
|
-
const grpc_channel_args& args) override;
|
158
|
+
ServerAddress address, const grpc_channel_args& args) override;
|
159
159
|
void UpdateState(grpc_connectivity_state state,
|
160
160
|
const absl::Status& status,
|
161
161
|
std::unique_ptr<SubchannelPicker> picker) override;
|
@@ -736,10 +736,10 @@ void PriorityLb::ChildPriority::Helper::RequestReresolution() {
|
|
736
736
|
|
737
737
|
RefCountedPtr<SubchannelInterface>
|
738
738
|
PriorityLb::ChildPriority::Helper::CreateSubchannel(
|
739
|
-
const grpc_channel_args& args) {
|
739
|
+
ServerAddress address, const grpc_channel_args& args) {
|
740
740
|
if (priority_->priority_policy_->shutting_down_) return nullptr;
|
741
741
|
return priority_->priority_policy_->channel_control_helper()
|
742
|
-
->CreateSubchannel(args);
|
742
|
+
->CreateSubchannel(std::move(address), args);
|
743
743
|
}
|
744
744
|
|
745
745
|
void PriorityLb::ChildPriority::Helper::UpdateState(
|
@@ -112,9 +112,9 @@ class RoundRobin : public LoadBalancingPolicy {
|
|
112
112
|
RoundRobinSubchannelData> {
|
113
113
|
public:
|
114
114
|
RoundRobinSubchannelList(RoundRobin* policy, TraceFlag* tracer,
|
115
|
-
|
115
|
+
ServerAddressList addresses,
|
116
116
|
const grpc_channel_args& args)
|
117
|
-
: SubchannelList(policy, tracer, addresses,
|
117
|
+
: SubchannelList(policy, tracer, std::move(addresses),
|
118
118
|
policy->channel_control_helper(), args) {
|
119
119
|
// Need to maintain a ref to the LB policy as long as we maintain
|
120
120
|
// any references to subchannels, since the subchannels'
|
@@ -445,7 +445,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
|
|
445
445
|
}
|
446
446
|
}
|
447
447
|
latest_pending_subchannel_list_ = MakeOrphanable<RoundRobinSubchannelList>(
|
448
|
-
this, &grpc_lb_round_robin_trace, args.addresses, *args.args);
|
448
|
+
this, &grpc_lb_round_robin_trace, std::move(args.addresses), *args.args);
|
449
449
|
if (latest_pending_subchannel_list_->num_subchannels() == 0) {
|
450
450
|
// If the new list is empty, immediately promote the new list to the
|
451
451
|
// current list and transition to TRANSIENT_FAILURE.
|
@@ -200,7 +200,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
200
200
|
|
201
201
|
protected:
|
202
202
|
SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer,
|
203
|
-
|
203
|
+
ServerAddressList addresses,
|
204
204
|
LoadBalancingPolicy::ChannelControlHelper* helper,
|
205
205
|
const grpc_channel_args& args);
|
206
206
|
|
@@ -350,8 +350,7 @@ void SubchannelData<SubchannelListType, SubchannelDataType>::ShutdownLocked() {
|
|
350
350
|
|
351
351
|
template <typename SubchannelListType, typename SubchannelDataType>
|
352
352
|
SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
353
|
-
LoadBalancingPolicy* policy, TraceFlag* tracer,
|
354
|
-
const ServerAddressList& addresses,
|
353
|
+
LoadBalancingPolicy* policy, TraceFlag* tracer, ServerAddressList addresses,
|
355
354
|
LoadBalancingPolicy::ChannelControlHelper* helper,
|
356
355
|
const grpc_channel_args& args)
|
357
356
|
: InternallyRefCounted<SubchannelListType>(tracer),
|
@@ -363,50 +362,28 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|
363
362
|
tracer_->name(), policy, this, addresses.size());
|
364
363
|
}
|
365
364
|
subchannels_.reserve(addresses.size());
|
366
|
-
// We need to remove the LB addresses in order to be able to compare the
|
367
|
-
// subchannel keys of subchannels from a different batch of addresses.
|
368
|
-
// We remove the service config, since it will be passed into the
|
369
|
-
// subchannel via call context.
|
370
|
-
static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
|
371
|
-
GRPC_ARG_SERVICE_CONFIG};
|
372
365
|
// Create a subchannel for each address.
|
373
|
-
for (
|
374
|
-
absl::InlinedVector<grpc_arg, 3> args_to_add;
|
375
|
-
const size_t subchannel_address_arg_index = args_to_add.size();
|
376
|
-
args_to_add.emplace_back(
|
377
|
-
Subchannel::CreateSubchannelAddressArg(&addresses[i].address()));
|
378
|
-
if (addresses[i].args() != nullptr) {
|
379
|
-
for (size_t j = 0; j < addresses[i].args()->num_args; ++j) {
|
380
|
-
args_to_add.emplace_back(addresses[i].args()->args[j]);
|
381
|
-
}
|
382
|
-
}
|
383
|
-
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
|
384
|
-
&args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove),
|
385
|
-
args_to_add.data(), args_to_add.size());
|
386
|
-
gpr_free(args_to_add[subchannel_address_arg_index].value.string);
|
366
|
+
for (const ServerAddress& address : addresses) {
|
387
367
|
RefCountedPtr<SubchannelInterface> subchannel =
|
388
|
-
helper->CreateSubchannel(
|
389
|
-
grpc_channel_args_destroy(new_args);
|
368
|
+
helper->CreateSubchannel(std::move(address), args);
|
390
369
|
if (subchannel == nullptr) {
|
391
370
|
// Subchannel could not be created.
|
392
371
|
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
393
372
|
gpr_log(GPR_INFO,
|
394
|
-
"[%s %p] could not create subchannel for address
|
373
|
+
"[%s %p] could not create subchannel for address %s, "
|
395
374
|
"ignoring",
|
396
|
-
tracer_->name(), policy_,
|
397
|
-
grpc_sockaddr_to_uri(&addresses[i].address()).c_str());
|
375
|
+
tracer_->name(), policy_, address.ToString().c_str());
|
398
376
|
}
|
399
377
|
continue;
|
400
378
|
}
|
401
379
|
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
402
380
|
gpr_log(GPR_INFO,
|
403
381
|
"[%s %p] subchannel list %p index %" PRIuPTR
|
404
|
-
": Created subchannel %p for address
|
382
|
+
": Created subchannel %p for address %s",
|
405
383
|
tracer_->name(), policy_, this, subchannels_.size(),
|
406
|
-
subchannel.get(),
|
407
|
-
grpc_sockaddr_to_uri(&addresses[i].address()).c_str());
|
384
|
+
subchannel.get(), address.ToString().c_str());
|
408
385
|
}
|
409
|
-
subchannels_.emplace_back(this,
|
386
|
+
subchannels_.emplace_back(this, address, std::move(subchannel));
|
410
387
|
}
|
411
388
|
}
|
412
389
|
|
@@ -145,7 +145,7 @@ class WeightedTargetLb : public LoadBalancingPolicy {
|
|
145
145
|
~Helper() { weighted_child_.reset(DEBUG_LOCATION, "Helper"); }
|
146
146
|
|
147
147
|
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
148
|
-
const grpc_channel_args& args) override;
|
148
|
+
ServerAddress address, const grpc_channel_args& args) override;
|
149
149
|
void UpdateState(grpc_connectivity_state state,
|
150
150
|
const absl::Status& status,
|
151
151
|
std::unique_ptr<SubchannelPicker> picker) override;
|
@@ -590,10 +590,10 @@ void WeightedTargetLb::WeightedChild::OnDelayedRemovalTimerLocked(
|
|
590
590
|
|
591
591
|
RefCountedPtr<SubchannelInterface>
|
592
592
|
WeightedTargetLb::WeightedChild::Helper::CreateSubchannel(
|
593
|
-
const grpc_channel_args& args) {
|
593
|
+
ServerAddress address, const grpc_channel_args& args) {
|
594
594
|
if (weighted_child_->weighted_target_policy_->shutting_down_) return nullptr;
|
595
595
|
return weighted_child_->weighted_target_policy_->channel_control_helper()
|
596
|
-
->CreateSubchannel(args);
|
596
|
+
->CreateSubchannel(std::move(address), args);
|
597
597
|
}
|
598
598
|
|
599
599
|
void WeightedTargetLb::WeightedChild::Helper::UpdateState(
|
@@ -29,6 +29,8 @@
|
|
29
29
|
#include "src/core/lib/gprpp/memory.h"
|
30
30
|
#include "src/core/lib/gprpp/orphanable.h"
|
31
31
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
32
|
+
#include "src/core/lib/iomgr/closure.h"
|
33
|
+
#include "src/core/lib/iomgr/exec_ctx.h"
|
32
34
|
#include "src/core/lib/transport/error_utils.h"
|
33
35
|
|
34
36
|
namespace grpc_core {
|
@@ -66,11 +68,32 @@ class CdsLb : public LoadBalancingPolicy {
|
|
66
68
|
public:
|
67
69
|
explicit ClusterWatcher(RefCountedPtr<CdsLb> parent)
|
68
70
|
: parent_(std::move(parent)) {}
|
69
|
-
|
70
|
-
void
|
71
|
-
|
71
|
+
|
72
|
+
void OnClusterChanged(XdsApi::CdsUpdate cluster_data) override {
|
73
|
+
new Notifier(parent_, std::move(cluster_data));
|
74
|
+
}
|
75
|
+
void OnError(grpc_error* error) override { new Notifier(parent_, error); }
|
76
|
+
void OnResourceDoesNotExist() override { new Notifier(parent_); }
|
72
77
|
|
73
78
|
private:
|
79
|
+
class Notifier {
|
80
|
+
public:
|
81
|
+
Notifier(RefCountedPtr<CdsLb> parent, XdsApi::CdsUpdate update);
|
82
|
+
Notifier(RefCountedPtr<CdsLb> parent, grpc_error* error);
|
83
|
+
explicit Notifier(RefCountedPtr<CdsLb> parent);
|
84
|
+
|
85
|
+
private:
|
86
|
+
enum Type { kUpdate, kError, kDoesNotExist };
|
87
|
+
|
88
|
+
static void RunInExecCtx(void* arg, grpc_error* error);
|
89
|
+
void RunInWorkSerializer(grpc_error* error);
|
90
|
+
|
91
|
+
RefCountedPtr<CdsLb> parent_;
|
92
|
+
grpc_closure closure_;
|
93
|
+
XdsApi::CdsUpdate update_;
|
94
|
+
Type type_;
|
95
|
+
};
|
96
|
+
|
74
97
|
RefCountedPtr<CdsLb> parent_;
|
75
98
|
};
|
76
99
|
|
@@ -79,7 +102,7 @@ class CdsLb : public LoadBalancingPolicy {
|
|
79
102
|
public:
|
80
103
|
explicit Helper(RefCountedPtr<CdsLb> parent) : parent_(std::move(parent)) {}
|
81
104
|
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
82
|
-
const grpc_channel_args& args) override;
|
105
|
+
ServerAddress address, const grpc_channel_args& args) override;
|
83
106
|
void UpdateState(grpc_connectivity_state state, const absl::Status& status,
|
84
107
|
std::unique_ptr<SubchannelPicker> picker) override;
|
85
108
|
void RequestReresolution() override;
|
@@ -94,6 +117,10 @@ class CdsLb : public LoadBalancingPolicy {
|
|
94
117
|
|
95
118
|
void ShutdownLocked() override;
|
96
119
|
|
120
|
+
void OnClusterChanged(XdsApi::CdsUpdate cluster_data);
|
121
|
+
void OnError(grpc_error* error);
|
122
|
+
void OnResourceDoesNotExist();
|
123
|
+
|
97
124
|
void MaybeDestroyChildPolicyLocked();
|
98
125
|
|
99
126
|
RefCountedPtr<CdsLbConfig> config_;
|
@@ -115,123 +142,50 @@ class CdsLb : public LoadBalancingPolicy {
|
|
115
142
|
};
|
116
143
|
|
117
144
|
//
|
118
|
-
// CdsLb::ClusterWatcher
|
145
|
+
// CdsLb::ClusterWatcher::Notifier
|
119
146
|
//
|
120
147
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
parent_.get(), parent_->xds_client_.get(),
|
127
|
-
cluster_data.eds_service_name.c_str(),
|
128
|
-
cluster_data.lrs_load_reporting_server_name.has_value()
|
129
|
-
? cluster_data.lrs_load_reporting_server_name.value().c_str()
|
130
|
-
: "(unset)");
|
131
|
-
}
|
132
|
-
// Construct config for child policy.
|
133
|
-
Json::Object child_config = {
|
134
|
-
{"clusterName", parent_->config_->cluster()},
|
135
|
-
{"localityPickingPolicy",
|
136
|
-
Json::Array{
|
137
|
-
Json::Object{
|
138
|
-
{"weighted_target_experimental",
|
139
|
-
Json::Object{
|
140
|
-
{"targets", Json::Object()},
|
141
|
-
}},
|
142
|
-
},
|
143
|
-
}},
|
144
|
-
{"endpointPickingPolicy",
|
145
|
-
Json::Array{
|
146
|
-
Json::Object{
|
147
|
-
{"round_robin", Json::Object()},
|
148
|
-
},
|
149
|
-
}},
|
150
|
-
};
|
151
|
-
if (!cluster_data.eds_service_name.empty()) {
|
152
|
-
child_config["edsServiceName"] = cluster_data.eds_service_name;
|
153
|
-
}
|
154
|
-
if (cluster_data.lrs_load_reporting_server_name.has_value()) {
|
155
|
-
child_config["lrsLoadReportingServerName"] =
|
156
|
-
cluster_data.lrs_load_reporting_server_name.value();
|
157
|
-
}
|
158
|
-
Json json = Json::Array{
|
159
|
-
Json::Object{
|
160
|
-
{"eds_experimental", std::move(child_config)},
|
161
|
-
},
|
162
|
-
};
|
163
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
164
|
-
std::string json_str = json.Dump(/*indent=*/1);
|
165
|
-
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s",
|
166
|
-
parent_.get(), json_str.c_str());
|
167
|
-
}
|
168
|
-
grpc_error* error = GRPC_ERROR_NONE;
|
169
|
-
RefCountedPtr<LoadBalancingPolicy::Config> config =
|
170
|
-
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error);
|
171
|
-
if (error != GRPC_ERROR_NONE) {
|
172
|
-
OnError(error);
|
173
|
-
return;
|
174
|
-
}
|
175
|
-
// Create child policy if not already present.
|
176
|
-
if (parent_->child_policy_ == nullptr) {
|
177
|
-
LoadBalancingPolicy::Args args;
|
178
|
-
args.work_serializer = parent_->work_serializer();
|
179
|
-
args.args = parent_->args_;
|
180
|
-
args.channel_control_helper = absl::make_unique<Helper>(parent_->Ref());
|
181
|
-
parent_->child_policy_ =
|
182
|
-
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(config->name(),
|
183
|
-
std::move(args));
|
184
|
-
if (parent_->child_policy_ == nullptr) {
|
185
|
-
OnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
186
|
-
"failed to create child policy"));
|
187
|
-
return;
|
188
|
-
}
|
189
|
-
grpc_pollset_set_add_pollset_set(
|
190
|
-
parent_->child_policy_->interested_parties(),
|
191
|
-
parent_->interested_parties());
|
192
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
193
|
-
gpr_log(GPR_INFO, "[cdslb %p] created child policy %s (%p)",
|
194
|
-
parent_.get(), config->name(), parent_->child_policy_.get());
|
195
|
-
}
|
196
|
-
}
|
197
|
-
// Update child policy.
|
198
|
-
UpdateArgs args;
|
199
|
-
args.config = std::move(config);
|
200
|
-
args.args = grpc_channel_args_copy(parent_->args_);
|
201
|
-
parent_->child_policy_->UpdateLocked(std::move(args));
|
148
|
+
CdsLb::ClusterWatcher::Notifier::Notifier(RefCountedPtr<CdsLb> parent,
|
149
|
+
XdsApi::CdsUpdate update)
|
150
|
+
: parent_(std::move(parent)), update_(std::move(update)), type_(kUpdate) {
|
151
|
+
GRPC_CLOSURE_INIT(&closure_, &RunInExecCtx, this, nullptr);
|
152
|
+
ExecCtx::Run(DEBUG_LOCATION, &closure_, GRPC_ERROR_NONE);
|
202
153
|
}
|
203
154
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
// policy (i.e., we have not yet received data from xds). Otherwise,
|
210
|
-
// we keep running with the data we had previously.
|
211
|
-
if (parent_->child_policy_ == nullptr) {
|
212
|
-
parent_->channel_control_helper()->UpdateState(
|
213
|
-
GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
|
214
|
-
absl::make_unique<TransientFailurePicker>(error));
|
215
|
-
} else {
|
216
|
-
GRPC_ERROR_UNREF(error);
|
217
|
-
}
|
155
|
+
CdsLb::ClusterWatcher::Notifier::Notifier(RefCountedPtr<CdsLb> parent,
|
156
|
+
grpc_error* error)
|
157
|
+
: parent_(std::move(parent)), type_(kError) {
|
158
|
+
GRPC_CLOSURE_INIT(&closure_, &RunInExecCtx, this, nullptr);
|
159
|
+
ExecCtx::Run(DEBUG_LOCATION, &closure_, error);
|
218
160
|
}
|
219
161
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
162
|
+
CdsLb::ClusterWatcher::Notifier::Notifier(RefCountedPtr<CdsLb> parent)
|
163
|
+
: parent_(std::move(parent)), type_(kDoesNotExist) {
|
164
|
+
GRPC_CLOSURE_INIT(&closure_, &RunInExecCtx, this, nullptr);
|
165
|
+
ExecCtx::Run(DEBUG_LOCATION, &closure_, GRPC_ERROR_NONE);
|
166
|
+
}
|
167
|
+
|
168
|
+
void CdsLb::ClusterWatcher::Notifier::RunInExecCtx(void* arg,
|
169
|
+
grpc_error* error) {
|
170
|
+
Notifier* self = static_cast<Notifier*>(arg);
|
171
|
+
GRPC_ERROR_REF(error);
|
172
|
+
self->parent_->work_serializer()->Run(
|
173
|
+
[self, error]() { self->RunInWorkSerializer(error); }, DEBUG_LOCATION);
|
174
|
+
}
|
175
|
+
|
176
|
+
void CdsLb::ClusterWatcher::Notifier::RunInWorkSerializer(grpc_error* error) {
|
177
|
+
switch (type_) {
|
178
|
+
case kUpdate:
|
179
|
+
parent_->OnClusterChanged(std::move(update_));
|
180
|
+
break;
|
181
|
+
case kError:
|
182
|
+
parent_->OnError(error);
|
183
|
+
break;
|
184
|
+
case kDoesNotExist:
|
185
|
+
parent_->OnResourceDoesNotExist();
|
186
|
+
break;
|
187
|
+
};
|
188
|
+
delete this;
|
235
189
|
}
|
236
190
|
|
237
191
|
//
|
@@ -239,9 +193,10 @@ void CdsLb::ClusterWatcher::OnResourceDoesNotExist() {
|
|
239
193
|
//
|
240
194
|
|
241
195
|
RefCountedPtr<SubchannelInterface> CdsLb::Helper::CreateSubchannel(
|
242
|
-
const grpc_channel_args& args) {
|
196
|
+
ServerAddress address, const grpc_channel_args& args) {
|
243
197
|
if (parent_->shutting_down_) return nullptr;
|
244
|
-
return parent_->channel_control_helper()->CreateSubchannel(
|
198
|
+
return parent_->channel_control_helper()->CreateSubchannel(std::move(address),
|
199
|
+
args);
|
245
200
|
}
|
246
201
|
|
247
202
|
void CdsLb::Helper::UpdateState(grpc_connectivity_state state,
|
@@ -279,8 +234,8 @@ void CdsLb::Helper::AddTraceEvent(TraceSeverity severity,
|
|
279
234
|
CdsLb::CdsLb(RefCountedPtr<XdsClient> xds_client, Args args)
|
280
235
|
: LoadBalancingPolicy(std::move(args)), xds_client_(std::move(xds_client)) {
|
281
236
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
282
|
-
gpr_log(GPR_INFO, "[cdslb %p] created -- using xds client %p
|
283
|
-
|
237
|
+
gpr_log(GPR_INFO, "[cdslb %p] created -- using xds client %p", this,
|
238
|
+
xds_client_.get());
|
284
239
|
}
|
285
240
|
}
|
286
241
|
|
@@ -288,7 +243,6 @@ CdsLb::~CdsLb() {
|
|
288
243
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
289
244
|
gpr_log(GPR_INFO, "[cdslb %p] destroying cds LB policy", this);
|
290
245
|
}
|
291
|
-
grpc_channel_args_destroy(args_);
|
292
246
|
}
|
293
247
|
|
294
248
|
void CdsLb::ShutdownLocked() {
|
@@ -305,8 +259,10 @@ void CdsLb::ShutdownLocked() {
|
|
305
259
|
}
|
306
260
|
xds_client_->CancelClusterDataWatch(config_->cluster(), cluster_watcher_);
|
307
261
|
}
|
308
|
-
xds_client_.reset();
|
262
|
+
xds_client_.reset(DEBUG_LOCATION, "CdsLb");
|
309
263
|
}
|
264
|
+
grpc_channel_args_destroy(args_);
|
265
|
+
args_ = nullptr;
|
310
266
|
}
|
311
267
|
|
312
268
|
void CdsLb::MaybeDestroyChildPolicyLocked() {
|
@@ -354,6 +310,121 @@ void CdsLb::UpdateLocked(UpdateArgs args) {
|
|
354
310
|
}
|
355
311
|
}
|
356
312
|
|
313
|
+
void CdsLb::OnClusterChanged(XdsApi::CdsUpdate cluster_data) {
|
314
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
315
|
+
gpr_log(GPR_INFO,
|
316
|
+
"[cdslb %p] received CDS update from xds client %p: "
|
317
|
+
"eds_service_name=%s lrs_load_reporting_server_name=%s "
|
318
|
+
"max_concurrent_requests=%d",
|
319
|
+
this, xds_client_.get(), cluster_data.eds_service_name.c_str(),
|
320
|
+
cluster_data.lrs_load_reporting_server_name.has_value()
|
321
|
+
? cluster_data.lrs_load_reporting_server_name.value().c_str()
|
322
|
+
: "(unset)",
|
323
|
+
cluster_data.max_concurrent_requests);
|
324
|
+
}
|
325
|
+
// Construct config for child policy.
|
326
|
+
Json::Object child_config = {
|
327
|
+
{"clusterName", config_->cluster()},
|
328
|
+
{"max_concurrent_requests", cluster_data.max_concurrent_requests},
|
329
|
+
{"localityPickingPolicy",
|
330
|
+
Json::Array{
|
331
|
+
Json::Object{
|
332
|
+
{"weighted_target_experimental",
|
333
|
+
Json::Object{
|
334
|
+
{"targets", Json::Object()},
|
335
|
+
}},
|
336
|
+
},
|
337
|
+
}},
|
338
|
+
{"endpointPickingPolicy",
|
339
|
+
Json::Array{
|
340
|
+
Json::Object{
|
341
|
+
{"round_robin", Json::Object()},
|
342
|
+
},
|
343
|
+
}},
|
344
|
+
};
|
345
|
+
if (!cluster_data.eds_service_name.empty()) {
|
346
|
+
child_config["edsServiceName"] = cluster_data.eds_service_name;
|
347
|
+
}
|
348
|
+
if (cluster_data.lrs_load_reporting_server_name.has_value()) {
|
349
|
+
child_config["lrsLoadReportingServerName"] =
|
350
|
+
cluster_data.lrs_load_reporting_server_name.value();
|
351
|
+
}
|
352
|
+
Json json = Json::Array{
|
353
|
+
Json::Object{
|
354
|
+
{"eds_experimental", std::move(child_config)},
|
355
|
+
},
|
356
|
+
};
|
357
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
358
|
+
std::string json_str = json.Dump(/*indent=*/1);
|
359
|
+
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s", this,
|
360
|
+
json_str.c_str());
|
361
|
+
}
|
362
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
363
|
+
RefCountedPtr<LoadBalancingPolicy::Config> config =
|
364
|
+
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error);
|
365
|
+
if (error != GRPC_ERROR_NONE) {
|
366
|
+
OnError(error);
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
// Create child policy if not already present.
|
370
|
+
if (child_policy_ == nullptr) {
|
371
|
+
LoadBalancingPolicy::Args args;
|
372
|
+
args.work_serializer = work_serializer();
|
373
|
+
args.args = args_;
|
374
|
+
args.channel_control_helper = absl::make_unique<Helper>(Ref());
|
375
|
+
child_policy_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
|
376
|
+
config->name(), std::move(args));
|
377
|
+
if (child_policy_ == nullptr) {
|
378
|
+
OnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
379
|
+
"failed to create child policy"));
|
380
|
+
return;
|
381
|
+
}
|
382
|
+
grpc_pollset_set_add_pollset_set(child_policy_->interested_parties(),
|
383
|
+
interested_parties());
|
384
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
|
385
|
+
gpr_log(GPR_INFO, "[cdslb %p] created child policy %s (%p)", this,
|
386
|
+
config->name(), child_policy_.get());
|
387
|
+
}
|
388
|
+
}
|
389
|
+
// Update child policy.
|
390
|
+
UpdateArgs args;
|
391
|
+
args.config = std::move(config);
|
392
|
+
args.args = grpc_channel_args_copy(args_);
|
393
|
+
child_policy_->UpdateLocked(std::move(args));
|
394
|
+
}
|
395
|
+
|
396
|
+
void CdsLb::OnError(grpc_error* error) {
|
397
|
+
gpr_log(GPR_ERROR, "[cdslb %p] xds error obtaining data for cluster %s: %s",
|
398
|
+
this, config_->cluster().c_str(), grpc_error_string(error));
|
399
|
+
// Go into TRANSIENT_FAILURE if we have not yet created the child
|
400
|
+
// policy (i.e., we have not yet received data from xds). Otherwise,
|
401
|
+
// we keep running with the data we had previously.
|
402
|
+
if (child_policy_ == nullptr) {
|
403
|
+
channel_control_helper()->UpdateState(
|
404
|
+
GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
|
405
|
+
absl::make_unique<TransientFailurePicker>(error));
|
406
|
+
} else {
|
407
|
+
GRPC_ERROR_UNREF(error);
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
411
|
+
void CdsLb::OnResourceDoesNotExist() {
|
412
|
+
gpr_log(GPR_ERROR,
|
413
|
+
"[cdslb %p] CDS resource for %s does not exist -- reporting "
|
414
|
+
"TRANSIENT_FAILURE",
|
415
|
+
this, config_->cluster().c_str());
|
416
|
+
grpc_error* error =
|
417
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
418
|
+
absl::StrCat("CDS resource \"", config_->cluster(),
|
419
|
+
"\" does not exist")
|
420
|
+
.c_str()),
|
421
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
|
422
|
+
channel_control_helper()->UpdateState(
|
423
|
+
GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
|
424
|
+
absl::make_unique<TransientFailurePicker>(error));
|
425
|
+
MaybeDestroyChildPolicyLocked();
|
426
|
+
}
|
427
|
+
|
357
428
|
//
|
358
429
|
// factory
|
359
430
|
//
|
@@ -362,12 +433,13 @@ class CdsLbFactory : public LoadBalancingPolicyFactory {
|
|
362
433
|
public:
|
363
434
|
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
|
364
435
|
LoadBalancingPolicy::Args args) const override {
|
365
|
-
|
366
|
-
|
367
|
-
if (
|
436
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
437
|
+
RefCountedPtr<XdsClient> xds_client = XdsClient::GetOrCreate(&error);
|
438
|
+
if (error != GRPC_ERROR_NONE) {
|
368
439
|
gpr_log(GPR_ERROR,
|
369
|
-
"
|
370
|
-
|
440
|
+
"cannot get XdsClient to instantiate cds LB policy: %s",
|
441
|
+
grpc_error_string(error));
|
442
|
+
GRPC_ERROR_UNREF(error);
|
371
443
|
return nullptr;
|
372
444
|
}
|
373
445
|
return MakeOrphanable<CdsLb>(std::move(xds_client), std::move(args));
|