xds: change XdsClient watcher API to use absl::Status (#29143)

pull/29150/head
Mark D. Roth 3 years ago committed by GitHub
parent 7bf0babc28
commit f4126cdfbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  2. 22
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
  3. 66
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  4. 5
      src/core/ext/filters/server_config_selector/server_config_selector_filter.cc
  5. 61
      src/core/ext/xds/xds_client.cc
  6. 4
      src/core/ext/xds/xds_client.h
  7. 36
      src/core/ext/xds/xds_server_config_fetcher.cc

@ -83,11 +83,11 @@ class CdsLb : public LoadBalancingPolicy {
},
DEBUG_LOCATION);
}
void OnError(grpc_error_handle error) override {
void OnError(absl::Status status) override {
Ref().release(); // Ref held by lambda
parent_->work_serializer()->Run(
[this, error]() {
parent_->OnError(name_, error);
[this, status]() {
parent_->OnError(name_, status);
Unref();
},
DEBUG_LOCATION);
@ -141,10 +141,10 @@ class CdsLb : public LoadBalancingPolicy {
std::set<std::string>* clusters_needed);
void OnClusterChanged(const std::string& name,
XdsClusterResource cluster_data);
void OnError(const std::string& name, grpc_error_handle error);
void OnError(const std::string& name, absl::Status status);
void OnResourceDoesNotExist(const std::string& name);
grpc_error_handle UpdateXdsCertificateProvider(
absl::Status UpdateXdsCertificateProvider(
const std::string& cluster_name, const XdsClusterResource& cluster_data);
void CancelClusterDataWatch(absl::string_view cluster_name,
@ -390,10 +390,10 @@ void CdsLb::OnClusterChanged(const std::string& name,
if (it == watchers_.end()) return;
it->second.update = cluster_data;
// Take care of integration with new certificate code.
grpc_error_handle error = GRPC_ERROR_NONE;
error = UpdateXdsCertificateProvider(name, it->second.update.value());
if (error != GRPC_ERROR_NONE) {
return OnError(name, error);
absl::Status status =
UpdateXdsCertificateProvider(name, it->second.update.value());
if (!status.ok()) {
return OnError(name, status);
}
// Scan the map starting from the root cluster to generate the list of
// discovery mechanisms. If we don't have some of the data we need (i.e., we
@ -435,10 +435,12 @@ void CdsLb::OnClusterChanged(const std::string& name,
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s",
this, json_str.c_str());
}
grpc_error_handle error = GRPC_ERROR_NONE;
RefCountedPtr<LoadBalancingPolicy::Config> config =
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json, &error);
if (error != GRPC_ERROR_NONE) {
OnError(name, error);
OnError(name, absl::UnavailableError(grpc_error_std_string(error)));
GRPC_ERROR_UNREF(error);
return;
}
// Create child policy if not already present.
@ -450,8 +452,7 @@ void CdsLb::OnClusterChanged(const std::string& name,
child_policy_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
config->name(), std::move(args));
if (child_policy_ == nullptr) {
OnError(name, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"failed to create child policy"));
OnError(name, absl::UnavailableError("failed to create child policy"));
return;
}
grpc_pollset_set_add_pollset_set(child_policy_->interested_parties(),
@ -489,19 +490,18 @@ void CdsLb::OnClusterChanged(const std::string& name,
}
}
void CdsLb::OnError(const std::string& name, grpc_error_handle error) {
void CdsLb::OnError(const std::string& name, absl::Status status) {
gpr_log(GPR_ERROR, "[cdslb %p] xds error obtaining data for cluster %s: %s",
this, name.c_str(), grpc_error_std_string(error).c_str());
this, name.c_str(), status.ToString().c_str());
// Go into TRANSIENT_FAILURE if we have not yet created the child
// policy (i.e., we have not yet received data from xds). Otherwise,
// we keep running with the data we had previously.
if (child_policy_ == nullptr) {
absl::Status status = grpc_error_to_absl_status(error);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE, status,
absl::make_unique<TransientFailurePicker>(status));
absl::make_unique<TransientFailurePicker>(
absl::UnavailableError(status.ToString())));
}
GRPC_ERROR_UNREF(error);
}
void CdsLb::OnResourceDoesNotExist(const std::string& name) {
@ -517,7 +517,7 @@ void CdsLb::OnResourceDoesNotExist(const std::string& name) {
MaybeDestroyChildPolicyLocked();
}
grpc_error_handle CdsLb::UpdateXdsCertificateProvider(
absl::Status CdsLb::UpdateXdsCertificateProvider(
const std::string& cluster_name, const XdsClusterResource& cluster_data) {
// Early out if channel is not configured to use xds security.
grpc_channel_credentials* channel_credentials =
@ -525,7 +525,7 @@ grpc_error_handle CdsLb::UpdateXdsCertificateProvider(
if (channel_credentials == nullptr ||
channel_credentials->type() != XdsCredentials::Type()) {
xds_certificate_provider_ = nullptr;
return GRPC_ERROR_NONE;
return absl::OkStatus();
}
if (xds_certificate_provider_ == nullptr) {
xds_certificate_provider_ = MakeRefCounted<XdsCertificateProvider>();
@ -543,11 +543,9 @@ grpc_error_handle CdsLb::UpdateXdsCertificateProvider(
xds_client_->certificate_provider_store()
.CreateOrGetCertificateProvider(root_provider_instance_name);
if (new_root_provider == nullptr) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrCat("Certificate provider instance name: \"",
root_provider_instance_name, "\" not recognized.")),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
return absl::UnavailableError(
absl::StrCat("Certificate provider instance name: \"",
root_provider_instance_name, "\" not recognized."));
}
}
if (root_certificate_provider_ != new_root_provider) {
@ -582,11 +580,9 @@ grpc_error_handle CdsLb::UpdateXdsCertificateProvider(
xds_client_->certificate_provider_store()
.CreateOrGetCertificateProvider(identity_provider_instance_name);
if (new_identity_provider == nullptr) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
"Certificate provider instance name: \"",
identity_provider_instance_name, "\" not recognized.")),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
return absl::UnavailableError(
absl::StrCat("Certificate provider instance name: \"",
identity_provider_instance_name, "\" not recognized."));
}
}
if (identity_certificate_provider_ != new_identity_provider) {
@ -614,7 +610,7 @@ grpc_error_handle CdsLb::UpdateXdsCertificateProvider(
.match_subject_alt_names;
xds_certificate_provider_->UpdateSubjectAlternativeNameMatchers(
cluster_name, match_subject_alt_names);
return GRPC_ERROR_NONE;
return absl::OkStatus();
}
void CdsLb::CancelClusterDataWatch(absl::string_view cluster_name,

@ -186,11 +186,11 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
},
DEBUG_LOCATION);
}
void OnError(grpc_error_handle error) override {
void OnError(absl::Status status) override {
Ref().release(); // ref held by callback
discovery_mechanism_->parent()->work_serializer()->Run(
[this, error]() {
OnErrorHelper(error);
[this, status]() {
OnErrorHelper(status);
Unref();
},
DEBUG_LOCATION);
@ -213,9 +213,9 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
discovery_mechanism_->parent()->OnEndpointChanged(
discovery_mechanism_->index(), std::move(update));
}
void OnErrorHelper(grpc_error_handle error) {
void OnErrorHelper(absl::Status status) {
discovery_mechanism_->parent()->OnError(discovery_mechanism_->index(),
error);
status);
}
void OnResourceDoesNotExistHelper() {
discovery_mechanism_->parent()->OnResourceDoesNotExist(
@ -326,7 +326,7 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
void ShutdownLocked() override;
void OnEndpointChanged(size_t index, XdsEndpointResource update);
void OnError(size_t index, grpc_error_handle error);
void OnError(size_t index, absl::Status status);
void OnResourceDoesNotExist(size_t index);
void MaybeDestroyChildPolicyLocked();
@ -491,9 +491,8 @@ void XdsClusterResolverLb::LogicalDNSDiscoveryMechanism::Orphan() {
void XdsClusterResolverLb::LogicalDNSDiscoveryMechanism::ResolverResultHandler::
ReportResult(Resolver::Result result) {
if (!result.addresses.ok()) {
discovery_mechanism_->parent()->OnError(
discovery_mechanism_->index(),
absl_status_to_grpc_error(result.addresses.status()));
discovery_mechanism_->parent()->OnError(discovery_mechanism_->index(),
result.addresses.status());
return;
}
// Convert resolver result to EDS update.
@ -660,12 +659,11 @@ void XdsClusterResolverLb::OnEndpointChanged(size_t index,
UpdatePriorityList(std::move(priority_list));
}
void XdsClusterResolverLb::OnError(size_t index, grpc_error_handle error) {
void XdsClusterResolverLb::OnError(size_t index, absl::Status status) {
gpr_log(GPR_ERROR,
"[xds_cluster_resolver_lb %p] discovery mechanism %" PRIuPTR
" xds watcher reported error: %s",
this, index, grpc_error_std_string(error).c_str());
GRPC_ERROR_UNREF(error);
this, index, status.ToString().c_str());
if (shutting_down_) return;
if (!discovery_mechanisms_[index].first_update_received) {
// Call OnEndpointChanged with an empty update just like

@ -1,20 +1,18 @@
/*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
//
// Copyright 2019 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <grpc/support/port_platform.h>
@ -123,11 +121,11 @@ class XdsResolver : public Resolver {
},
DEBUG_LOCATION);
}
void OnError(grpc_error_handle error) override {
void OnError(absl::Status status) override {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
[this, error]() {
resolver_->OnError(error);
[this, status]() {
resolver_->OnError(status);
Unref();
},
DEBUG_LOCATION);
@ -162,11 +160,11 @@ class XdsResolver : public Resolver {
},
DEBUG_LOCATION);
}
void OnError(grpc_error_handle error) override {
void OnError(absl::Status status) override {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
[this, error]() {
resolver_->OnError(error);
[this, status]() {
resolver_->OnError(status);
Unref();
},
DEBUG_LOCATION);
@ -305,7 +303,7 @@ class XdsResolver : public Resolver {
void OnListenerUpdate(XdsListenerResource listener);
void OnRouteConfigUpdate(XdsRouteConfigResource rds_update);
void OnError(grpc_error_handle error);
void OnError(absl::Status status);
void OnResourceDoesNotExist();
absl::StatusOr<RefCountedPtr<ServiceConfig>> CreateServiceConfig();
@ -858,7 +856,7 @@ void XdsResolver::OnRouteConfigUpdate(XdsRouteConfigResource rds_update) {
VirtualHostListIterator(&rds_update.virtual_hosts),
data_plane_authority_);
if (!vhost_index.has_value()) {
OnError(GRPC_ERROR_CREATE_FROM_CPP_STRING(
OnError(absl::UnavailableError(
absl::StrCat("could not find VirtualHost for ", data_plane_authority_,
" in RouteConfiguration")));
return;
@ -869,20 +867,16 @@ void XdsResolver::OnRouteConfigUpdate(XdsRouteConfigResource rds_update) {
GenerateResult();
}
void XdsResolver::OnError(grpc_error_handle error) {
void XdsResolver::OnError(absl::Status status) {
gpr_log(GPR_ERROR, "[xds_resolver %p] received error from XdsClient: %s",
this, grpc_error_std_string(error).c_str());
if (xds_client_ == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
this, status.ToString().c_str());
if (xds_client_ == nullptr) return;
Result result;
grpc_arg new_arg = xds_client_->MakeChannelArg();
result.args = grpc_channel_args_copy_and_add(args_, &new_arg, 1);
result.service_config = absl::UnavailableError(absl::StrCat(
"error obtaining xDS resources: ", grpc_error_std_string(error)));
result.service_config = absl::UnavailableError(
absl::StrCat("error obtaining xDS resources: ", status.ToString()));
result_handler_->ReportResult(std::move(result));
GRPC_ERROR_UNREF(error);
}
void XdsResolver::OnResourceDoesNotExist() {
@ -946,8 +940,8 @@ void XdsResolver::GenerateResult() {
grpc_error_handle error = GRPC_ERROR_NONE;
auto config_selector = MakeRefCounted<XdsConfigSelector>(Ref(), &error);
if (error != GRPC_ERROR_NONE) {
OnError(grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAVAILABLE));
OnError(absl::UnavailableError(grpc_error_std_string(error)));
GRPC_ERROR_UNREF(error);
return;
}
Result result;

@ -212,7 +212,10 @@ void CallData::RecvInitialMetadataReady(void* user_data,
&calld->service_config_call_data_;
}
} else {
calld->error_ = absl_status_to_grpc_error(config_selector.status());
calld->error_ = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(
config_selector.status().ToString()),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
error = calld->error_;
}
}

@ -89,15 +89,14 @@ class XdsClient::Notifier {
// watchers_list within \a work_serializer. Works with all 4 resource types.
template <class T>
static void ScheduleNotifyWatchersOnErrorInWorkSerializer(
XdsClient* xds_client, const T& watchers_list, grpc_error_handle error,
XdsClient* xds_client, const T& watchers_list, absl::Status status,
const DebugLocation& location) {
xds_client->work_serializer_.Schedule(
[watchers_list, error]()
[watchers_list, status]()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&xds_client->work_serializer_) {
for (const auto& p : watchers_list) {
p.first->OnError(GRPC_ERROR_REF(error));
p.first->OnError(status);
}
GRPC_ERROR_UNREF(error);
},
location);
}
@ -269,19 +268,16 @@ class XdsClient::ChannelState::AdsCallState
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsClient::mu_) {
if (error == GRPC_ERROR_NONE && timer_pending_) {
timer_pending_ = false;
grpc_error_handle watcher_error =
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
"timeout obtaining resource {type=%s name=%s} from xds server",
type_->type_url(),
XdsClient::ConstructFullXdsResourceName(
name_.authority, type_->type_url(), name_.key)));
watcher_error = grpc_error_set_int(
watcher_error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
absl::Status watcher_error = absl::UnavailableError(absl::StrFormat(
"timeout obtaining resource {type=%s name=%s} from xds server",
type_->type_url(),
XdsClient::ConstructFullXdsResourceName(
name_.authority, type_->type_url(), name_.key)));
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p] xds server %s: %s",
ads_calld_->xds_client(),
ads_calld_->chand()->server_.server_uri.c_str(),
grpc_error_std_string(watcher_error).c_str());
watcher_error.ToString().c_str());
}
auto& authority_state =
ads_calld_->xds_client()->authority_state_map_[name_.authority];
@ -496,7 +492,7 @@ class XdsClient::ChannelState::StateWatcher
parent_->xds_client(), parent_->server_.server_uri.c_str(),
status.ToString().c_str());
parent_->xds_client_->NotifyOnErrorLocked(
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
absl::UnavailableError(absl::StrCat(
"xds channel in TRANSIENT_FAILURE, connectivity error: ",
status.ToString())));
}
@ -603,7 +599,7 @@ bool IsLameChannel(grpc_channel* channel) {
void XdsClient::ChannelState::StartConnectivityWatchLocked() {
if (IsLameChannel(channel_)) {
xds_client()->NotifyOnErrorLocked(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("xds client has a lame channel"));
absl::UnavailableError("xds client has a lame channel"));
return;
}
ClientChannel* client_channel = ClientChannel::GetFromChannel(channel_);
@ -883,10 +879,8 @@ void XdsClient::ChannelState::AdsCallState::AdsResponseParser::ParseResource(
": validation error: ", result->resource.status().ToString()));
Notifier::ScheduleNotifyWatchersOnErrorInWorkSerializer(
xds_client(), resource_state.watchers,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
"invalid resource: ", result->resource.status().ToString())),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
absl::UnavailableError(absl::StrCat(
"invalid resource: ", result->resource.status().ToString())),
DEBUG_LOCATION);
UpdateResourceMetadataNacked(result_.version,
result->resource.status().ToString(),
@ -1321,13 +1315,11 @@ void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked(
// Try to restart the call.
parent_->OnCallFinishedLocked();
// Send error to all watchers.
xds_client()->NotifyOnErrorLocked(
GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
"xDS call failed: xDS server: %s, ADS call status code=%d, "
"details='%s', error='%s'",
chand()->server_.server_uri, status_code_,
StringViewFromSlice(status_details_),
grpc_error_std_string(error))));
xds_client()->NotifyOnErrorLocked(absl::UnavailableError(absl::StrFormat(
"xDS call failed: xDS server: %s, ADS call status code=%d, "
"details='%s', error='%s'",
chand()->server_.server_uri, status_code_,
StringViewFromSlice(status_details_), grpc_error_std_string(error))));
}
GRPC_ERROR_UNREF(error);
}
@ -1899,7 +1891,7 @@ void XdsClient::WatchResource(const XdsResourceType* type,
RefCountedPtr<ResourceWatcherInterface> watcher) {
ResourceWatcherInterface* w = watcher.get();
// Lambda for handling failure cases.
auto fail = [&](grpc_error_handle error) mutable {
auto fail = [&](absl::Status status) mutable {
{
MutexLock lock(&mu_);
MaybeRegisterResourceTypeLocked(type);
@ -1908,14 +1900,14 @@ void XdsClient::WatchResource(const XdsResourceType* type,
work_serializer_.Run(
// TODO(yashykt): When we move to C++14, capture watcher using
// std::move()
[watcher, error]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) {
watcher->OnError(error);
[watcher, status]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) {
watcher->OnError(status);
},
DEBUG_LOCATION);
};
auto resource_name = ParseXdsResourceName(name, type);
if (!resource_name.ok()) {
fail(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
fail(absl::UnavailableError(absl::StrFormat(
"Unable to parse resource name for listener %s", name)));
return;
}
@ -1925,7 +1917,7 @@ void XdsClient::WatchResource(const XdsResourceType* type,
if (absl::ConsumePrefix(&authority_name, "xdstp:")) {
auto* authority = bootstrap_->LookupAuthority(std::string(authority_name));
if (authority == nullptr) {
fail(GRPC_ERROR_CREATE_FROM_CPP_STRING(
fail(absl::UnavailableError(
absl::StrCat("authority \"", authority_name,
"\" not present in bootstrap config")));
return;
@ -2206,7 +2198,7 @@ void XdsClient::ResetBackoff() {
}
}
void XdsClient::NotifyOnErrorLocked(grpc_error_handle error) {
void XdsClient::NotifyOnErrorLocked(absl::Status status) {
std::set<RefCountedPtr<ResourceWatcherInterface>> watchers;
for (const auto& a : authority_state_map_) { // authority
for (const auto& t : a.second.resource_map) { // type
@ -2220,11 +2212,10 @@ void XdsClient::NotifyOnErrorLocked(grpc_error_handle error) {
work_serializer_.Schedule(
// TODO(yashykt): When we move to C++14, capture watchers using
// std::move()
[watchers, error]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(work_serializer_) {
[watchers, status]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(work_serializer_) {
for (const auto& watcher : watchers) {
watcher->OnError(GRPC_ERROR_REF(error));
watcher->OnError(status);
}
GRPC_ERROR_UNREF(error);
},
DEBUG_LOCATION);
}

@ -55,7 +55,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
virtual void OnGenericResourceChanged(
const XdsResourceType::ResourceData* resource)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) = 0;
virtual void OnError(grpc_error_handle error)
virtual void OnError(absl::Status status)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) = 0;
virtual void OnResourceDoesNotExist()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) = 0;
@ -269,7 +269,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
class Notifier;
// Sends an error notification to all watchers.
void NotifyOnErrorLocked(grpc_error_handle error)
void NotifyOnErrorLocked(absl::Status status)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
void MaybeRegisterResourceTypeLocked(const XdsResourceType* resource_type)

@ -100,7 +100,7 @@ class XdsServerConfigFetcher::ListenerWatcher
void OnResourceChanged(XdsListenerResource listener) override;
void OnError(grpc_error_handle error) override;
void OnError(absl::Status status) override;
void OnResourceDoesNotExist() override;
@ -195,7 +195,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager
// RDS resources.
void OnRouteConfigChanged(const std::string& resource_name,
XdsRouteConfigResource route_config);
void OnError(const std::string& resource_name, grpc_error_handle error);
void OnError(const std::string& resource_name, absl::Status status);
void OnResourceDoesNotExist(const std::string& resource_name);
RefCountedPtr<XdsClient> xds_client_;
@ -233,8 +233,8 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
std::move(route_config));
}
void OnError(grpc_error_handle error) override {
filter_chain_match_manager_->OnError(resource_name_, error);
void OnError(absl::Status status) override {
filter_chain_match_manager_->OnError(resource_name_, status);
}
void OnResourceDoesNotExist() override {
@ -370,7 +370,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
class RouteConfigWatcher;
void OnRouteConfigChanged(XdsRouteConfigResource rds_update);
void OnError(grpc_error_handle error);
void OnError(absl::Status status);
void OnResourceDoesNotExist();
RefCountedPtr<XdsClient> xds_client_;
@ -398,7 +398,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
parent_->OnRouteConfigChanged(std::move(route_config));
}
void OnError(grpc_error_handle error) override { parent_->OnError(error); }
void OnError(absl::Status status) override { parent_->OnError(status); }
void OnResourceDoesNotExist() override { parent_->OnResourceDoesNotExist(); }
@ -510,29 +510,26 @@ void XdsServerConfigFetcher::ListenerWatcher::OnResourceChanged(
}
}
void XdsServerConfigFetcher::ListenerWatcher::OnError(grpc_error_handle error) {
void XdsServerConfigFetcher::ListenerWatcher::OnError(absl::Status status) {
MutexLock lock(&mu_);
if (filter_chain_match_manager_ != nullptr ||
pending_filter_chain_match_manager_ != nullptr) {
gpr_log(GPR_ERROR,
"ListenerWatcher:%p XdsClient reports error: %s for %s; "
"ignoring in favor of existing resource",
this, grpc_error_std_string(error).c_str(),
listening_address_.c_str());
this, status.ToString().c_str(), listening_address_.c_str());
} else {
if (serving_status_notifier_.on_serving_status_update != nullptr) {
serving_status_notifier_.on_serving_status_update(
serving_status_notifier_.user_data, listening_address_.c_str(),
{GRPC_STATUS_UNAVAILABLE, grpc_error_std_string(error).c_str()});
{GRPC_STATUS_UNAVAILABLE, status.ToString().c_str()});
} else {
gpr_log(GPR_ERROR,
"ListenerWatcher:%p error obtaining xDS Listener resource: %s; "
"not serving on %s",
this, grpc_error_std_string(error).c_str(),
listening_address_.c_str());
this, status.ToString().c_str(), listening_address_.c_str());
}
}
GRPC_ERROR_UNREF(error);
}
void XdsServerConfigFetcher::ListenerWatcher::OnFatalError(
@ -778,7 +775,7 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
}
void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::OnError(
const std::string& resource_name, grpc_error_handle error) {
const std::string& resource_name, absl::Status status) {
RefCountedPtr<ListenerWatcher> listener_watcher;
{
MutexLock lock(&mu_);
@ -787,11 +784,11 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::OnError(
if (--rds_resources_yet_to_fetch_ == 0) {
listener_watcher = std::move(listener_watcher_);
}
state.rds_update = grpc_error_to_absl_status(error);
state.rds_update = status;
} else {
// Prefer existing good version over current errored version
if (!state.rds_update->ok()) {
state.rds_update = grpc_error_to_absl_status(error);
state.rds_update = status;
}
}
}
@ -800,7 +797,6 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::OnError(
if (listener_watcher != nullptr) {
listener_watcher->PendingFilterChainMatchManagerReady(this);
}
GRPC_ERROR_UNREF(error);
}
void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
@ -1259,15 +1255,13 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
}
void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
DynamicXdsServerConfigSelectorProvider::OnError(grpc_error_handle error) {
DynamicXdsServerConfigSelectorProvider::OnError(absl::Status status) {
MutexLock lock(&mu_);
// Prefer existing good update.
if (resource_.ok()) {
GRPC_ERROR_UNREF(error);
return;
}
resource_ = grpc_error_to_absl_status(error);
GRPC_ERROR_UNREF(error);
resource_ = status;
if (watcher_ == nullptr) {
return;
}

Loading…
Cancel
Save