Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4282,6 +4282,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/cleanup",
"absl/log:check",
"absl/memory",
"absl/status",
"absl/status:statusor",
Expand Down
2 changes: 2 additions & 0 deletions src/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5034,6 +5034,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/cleanup",
"absl/functional:bind_front",
"absl/log:check",
"absl/memory",
"absl/random",
"absl/status",
Expand Down Expand Up @@ -5217,6 +5218,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
Expand Down
5 changes: 3 additions & 2 deletions src/core/ext/xds/xds_certificate_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <utility>

#include "absl/functional/bind_front.h"
#include "absl/log/check.h"
#include "absl/types/optional.h"

#include <grpc/support/log.h>
Expand Down Expand Up @@ -186,7 +187,7 @@ void XdsCertificateProvider::WatchStatusCallback(std::string cert_name,
}
} else if (!root_being_watched && root_cert_watcher_ != nullptr) {
// Cancel root cert watch.
GPR_ASSERT(root_cert_provider_ != nullptr);
CHECK(root_cert_provider_ != nullptr);
root_cert_provider_->distributor()->CancelTlsCertificatesWatch(
root_cert_watcher_);
root_cert_watcher_ = nullptr;
Expand All @@ -206,7 +207,7 @@ void XdsCertificateProvider::WatchStatusCallback(std::string cert_name,
std::move(watcher), absl::nullopt, identity_cert_name_);
}
} 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_watcher_);
identity_cert_watcher_ = nullptr;
Expand Down
21 changes: 11 additions & 10 deletions src/core/ext/xds/xds_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
Expand Down Expand Up @@ -472,7 +473,7 @@ XdsClient::XdsChannel::XdsChannel(WeakRefCountedPtr<XdsClient> xds_client,
self->OnConnectivityFailure(std::move(status));
},
&status);
GPR_ASSERT(transport_ != nullptr);
CHECK(transport_ != nullptr);
if (!status.ok()) SetChannelStatusLocked(std::move(status));
}

