[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36459)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK.
These changes have been made using string replacement and regex.
Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced.
Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36459

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36459 from tanvi-jagtap:tjagtap_src_core_ext_xds 3705a1aabc
PiperOrigin-RevId: 629452815
pull/36485/head
Tanvi Jagtap 7 months ago committed by Copybara-Service
parent aa46d266c5
commit aeab2000a9
  1. 1
      BUILD
  2. 2
      src/core/BUILD
  3. 5
      src/core/ext/xds/xds_certificate_provider.cc
  4. 21
      src/core/ext/xds/xds_client.cc
  5. 3
      src/core/ext/xds/xds_cluster.cc
  6. 3
      src/core/ext/xds/xds_cluster_specifier_plugin.cc
  7. 3
      src/core/ext/xds/xds_endpoint.cc
  8. 6
      src/core/ext/xds/xds_http_filters.cc
  9. 5
      src/core/ext/xds/xds_listener.cc
  10. 15
      src/core/ext/xds/xds_route_config.cc
  11. 5
      src/core/ext/xds/xds_routing.cc
  12. 13
      src/core/ext/xds/xds_server_config_fetcher.cc
  13. 19
      src/core/ext/xds/xds_transport_grpc.cc

@ -4282,6 +4282,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/cleanup", "absl/cleanup",
"absl/log:check",
"absl/memory", "absl/memory",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",

@ -5034,6 +5034,7 @@ grpc_cc_library(
"absl/base:core_headers", "absl/base:core_headers",
"absl/cleanup", "absl/cleanup",
"absl/functional:bind_front", "absl/functional:bind_front",
"absl/log:check",
"absl/memory", "absl/memory",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -5217,6 +5218,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",

@ -21,6 +21,7 @@
#include <utility> #include <utility>
#include "absl/functional/bind_front.h" #include "absl/functional/bind_front.h"
#include "absl/log/check.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -186,7 +187,7 @@ void XdsCertificateProvider::WatchStatusCallback(std::string cert_name,
} }
} else if (!root_being_watched && root_cert_watcher_ != nullptr) { } else if (!root_being_watched && root_cert_watcher_ != nullptr) {
// Cancel root cert watch. // Cancel root cert watch.
GPR_ASSERT(root_cert_provider_ != nullptr); CHECK(root_cert_provider_ != nullptr);
root_cert_provider_->distributor()->CancelTlsCertificatesWatch( root_cert_provider_->distributor()->CancelTlsCertificatesWatch(
root_cert_watcher_); root_cert_watcher_);
root_cert_watcher_ = nullptr; root_cert_watcher_ = nullptr;
@ -206,7 +207,7 @@ void XdsCertificateProvider::WatchStatusCallback(std::string cert_name,
std::move(watcher), absl::nullopt, identity_cert_name_); std::move(watcher), absl::nullopt, identity_cert_name_);
} }
} else if (!identity_being_watched && identity_cert_watcher_ != nullptr) { } else if (!identity_being_watched && identity_cert_watcher_ != nullptr) {
GPR_ASSERT(identity_cert_provider_ != nullptr); CHECK(identity_cert_provider_ != nullptr);
identity_cert_provider_->distributor()->CancelTlsCertificatesWatch( identity_cert_provider_->distributor()->CancelTlsCertificatesWatch(
identity_cert_watcher_); identity_cert_watcher_);
identity_cert_watcher_ = nullptr; identity_cert_watcher_ = nullptr;

@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include "absl/cleanup/cleanup.h" #include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
@ -472,7 +473,7 @@ XdsClient::XdsChannel::XdsChannel(WeakRefCountedPtr<XdsClient> xds_client,
self->OnConnectivityFailure(std::move(status)); self->OnConnectivityFailure(std::move(status));
}, },
&status); &status);
GPR_ASSERT(transport_ != nullptr); CHECK(transport_ != nullptr);
if (!status.ok()) SetChannelStatusLocked(std::move(status)); if (!status.ok()) SetChannelStatusLocked(std::move(status));
} }
@ -717,8 +718,8 @@ void XdsClient::XdsChannel::RetryableCall<T>::OnCallFinishedLocked() {
template <typename T> template <typename T>
void XdsClient::XdsChannel::RetryableCall<T>::StartNewCallLocked() { void XdsClient::XdsChannel::RetryableCall<T>::StartNewCallLocked() {
if (shutting_down_) return; if (shutting_down_) return;
GPR_ASSERT(xds_channel_->transport_ != nullptr); CHECK(xds_channel_->transport_ != nullptr);
GPR_ASSERT(call_ == nullptr); CHECK(call_ == nullptr);
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[xds_client %p] xds server %s: start new call from retryable " "[xds_client %p] xds server %s: start new call from retryable "
@ -1005,7 +1006,7 @@ XdsClient::XdsChannel::AdsCall::AdsCall(
GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace) ? "AdsCall" GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace) ? "AdsCall"
: nullptr), : nullptr),
retryable_call_(std::move(retryable_call)) { retryable_call_(std::move(retryable_call)) {
GPR_ASSERT(xds_client() != nullptr); CHECK_NE(xds_client(), nullptr);
// Init the ADS call. // Init the ADS call.
const char* method = const char* method =
"/envoy.service.discovery.v3.AggregatedDiscoveryService/" "/envoy.service.discovery.v3.AggregatedDiscoveryService/"
@ -1015,7 +1016,7 @@ XdsClient::XdsChannel::AdsCall::AdsCall(
// Passing the initial ref here. This ref will go away when // Passing the initial ref here. This ref will go away when
// the StreamEventHandler is destroyed. // the StreamEventHandler is destroyed.
RefCountedPtr<AdsCall>(this))); RefCountedPtr<AdsCall>(this)));
GPR_ASSERT(streaming_call_ != nullptr); CHECK(streaming_call_ != nullptr);
// Start the call. // Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -1369,7 +1370,7 @@ XdsClient::XdsChannel::LrsCall::LrsCall(
// Init the LRS call. Note that the call will progress every time there's // Init the LRS call. Note that the call will progress every time there's
// activity in xds_client()->interested_parties_, which is comprised of // activity in xds_client()->interested_parties_, which is comprised of
// the polling entities from client_channel. // the polling entities from client_channel.
GPR_ASSERT(xds_client() != nullptr); CHECK_NE(xds_client(), nullptr);
const char* method = const char* method =
"/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats"; "/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats";
streaming_call_ = xds_channel()->transport_->CreateStreamingCall( streaming_call_ = xds_channel()->transport_->CreateStreamingCall(
@ -1377,7 +1378,7 @@ XdsClient::XdsChannel::LrsCall::LrsCall(
// Passing the initial ref here. This ref will go away when // Passing the initial ref here. This ref will go away when
// the StreamEventHandler is destroyed. // the StreamEventHandler is destroyed.
RefCountedPtr<LrsCall>(this))); RefCountedPtr<LrsCall>(this)));
GPR_ASSERT(streaming_call_ != nullptr); CHECK(streaming_call_ != nullptr);
// Start the call. // Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
@ -1598,7 +1599,7 @@ XdsClient::XdsClient(
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this); gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
} }
GPR_ASSERT(bootstrap_ != nullptr); CHECK(bootstrap_ != nullptr);
if (bootstrap_->node() != nullptr) { if (bootstrap_->node() != nullptr) {
gpr_log(GPR_INFO, "[xds_client %p] xDS node ID: %s", this, gpr_log(GPR_INFO, "[xds_client %p] xDS node ID: %s", this,
bootstrap_->node()->id().c_str()); bootstrap_->node()->id().c_str());
@ -1853,7 +1854,7 @@ void XdsClient::MaybeRegisterResourceTypeLocked(
const XdsResourceType* resource_type) { const XdsResourceType* resource_type) {
auto it = resource_types_.find(resource_type->type_url()); auto it = resource_types_.find(resource_type->type_url());
if (it != resource_types_.end()) { if (it != resource_types_.end()) {
GPR_ASSERT(it->second == resource_type); CHECK(it->second == resource_type);
return; return;
} }
resource_types_.emplace(resource_type->type_url(), resource_type); resource_types_.emplace(resource_type->type_url(), resource_type);
@ -1904,7 +1905,7 @@ std::string XdsClient::ConstructFullXdsResourceName(
auto uri = URI::Create("xdstp", std::string(authority), auto uri = URI::Create("xdstp", std::string(authority),
absl::StrCat("/", resource_type, "/", key.id), absl::StrCat("/", resource_type, "/", key.id),
key.query_params, /*fragment=*/""); key.query_params, /*fragment=*/"");
GPR_ASSERT(uri.ok()); CHECK(uri.ok());
return uri->ToString(); return uri->ToString();
} }
// Old-style name. // Old-style name.

@ -22,6 +22,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -476,7 +477,7 @@ absl::StatusOr<std::shared_ptr<const XdsClusterResource>> CdsResourceParse(
ValidationErrors::ScopedField field(&errors, ".cluster_type"); ValidationErrors::ScopedField field(&errors, ".cluster_type");
const auto* custom_cluster_type = const auto* custom_cluster_type =
envoy_config_cluster_v3_Cluster_cluster_type(cluster); envoy_config_cluster_v3_Cluster_cluster_type(cluster);
GPR_ASSERT(custom_cluster_type != nullptr); CHECK_NE(custom_cluster_type, nullptr);
ValidationErrors::ScopedField field2(&errors, ".typed_config"); ValidationErrors::ScopedField field2(&errors, ".typed_config");
const auto* typed_config = const auto* typed_config =
envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config( envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(

@ -21,6 +21,7 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/types/variant.h" #include "absl/types/variant.h"
@ -91,7 +92,7 @@ Json XdsRouteLookupClusterSpecifierPlugin::GenerateLoadBalancingPolicyConfig(
upb_JsonEncode(plugin_config, msg_type, symtab, 0, upb_JsonEncode(plugin_config, msg_type, symtab, 0,
reinterpret_cast<char*>(buf), json_size + 1, status.ptr()); reinterpret_cast<char*>(buf), json_size + 1, status.ptr());
auto json = JsonParse(reinterpret_cast<char*>(buf)); auto json = JsonParse(reinterpret_cast<char*>(buf));
GPR_ASSERT(json.ok()); CHECK(json.ok());
return Json::FromArray({Json::FromObject( return Json::FromArray({Json::FromObject(
{{"rls_experimental", {{"rls_experimental",
Json::FromObject({ Json::FromObject({

@ -25,6 +25,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -407,7 +408,7 @@ absl::StatusOr<std::shared_ptr<const XdsEndpointResource>> EdsResourceParse(
ValidationErrors::ScopedField field(&errors, absl::StrCat("[", i, "]")); ValidationErrors::ScopedField field(&errors, absl::StrCat("[", i, "]"));
auto parsed_locality = LocalityParse(endpoints[i], &address_set, &errors); auto parsed_locality = LocalityParse(endpoints[i], &address_set, &errors);
if (parsed_locality.has_value()) { if (parsed_locality.has_value()) {
GPR_ASSERT(parsed_locality->locality.lb_weight != 0); CHECK_NE(parsed_locality->locality.lb_weight, 0u);
// Make sure prorities is big enough. Note that they might not // Make sure prorities is big enough. Note that they might not
// arrive in priority order. // arrive in priority order.
if (eds_resource->priorities.size() < parsed_locality->priority + 1) { if (eds_resource->priorities.size() < parsed_locality->priority + 1) {

@ -20,6 +20,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/types/variant.h" #include "absl/types/variant.h"
#include "envoy/extensions/filters/http/router/v3/router.upb.h" #include "envoy/extensions/filters/http/router/v3/router.upb.h"
#include "envoy/extensions/filters/http/router/v3/router.upbdefs.h" #include "envoy/extensions/filters/http/router/v3/router.upbdefs.h"
@ -91,11 +92,10 @@ XdsHttpFilterRegistry::XdsHttpFilterRegistry(bool register_builtins) {
void XdsHttpFilterRegistry::RegisterFilter( void XdsHttpFilterRegistry::RegisterFilter(
std::unique_ptr<XdsHttpFilterImpl> filter) { std::unique_ptr<XdsHttpFilterImpl> filter) {
GPR_ASSERT( CHECK(registry_map_.emplace(filter->ConfigProtoName(), filter.get()).second);
registry_map_.emplace(filter->ConfigProtoName(), filter.get()).second);
auto override_proto_name = filter->OverrideConfigProtoName(); auto override_proto_name = filter->OverrideConfigProtoName();
if (!override_proto_name.empty()) { if (!override_proto_name.empty()) {
GPR_ASSERT(registry_map_.emplace(override_proto_name, filter.get()).second); CHECK(registry_map_.emplace(override_proto_name, filter.get()).second);
} }
owning_list_.push_back(std::move(filter)); owning_list_.push_back(std::move(filter));
} }

@ -21,6 +21,7 @@
#include <set> #include <set>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -873,8 +874,8 @@ void AddFilterChainDataForSourceType(
const FilterChain& filter_chain, const FilterChain& filter_chain,
InternalFilterChainMap::DestinationIp* destination_ip, InternalFilterChainMap::DestinationIp* destination_ip,
ValidationErrors* errors) { ValidationErrors* errors) {
GPR_ASSERT(static_cast<unsigned int>( CHECK(static_cast<unsigned int>(filter_chain.filter_chain_match.source_type) <
filter_chain.filter_chain_match.source_type) < 3); 3u);
AddFilterChainDataForSourceIpRange( AddFilterChainDataForSourceIpRange(
filter_chain, filter_chain,
&destination_ip->source_types_array[static_cast<int>( &destination_ip->source_types_array[static_cast<int>(

@ -27,6 +27,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -464,7 +465,7 @@ absl::optional<StringMatcher> RoutePathMatchParse(
} else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) { } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
const envoy_type_matcher_v3_RegexMatcher* regex_matcher = const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
envoy_config_route_v3_RouteMatch_safe_regex(match); envoy_config_route_v3_RouteMatch_safe_regex(match);
GPR_ASSERT(regex_matcher != nullptr); CHECK_NE(regex_matcher, nullptr);
type = StringMatcher::Type::kSafeRegex; type = StringMatcher::Type::kSafeRegex;
match_string = UpbStringToStdString( match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)); envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
@ -492,7 +493,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
ValidationErrors::ScopedField field(errors, ValidationErrors::ScopedField field(errors,
absl::StrCat(".headers[", i, "]")); absl::StrCat(".headers[", i, "]"));
const envoy_config_route_v3_HeaderMatcher* header = headers[i]; const envoy_config_route_v3_HeaderMatcher* header = headers[i];
GPR_ASSERT(header != nullptr); CHECK_NE(header, nullptr);
const std::string name = const std::string name =
UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header)); UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
HeaderMatcher::Type type; HeaderMatcher::Type type;
@ -521,7 +522,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
header)) { header)) {
const envoy_type_matcher_v3_RegexMatcher* regex_matcher = const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
envoy_config_route_v3_HeaderMatcher_safe_regex_match(header); envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
GPR_ASSERT(regex_matcher != nullptr); CHECK_NE(regex_matcher, nullptr);
type = HeaderMatcher::Type::kSafeRegex; type = HeaderMatcher::Type::kSafeRegex;
match_string = UpbStringToStdString( match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)); envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
@ -529,7 +530,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
type = HeaderMatcher::Type::kRange; type = HeaderMatcher::Type::kRange;
const envoy_type_v3_Int64Range* range_matcher = const envoy_type_v3_Int64Range* range_matcher =
envoy_config_route_v3_HeaderMatcher_range_match(header); envoy_config_route_v3_HeaderMatcher_range_match(header);
GPR_ASSERT(range_matcher != nullptr); CHECK_NE(range_matcher, nullptr);
range_start = envoy_type_v3_Int64Range_start(range_matcher); range_start = envoy_type_v3_Int64Range_start(range_matcher);
range_end = envoy_type_v3_Int64Range_end(range_matcher); range_end = envoy_type_v3_Int64Range_end(range_matcher);
} else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) { } else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
@ -539,7 +540,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
ValidationErrors::ScopedField field(errors, ".string_match"); ValidationErrors::ScopedField field(errors, ".string_match");
const auto* matcher = const auto* matcher =
envoy_config_route_v3_HeaderMatcher_string_match(header); envoy_config_route_v3_HeaderMatcher_string_match(header);
GPR_ASSERT(matcher != nullptr); CHECK_NE(matcher, nullptr);
if (envoy_type_matcher_v3_StringMatcher_has_exact(matcher)) { if (envoy_type_matcher_v3_StringMatcher_has_exact(matcher)) {
type = HeaderMatcher::Type::kExact; type = HeaderMatcher::Type::kExact;
match_string = UpbStringToStdString( match_string = UpbStringToStdString(
@ -560,7 +561,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
type = HeaderMatcher::Type::kSafeRegex; type = HeaderMatcher::Type::kSafeRegex;
const auto* regex_matcher = const auto* regex_matcher =
envoy_type_matcher_v3_StringMatcher_safe_regex(matcher); envoy_type_matcher_v3_StringMatcher_safe_regex(matcher);
GPR_ASSERT(regex_matcher != nullptr); CHECK_NE(regex_matcher, nullptr);
match_string = UpbStringToStdString( match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)); envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
} else { } else {
@ -886,7 +887,7 @@ absl::optional<XdsRouteConfigResource::Route::RouteAction> RouteActionParse(
ValidationErrors::ScopedField field(errors, ".weighted_clusters"); ValidationErrors::ScopedField field(errors, ".weighted_clusters");
const envoy_config_route_v3_WeightedCluster* weighted_clusters_proto = const envoy_config_route_v3_WeightedCluster* weighted_clusters_proto =
envoy_config_route_v3_RouteAction_weighted_clusters(route_action_proto); envoy_config_route_v3_RouteAction_weighted_clusters(route_action_proto);
GPR_ASSERT(weighted_clusters_proto != nullptr); CHECK_NE(weighted_clusters_proto, nullptr);
std::vector<XdsRouteConfigResource::Route::RouteAction::ClusterWeight> std::vector<XdsRouteConfigResource::Route::RouteAction::ClusterWeight>
action_weighted_clusters; action_weighted_clusters;
uint64_t total_weight = 0; uint64_t total_weight = 0;

@ -25,6 +25,7 @@
#include <cctype> #include <cctype>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -117,7 +118,7 @@ absl::optional<size_t> XdsRouting::FindVirtualHostForDomain(
// than current match. // than current match.
const MatchType match_type = DomainPatternMatchType(domain_pattern); const MatchType match_type = DomainPatternMatchType(domain_pattern);
// This should be caught by RouteConfigParse(). // This should be caught by RouteConfigParse().
GPR_ASSERT(match_type != INVALID_MATCH); CHECK(match_type != INVALID_MATCH);
if (match_type > best_match_type) continue; if (match_type > best_match_type) continue;
if (match_type == best_match_type && if (match_type == best_match_type &&
domain_pattern.size() <= longest_match) { domain_pattern.size() <= longest_match) {
@ -235,7 +236,7 @@ XdsRouting::GeneratePerHTTPFilterConfigs(
const XdsHttpFilterImpl* filter_impl = const XdsHttpFilterImpl* filter_impl =
http_filter_registry.GetFilterForType( http_filter_registry.GetFilterForType(
http_filter.config.config_proto_type_name); http_filter.config.config_proto_type_name);
GPR_ASSERT(filter_impl != nullptr); CHECK_NE(filter_impl, nullptr);
// If there is not actually any C-core filter associated with this // If there is not actually any C-core filter associated with this
// xDS filter, then it won't need any config, so skip it. // xDS filter, then it won't need any config, so skip it.
if (filter_impl->channel_filter() == nullptr) continue; if (filter_impl->channel_filter() == nullptr) continue;

@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -405,7 +406,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> Watch( absl::StatusOr<RefCountedPtr<ServerConfigSelector>> Watch(
std::unique_ptr<ServerConfigSelectorProvider::ServerConfigSelectorWatcher> std::unique_ptr<ServerConfigSelectorProvider::ServerConfigSelectorWatcher>
watcher) override { watcher) override {
GPR_ASSERT(watcher_ == nullptr); CHECK(watcher_ == nullptr);
watcher_ = std::move(watcher); watcher_ = std::move(watcher);
if (!static_resource_.ok()) { if (!static_resource_.ok()) {
return static_resource_.status(); return static_resource_.status();
@ -518,7 +519,7 @@ XdsServerConfigFetcher::XdsServerConfigFetcher(
RefCountedPtr<GrpcXdsClient> xds_client, RefCountedPtr<GrpcXdsClient> xds_client,
grpc_server_xds_status_notifier notifier) grpc_server_xds_status_notifier notifier)
: xds_client_(std::move(xds_client)), serving_status_notifier_(notifier) { : xds_client_(std::move(xds_client)), serving_status_notifier_(notifier) {
GPR_ASSERT(xds_client_ != nullptr); CHECK(xds_client_ != nullptr);
} }
std::string ListenerResourceName(absl::string_view resource_name_template, std::string ListenerResourceName(absl::string_view resource_name_template,
@ -1102,7 +1103,7 @@ absl::StatusOr<ChannelArgs> XdsServerConfigFetcher::ListenerWatcher::
const XdsHttpFilterImpl* filter_impl = const XdsHttpFilterImpl* filter_impl =
http_filter_registry.GetFilterForType( http_filter_registry.GetFilterForType(
http_filter.config.config_proto_type_name); http_filter.config.config_proto_type_name);
GPR_ASSERT(filter_impl != nullptr); CHECK_NE(filter_impl, nullptr);
// Some filters like the router filter are no-op filters and do not have // Some filters like the router filter are no-op filters and do not have
// an implementation. // an implementation.
if (filter_impl->channel_filter() != nullptr) { if (filter_impl->channel_filter() != nullptr) {
@ -1151,7 +1152,7 @@ absl::StatusOr<ChannelArgs> XdsServerConfigFetcher::ListenerWatcher::
return result.status(); return result.status();
} }
xds_certificate_provider = std::move(*result); xds_certificate_provider = std::move(*result);
GPR_ASSERT(xds_certificate_provider != nullptr); CHECK(xds_certificate_provider != nullptr);
args = args.SetObject(xds_certificate_provider); args = args.SetObject(xds_certificate_provider);
} }
return args; return args;
@ -1269,7 +1270,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
resource_name_(std::move(resource_name)), resource_name_(std::move(resource_name)),
http_filters_(std::move(http_filters)), http_filters_(std::move(http_filters)),
resource_(std::move(initial_resource)) { resource_(std::move(initial_resource)) {
GPR_ASSERT(!resource_name_.empty()); CHECK(!resource_name_.empty());
// RouteConfigWatcher is being created here instead of in Watch() to avoid // RouteConfigWatcher is being created here instead of in Watch() to avoid
// deadlocks from invoking XdsRouteConfigResourceType::StartWatch whilst in a // deadlocks from invoking XdsRouteConfigResourceType::StartWatch whilst in a
// critical region. // critical region.
@ -1296,7 +1297,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
absl::StatusOr<std::shared_ptr<const XdsRouteConfigResource>> resource; absl::StatusOr<std::shared_ptr<const XdsRouteConfigResource>> resource;
{ {
MutexLock lock(&mu_); MutexLock lock(&mu_);
GPR_ASSERT(watcher_ == nullptr); CHECK(watcher_ == nullptr);
watcher_ = std::move(watcher); watcher_ = std::move(watcher);
resource = resource_; resource = resource_;
} }

@ -23,6 +23,7 @@
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -78,7 +79,7 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
factory_->interested_parties(), Slice::FromStaticString(method), factory_->interested_parties(), Slice::FromStaticString(method),
/*authority=*/absl::nullopt, Timestamp::InfFuture(), /*authority=*/absl::nullopt, Timestamp::InfFuture(),
/*registered_method=*/true); /*registered_method=*/true);
GPR_ASSERT(call_ != nullptr); CHECK_NE(call_, nullptr);
// Init data associated with the call. // Init data associated with the call.
grpc_metadata_array_init(&initial_metadata_recv_); grpc_metadata_array_init(&initial_metadata_recv_);
grpc_metadata_array_init(&trailing_metadata_recv_); grpc_metadata_array_init(&trailing_metadata_recv_);
@ -108,7 +109,7 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
this->Ref(DEBUG_LOCATION, "OnRecvInitialMetadata").release(), nullptr); this->Ref(DEBUG_LOCATION, "OnRecvInitialMetadata").release(), nullptr);
call_error = grpc_call_start_batch_and_execute( call_error = grpc_call_start_batch_and_execute(
call_, ops, static_cast<size_t>(op - ops), &on_recv_initial_metadata_); call_, ops, static_cast<size_t>(op - ops), &on_recv_initial_metadata_);
GPR_ASSERT(GRPC_CALL_OK == call_error); CHECK_EQ(call_error, GRPC_CALL_OK);
// Start a batch for recv_trailing_metadata. // Start a batch for recv_trailing_metadata.
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
op = ops; op = ops;
@ -125,7 +126,7 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this, nullptr); GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this, nullptr);
call_error = grpc_call_start_batch_and_execute( call_error = grpc_call_start_batch_and_execute(
call_, ops, static_cast<size_t>(op - ops), &on_status_received_); call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error); CHECK_EQ(call_error, GRPC_CALL_OK);
GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this, nullptr); GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this, nullptr);
} }
@ -135,12 +136,12 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::
grpc_byte_buffer_destroy(send_message_payload_); grpc_byte_buffer_destroy(send_message_payload_);
grpc_byte_buffer_destroy(recv_message_payload_); grpc_byte_buffer_destroy(recv_message_payload_);
CSliceUnref(status_details_); CSliceUnref(status_details_);
GPR_ASSERT(call_ != nullptr); CHECK_NE(call_, nullptr);
grpc_call_unref(call_); grpc_call_unref(call_);
} }
void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::Orphan() { void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::Orphan() {
GPR_ASSERT(call_ != nullptr); CHECK_NE(call_, nullptr);
// If we are here because xds_client wants to cancel the call, // If we are here because xds_client wants to cancel the call,
// OnStatusReceived() will complete the cancellation and clean up. // OnStatusReceived() will complete the cancellation and clean up.
// Otherwise, we are here because xds_client has to orphan a failed call, // Otherwise, we are here because xds_client has to orphan a failed call,
@ -164,7 +165,7 @@ void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::SendMessage(
Ref(DEBUG_LOCATION, "OnRequestSent").release(); Ref(DEBUG_LOCATION, "OnRequestSent").release();
grpc_call_error call_error = grpc_call_error call_error =
grpc_call_start_batch_and_execute(call_, &op, 1, &on_request_sent_); grpc_call_start_batch_and_execute(call_, &op, 1, &on_request_sent_);
GPR_ASSERT(GRPC_CALL_OK == call_error); CHECK_EQ(call_error, GRPC_CALL_OK);
} }
void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall:: void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::
@ -174,10 +175,10 @@ void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::
memset(&op, 0, sizeof(op)); memset(&op, 0, sizeof(op));
op.op = GRPC_OP_RECV_MESSAGE; op.op = GRPC_OP_RECV_MESSAGE;
op.data.recv_message.recv_message = &recv_message_payload_; op.data.recv_message.recv_message = &recv_message_payload_;
GPR_ASSERT(call_ != nullptr); CHECK_NE(call_, nullptr);
const grpc_call_error call_error = const grpc_call_error call_error =
grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_); grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error); CHECK_EQ(call_error, GRPC_CALL_OK);
} }
void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall:: void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::
@ -271,7 +272,7 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcXdsTransport(
channel_ = CreateXdsChannel( channel_ = CreateXdsChannel(
factory->args_, factory->args_,
static_cast<const GrpcXdsBootstrap::GrpcXdsServer&>(server)); static_cast<const GrpcXdsBootstrap::GrpcXdsServer&>(server));
GPR_ASSERT(channel_ != nullptr); CHECK(channel_ != nullptr);
if (channel_->IsLame()) { if (channel_->IsLame()) {
*status = absl::UnavailableError("xds client has a lame channel"); *status = absl::UnavailableError("xds client has a lame channel");
} else { } else {

Loading…
Cancel
Save