Expand Down Expand Up @@ -717,8 +718,8 @@ void XdsClient::XdsChannel::RetryableCall<T>::OnCallFinishedLocked() {
template <typename T>
void XdsClient::XdsChannel::RetryableCall<T>::StartNewCallLocked() {
if (shutting_down_) return;
GPR_ASSERT(xds_channel_->transport_ != nullptr);
GPR_ASSERT(call_ == nullptr);
CHECK(xds_channel_->transport_ != nullptr);
CHECK(call_ == nullptr);
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO,
"[xds_client %p] xds server %s: start new call from retryable "
Expand Down Expand Up @@ -1005,7 +1006,7 @@ XdsClient::XdsChannel::AdsCall::AdsCall(
GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace) ? "AdsCall"
: nullptr),
retryable_call_(std::move(retryable_call)) {
GPR_ASSERT(xds_client() != nullptr);
CHECK_NE(xds_client(), nullptr);
// Init the ADS call.
const char* method =
"/envoy.service.discovery.v3.AggregatedDiscoveryService/"
Expand All @@ -1015,7 +1016,7 @@ XdsClient::XdsChannel::AdsCall::AdsCall(
// Passing the initial ref here. This ref will go away when
// the StreamEventHandler is destroyed.
RefCountedPtr<AdsCall>(this)));
GPR_ASSERT(streaming_call_ != nullptr);
CHECK(streaming_call_ != nullptr);
// Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO,
Expand Down Expand Up @@ -1369,15 +1370,15 @@ XdsClient::XdsChannel::LrsCall::LrsCall(
// Init the LRS call. Note that the call will progress every time there's
// activity in xds_client()->interested_parties_, which is comprised of
// the polling entities from client_channel.
GPR_ASSERT(xds_client() != nullptr);
CHECK_NE(xds_client(), nullptr);
const char* method =
"/envoy.service.load_stats.v3.LoadReportingService/StreamLoadStats";
streaming_call_ = xds_channel()->transport_->CreateStreamingCall(
method, std::make_unique<StreamEventHandler>(
// Passing the initial ref here. This ref will go away when
// the StreamEventHandler is destroyed.
RefCountedPtr<LrsCall>(this)));
GPR_ASSERT(streaming_call_ != nullptr);
CHECK(streaming_call_ != nullptr);
// Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO,
Expand Down Expand Up @@ -1598,7 +1599,7 @@ XdsClient::XdsClient(
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
}
GPR_ASSERT(bootstrap_ != nullptr);
CHECK(bootstrap_ != nullptr);
if (bootstrap_->node() != nullptr) {
gpr_log(GPR_INFO, "[xds_client %p] xDS node ID: %s", this,
bootstrap_->node()->id().c_str());
Expand Down Expand Up @@ -1853,7 +1854,7 @@ void XdsClient::MaybeRegisterResourceTypeLocked(
const XdsResourceType* resource_type) {
auto it = resource_types_.find(resource_type->type_url());
if (it != resource_types_.end()) {
GPR_ASSERT(it->second == resource_type);
CHECK(it->second == resource_type);
return;
}
resource_types_.emplace(resource_type->type_url(), resource_type);
Expand Down Expand Up @@ -1904,7 +1905,7 @@ std::string XdsClient::ConstructFullXdsResourceName(
auto uri = URI::Create("xdstp", std::string(authority),
absl::StrCat("/", resource_type, "/", key.id),
key.query_params, /*fragment=*/"");
GPR_ASSERT(uri.ok());
CHECK(uri.ok());
return uri->ToString();
}
// Old-style name.
Expand Down
3 changes: 2 additions & 1 deletion src/core/ext/xds/xds_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <memory>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
Expand Down Expand Up @@ -476,7 +477,7 @@ absl::StatusOr<std::shared_ptr<const XdsClusterResource>> CdsResourceParse(
ValidationErrors::ScopedField field(&errors, ".cluster_type");
const auto* custom_cluster_type =
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");
const auto* typed_config =
envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
Expand Down
3 changes: 2 additions & 1 deletion src/core/ext/xds/xds_cluster_specifier_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <map>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/types/variant.h"
Expand Down Expand Up @@ -91,7 +92,7 @@ Json XdsRouteLookupClusterSpecifierPlugin::GenerateLoadBalancingPolicyConfig(
upb_JsonEncode(plugin_config, msg_type, symtab, 0,
reinterpret_cast<char*>(buf), json_size + 1, status.ptr());
auto json = JsonParse(reinterpret_cast<char*>(buf));
GPR_ASSERT(json.ok());
CHECK(json.ok());
return Json::FromArray({Json::FromObject(
{{"rls_experimental",
Json::FromObject({
Expand Down
3 changes: 2 additions & 1 deletion src/core/ext/xds/xds_endpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <set>
#include <vector>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
Expand Down Expand Up @@ -407,7 +408,7 @@ absl::StatusOr<std::shared_ptr<const XdsEndpointResource>> EdsResourceParse(
ValidationErrors::ScopedField field(&errors, absl::StrCat("[", i, "]"));
auto parsed_locality = LocalityParse(endpoints[i], &address_set, &errors);
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
// arrive in priority order.
if (eds_resource->priorities.size() < parsed_locality->priority + 1) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/ext/xds/xds_http_filters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <utility>
#include <vector>

#include "absl/log/check.h"
#include "absl/types/variant.h"
#include "envoy/extensions/filters/http/router/v3/router.upb.h"
#include "envoy/extensions/filters/http/router/v3/router.upbdefs.h"
Expand Down Expand Up @@ -91,11 +92,10 @@ XdsHttpFilterRegistry::XdsHttpFilterRegistry(bool register_builtins) {

void XdsHttpFilterRegistry::RegisterFilter(
std::unique_ptr<XdsHttpFilterImpl> filter) {
GPR_ASSERT(
registry_map_.emplace(filter->ConfigProtoName(), filter.get()).second);
CHECK(registry_map_.emplace(filter->ConfigProtoName(), filter.get()).second);
auto override_proto_name = filter->OverrideConfigProtoName();
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));
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/ext/xds/xds_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <set>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
Expand Down Expand Up @@ -873,8 +874,8 @@ void AddFilterChainDataForSourceType(
const FilterChain& filter_chain,
InternalFilterChainMap::DestinationIp* destination_ip,
ValidationErrors* errors) {
GPR_ASSERT(static_cast<unsigned int>(
filter_chain.filter_chain_match.source_type) < 3);
CHECK(static_cast<unsigned int>(filter_chain.filter_chain_match.source_type) <
3u);
AddFilterChainDataForSourceIpRange(
filter_chain,
&destination_ip->source_types_array[static_cast<int>(
Expand Down
15 changes: 8 additions & 7 deletions src/core/ext/xds/xds_route_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <utility>
#include <vector>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
Expand Down Expand Up @@ -464,7 +465,7 @@ absl::optional<StringMatcher> RoutePathMatchParse(
} else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
envoy_config_route_v3_RouteMatch_safe_regex(match);
GPR_ASSERT(regex_matcher != nullptr);
CHECK_NE(regex_matcher, nullptr);
type = StringMatcher::Type::kSafeRegex;
match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
Expand Down Expand Up @@ -492,7 +493,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
ValidationErrors::ScopedField field(errors,
absl::StrCat(".headers[", i, "]"));
const envoy_config_route_v3_HeaderMatcher* header = headers[i];
GPR_ASSERT(header != nullptr);
CHECK_NE(header, nullptr);
const std::string name =
UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
HeaderMatcher::Type type;
Expand Down Expand Up @@ -521,15 +522,15 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
header)) {
const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
GPR_ASSERT(regex_matcher != nullptr);
CHECK_NE(regex_matcher, nullptr);
type = HeaderMatcher::Type::kSafeRegex;
match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
} else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) {
type = HeaderMatcher::Type::kRange;
const envoy_type_v3_Int64Range* range_matcher =
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_end = envoy_type_v3_Int64Range_end(range_matcher);
} else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
Expand All @@ -539,7 +540,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
ValidationErrors::ScopedField field(errors, ".string_match");
const auto* matcher =
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)) {
type = HeaderMatcher::Type::kExact;
match_string = UpbStringToStdString(
Expand All @@ -560,7 +561,7 @@ void RouteHeaderMatchersParse(const envoy_config_route_v3_RouteMatch* match,
type = HeaderMatcher::Type::kSafeRegex;
const auto* regex_matcher =
envoy_type_matcher_v3_StringMatcher_safe_regex(matcher);
GPR_ASSERT(regex_matcher != nullptr);
CHECK_NE(regex_matcher, nullptr);
match_string = UpbStringToStdString(
envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
} else {
Expand Down Expand Up @@ -886,7 +887,7 @@ absl::optional<XdsRouteConfigResource::Route::RouteAction> RouteActionParse(
ValidationErrors::ScopedField field(errors, ".weighted_clusters");
const envoy_config_route_v3_WeightedCluster* weighted_clusters_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>
action_weighted_clusters;
uint64_t total_weight = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/core/ext/xds/xds_routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <cctype>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
Expand Down Expand Up @@ -117,7 +118,7 @@ absl::optional<size_t> XdsRouting::FindVirtualHostForDomain(
// than current match.
const MatchType match_type = DomainPatternMatchType(domain_pattern);
// 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 &&
domain_pattern.size() <= longest_match) {
Expand Down Expand Up @@ -235,7 +236,7 @@ XdsRouting::GeneratePerHTTPFilterConfigs(
const XdsHttpFilterImpl* filter_impl =
http_filter_registry.GetFilterForType(
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
// xDS filter, then it won't need any config, so skip it.
if (filter_impl->channel_filter() == nullptr) continue;
Expand Down
13 changes: 7 additions & 6 deletions src/core/ext/xds/xds_server_config_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
Expand Down Expand Up @@ -405,7 +406,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> Watch(
std::unique_ptr<ServerConfigSelectorProvider::ServerConfigSelectorWatcher>
watcher) override {
GPR_ASSERT(watcher_ == nullptr);
CHECK(watcher_ == nullptr);
watcher_ = std::move(watcher);
if (!static_resource_.ok()) {
return static_resource_.status();
Expand Down Expand Up @@ -518,7 +519,7 @@ XdsServerConfigFetcher::XdsServerConfigFetcher(
RefCountedPtr<GrpcXdsClient> xds_client,
grpc_server_xds_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,
Expand Down Expand Up @@ -1102,7 +1103,7 @@ absl::StatusOr<ChannelArgs> XdsServerConfigFetcher::ListenerWatcher::
const XdsHttpFilterImpl* filter_impl =
http_filter_registry.GetFilterForType(
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
// an implementation.
if (filter_impl->channel_filter() != nullptr) {
Expand Down Expand Up @@ -1151,7 +1152,7 @@ absl::StatusOr<ChannelArgs> XdsServerConfigFetcher::ListenerWatcher::
return result.status();
}
xds_certificate_provider = std::move(*result);
GPR_ASSERT(xds_certificate_provider != nullptr);
CHECK(xds_certificate_provider != nullptr);
args = args.SetObject(xds_certificate_provider);
}
return args;
Expand Down Expand Up @@ -1269,7 +1270,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
resource_name_(std::move(resource_name)),
http_filters_(std::move(http_filters)),
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
// deadlocks from invoking XdsRouteConfigResourceType::StartWatch whilst in a
// critical region.
Expand All @@ -1296,7 +1297,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
absl::StatusOr<std::shared_ptr<const XdsRouteConfigResource>> resource;
{
MutexLock lock(&mu_);
GPR_ASSERT(watcher_ == nullptr);
CHECK(watcher_ == nullptr);
watcher_ = std::move(watcher);
resource = resource_;
}
Expand Down