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

[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.

Closes #36484

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36484 from tanvi-jagtap:tjagtap_src_core_resolver 1105178e8a
PiperOrigin-RevId: 630006323
pull/36483/head
Tanvi Jagtap 7 months ago committed by Copybara-Service
parent 9603942313
commit d02c17e246
  1. 5
      BUILD
  2. 5
      src/core/BUILD
  3. 3
      src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  4. 65
      src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  5. 19
      src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc
  6. 3
      src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc
  7. 5
      src/core/resolver/endpoint_addresses.cc
  8. 3
      src/core/resolver/fake/fake_resolver.cc
  9. 5
      src/core/resolver/google_c2p/google_c2p_resolver.cc
  10. 5
      src/core/resolver/polling_resolver.cc
  11. 7
      src/core/resolver/resolver_registry.cc
  12. 3
      src/core/resolver/xds/xds_dependency_manager.cc
  13. 13
      src/core/resolver/xds/xds_resolver.cc
  14. 3
      src/core/service_config/service_config_impl.h

@ -3427,6 +3427,7 @@ grpc_cc_library(
"//src/core:service_config/service_config_impl.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3462,6 +3463,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3503,6 +3505,7 @@ grpc_cc_library(
"//src/core:resolver/resolver_registry.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3765,6 +3768,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4375,6 +4379,7 @@ grpc_cc_library(
hdrs = ["//src/core:resolver/fake/fake_resolver.h"],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/strings",
"absl/time",
"absl/types:optional",

@ -6185,6 +6185,7 @@ grpc_cc_library(
"resolver/polling_resolver.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -6248,6 +6249,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/cleanup",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -6430,6 +6432,7 @@ grpc_cc_library(
external_deps = [
"absl/container:flat_hash_map",
"absl/container:flat_hash_set",
"absl/log:check",
"absl/strings",
],
language = "c++",
@ -6452,6 +6455,7 @@ grpc_cc_library(
"resolver/xds/xds_resolver.cc",
],
external_deps = [
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -6512,6 +6516,7 @@ grpc_cc_library(
"resolver/google_c2p/google_c2p_resolver.cc",
],
external_deps = [
"absl/log:check",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",

@ -36,6 +36,7 @@
#include <ares.h>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
@ -116,7 +117,7 @@ class GrpcPolledFdFactoryPosix final : public GrpcPolledFdFactory {
GrpcPolledFd* NewGrpcPolledFdLocked(
ares_socket_t as, grpc_pollset_set* driver_pollset_set) override {
auto insert_result = owned_fds_.insert(as);
GPR_ASSERT(insert_result.second);
CHECK(insert_result.second);
return new GrpcPolledFdPosix(as, driver_pollset_set);
}

@ -29,6 +29,7 @@
#include <ares.h>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/strings/str_format.h"
#include <grpc/support/alloc.h>
@ -136,8 +137,8 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
GetName(), shutdown_called_);
CSliceUnref(read_buf_);
CSliceUnref(write_buf_);
GPR_ASSERT(read_closure_ == nullptr);
GPR_ASSERT(write_closure_ == nullptr);
CHECK_EQ(read_closure_, nullptr);
CHECK_EQ(write_closure_, nullptr);
if (!shutdown_called_) {
// This can happen if the socket was never seen by grpc ares wrapper
// code, i.e. if we never started I/O polling on it.
@ -157,16 +158,16 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
}
void RegisterForOnReadableLocked(grpc_closure* read_closure) override {
GPR_ASSERT(read_closure_ == nullptr);
CHECK_EQ(read_closure_, nullptr);
read_closure_ = read_closure;
GPR_ASSERT(GRPC_SLICE_LENGTH(read_buf_) == 0);
CHECK_EQ(GRPC_SLICE_LENGTH(read_buf_), 0);
CSliceUnref(read_buf_);
GPR_ASSERT(!read_buf_has_data_);
CHECK(!read_buf_has_data_);
read_buf_ = GRPC_SLICE_MALLOC(4192);
if (connect_done_) {
ContinueRegisterForOnReadableLocked();
} else {
GPR_ASSERT(pending_continue_register_for_on_readable_locked_ == false);
CHECK(pending_continue_register_for_on_readable_locked_ == false);
pending_continue_register_for_on_readable_locked_ = true;
}
}
@ -176,7 +177,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
"fd:|%s| ContinueRegisterForOnReadableLocked "
"wsa_connect_error_:%d",
GetName(), wsa_connect_error_);
GPR_ASSERT(connect_done_);
CHECK(connect_done_);
if (wsa_connect_error_ != 0) {
ScheduleAndNullReadClosure(GRPC_WSA_ERROR(wsa_connect_error_, "connect"));
return;
@ -212,16 +213,16 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
GRPC_CARES_TRACE_LOG("fd:|%s| RegisterForOnWriteableLocked called",
GetName());
} else {
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
GRPC_CARES_TRACE_LOG(
"fd:|%s| RegisterForOnWriteableLocked called tcp_write_state_: %d "
"connect_done_: %d",
GetName(), tcp_write_state_, connect_done_);
}
GPR_ASSERT(write_closure_ == nullptr);
CHECK_EQ(write_closure_, nullptr);
write_closure_ = write_closure;
if (!connect_done_) {
GPR_ASSERT(!pending_continue_register_for_on_writeable_locked_);
CHECK(!pending_continue_register_for_on_writeable_locked_);
pending_continue_register_for_on_writeable_locked_ = true;
// Register an async OnTcpConnect callback here rather than when the
// connect was initiated, since we are now guaranteed to hold a ref of the
@ -237,7 +238,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
"fd:|%s| ContinueRegisterForOnWriteableLocked "
"wsa_connect_error_:%d",
GetName(), wsa_connect_error_);
GPR_ASSERT(connect_done_);
CHECK(connect_done_);
if (wsa_connect_error_ != 0) {
ScheduleAndNullWriteClosure(
GRPC_WSA_ERROR(wsa_connect_error_, "connect"));
@ -246,7 +247,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
if (socket_type_ == SOCK_DGRAM) {
ScheduleAndNullWriteClosure(absl::OkStatus());
} else {
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
int wsa_error_code = 0;
switch (tcp_write_state_) {
case WRITE_IDLE:
@ -272,7 +273,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
bool IsFdStillReadableLocked() override { return read_buf_has_data_; }
void ShutdownLocked(grpc_error_handle /* error */) override {
GPR_ASSERT(!shutdown_called_);
CHECK(!shutdown_called_);
shutdown_called_ = true;
on_shutdown_locked_();
grpc_winsocket_shutdown(winsocket_);
@ -308,7 +309,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
// c-ares overloads this recv_from virtual socket function to receive
// data on both UDP and TCP sockets, and from is nullptr for TCP.
if (from != nullptr) {
GPR_ASSERT(*from_len <= recv_from_source_addr_len_);
CHECK(*from_len <= recv_from_source_addr_len_);
memcpy(from, &recv_from_source_addr_, recv_from_source_addr_len_);
*from_len = recv_from_source_addr_len_;
}
@ -377,7 +378,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
// Therefore, the sendv handler for UDP sockets must only attempt
// to write everything inline.
GRPC_CARES_TRACE_LOG("fd:|%s| SendVUDP called", GetName());
GPR_ASSERT(GRPC_SLICE_LENGTH(write_buf_) == 0);
CHECK_EQ(GRPC_SLICE_LENGTH(write_buf_), 0);
CSliceUnref(write_buf_);
write_buf_ = FlattenIovec(iov, iov_count);
DWORD bytes_sent = 0;
@ -410,7 +411,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
switch (tcp_write_state_) {
case WRITE_IDLE:
tcp_write_state_ = WRITE_REQUESTED;
GPR_ASSERT(GRPC_SLICE_LENGTH(write_buf_) == 0);
CHECK_EQ(GRPC_SLICE_LENGTH(write_buf_), 0);
CSliceUnref(write_buf_);
write_buf_ = FlattenIovec(iov, iov_count);
wsa_error_ctx->SetWSAError(WSAEWOULDBLOCK);
@ -426,12 +427,12 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
// send again. If c-ares still needs to send even more data, we'll get
// to it eventually.
grpc_slice currently_attempted = FlattenIovec(iov, iov_count);
GPR_ASSERT(GRPC_SLICE_LENGTH(currently_attempted) >=
GRPC_SLICE_LENGTH(write_buf_));
CHECK(GRPC_SLICE_LENGTH(currently_attempted) >=
GRPC_SLICE_LENGTH(write_buf_));
ares_ssize_t total_sent = 0;
for (size_t i = 0; i < GRPC_SLICE_LENGTH(write_buf_); i++) {
GPR_ASSERT(GRPC_SLICE_START_PTR(currently_attempted)[i] ==
GRPC_SLICE_START_PTR(write_buf_)[i]);
CHECK(GRPC_SLICE_START_PTR(currently_attempted)[i] ==
GRPC_SLICE_START_PTR(write_buf_)[i]);
total_sent++;
}
CSliceUnref(currently_attempted);
@ -456,9 +457,9 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
GetName(), StatusToString(error).c_str(),
pending_continue_register_for_on_readable_locked_,
pending_continue_register_for_on_writeable_locked_);
GPR_ASSERT(!connect_done_);
CHECK(!connect_done_);
connect_done_ = true;
GPR_ASSERT(wsa_connect_error_ == 0);
CHECK_EQ(wsa_connect_error_, 0);
if (!error.ok() || shutdown_called_) {
wsa_connect_error_ = WSA_OPERATION_ABORTED;
} else {
@ -468,7 +469,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
WSAGetOverlappedResult(grpc_winsocket_wrapped_socket(winsocket_),
&winsocket_->write_info.overlapped,
&transferred_bytes, FALSE, &flags);
GPR_ASSERT(transferred_bytes == 0);
CHECK_EQ(transferred_bytes, 0);
if (!wsa_success) {
wsa_connect_error_ = WSAGetLastError();
char* msg = gpr_format_message(wsa_connect_error_);
@ -502,8 +503,8 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
int ConnectUDP(WSAErrorContext* wsa_error_ctx, const struct sockaddr* target,
ares_socklen_t target_len) {
GRPC_CARES_TRACE_LOG("fd:%s ConnectUDP", GetName());
GPR_ASSERT(!connect_done_);
GPR_ASSERT(wsa_connect_error_ == 0);
CHECK(!connect_done_);
CHECK_EQ(wsa_connect_error_, 0);
SOCKET s = grpc_winsocket_wrapped_socket(winsocket_);
int out =
WSAConnect(s, target, target_len, nullptr, nullptr, nullptr, nullptr);
@ -639,7 +640,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
void OnIocpWriteableLocked(grpc_error_handle error) {
GRPC_CARES_TRACE_LOG("OnIocpWriteableInner. fd:|%s|", GetName());
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
if (error.ok()) {
if (winsocket_->write_info.wsa_error != 0) {
error = GRPC_WSA_ERROR(winsocket_->write_info.wsa_error,
@ -651,7 +652,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
StatusToString(error).c_str());
}
}
GPR_ASSERT(tcp_write_state_ == WRITE_PENDING);
CHECK(tcp_write_state_ == WRITE_PENDING);
if (error.ok()) {
tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY;
write_buf_ = grpc_slice_sub_no_ref(
@ -710,7 +711,7 @@ class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory {
GrpcPolledFd* NewGrpcPolledFdLocked(
ares_socket_t as, grpc_pollset_set* /* driver_pollset_set */) override {
auto it = sockets_.find(as);
GPR_ASSERT(it != sockets_.end());
CHECK(it != sockets_.end());
return it->second;
}
@ -757,7 +758,7 @@ class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory {
GRPC_CARES_TRACE_LOG(
"fd:|%s| created with params af:%d type:%d protocol:%d",
polled_fd->GetName(), af, type, protocol);
GPR_ASSERT(self->sockets_.insert({s, polled_fd}).second);
CHECK(self->sockets_.insert({s, polled_fd}).second);
return s;
}
@ -767,7 +768,7 @@ class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->Connect(&wsa_error_ctx, target, target_len);
}
@ -777,7 +778,7 @@ class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->SendV(&wsa_error_ctx, iov, iovec_count);
}
@ -788,7 +789,7 @@ class GrpcPolledFdFactoryWindows final : public GrpcPolledFdFactory {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->RecvFrom(&wsa_error_ctx, data, data_len, flags, from,
from_len);
}

@ -46,6 +46,7 @@
#include <address_sorting/address_sorting.h>
#include <ares.h>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -204,7 +205,7 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver)
if (gpr_unref(&ev_driver->refs)) {
GRPC_CARES_TRACE_LOG("request:%p destroy ev_driver %p", ev_driver->request,
ev_driver);
GPR_ASSERT(ev_driver->fds == nullptr);
CHECK_EQ(ev_driver->fds, nullptr);
ares_destroy(ev_driver->channel);
grpc_ares_complete_request_locked(ev_driver->request);
delete ev_driver;
@ -215,9 +216,9 @@ static void fd_node_destroy_locked(fd_node* fdn)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&grpc_ares_request::mu) {
GRPC_CARES_TRACE_LOG("request:%p delete fd: %s", fdn->ev_driver->request,
fdn->grpc_polled_fd->GetName());
GPR_ASSERT(!fdn->readable_registered);
GPR_ASSERT(!fdn->writable_registered);
GPR_ASSERT(fdn->already_shutdown);
CHECK(!fdn->readable_registered);
CHECK(!fdn->writable_registered);
CHECK(fdn->already_shutdown);
delete fdn->grpc_polled_fd;
delete fdn;
}
@ -357,7 +358,7 @@ static void on_ares_backup_poll_alarm(void* arg, grpc_error_handle error) {
static void on_readable(void* arg, grpc_error_handle error) {
fd_node* fdn = static_cast<fd_node*>(arg);
grpc_core::MutexLock lock(&fdn->ev_driver->request->mu);
GPR_ASSERT(fdn->readable_registered);
CHECK(fdn->readable_registered);
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
const ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked();
fdn->readable_registered = false;
@ -381,7 +382,7 @@ static void on_readable(void* arg, grpc_error_handle error) {
static void on_writable(void* arg, grpc_error_handle error) {
fd_node* fdn = static_cast<fd_node*>(arg);
grpc_core::MutexLock lock(&fdn->ev_driver->request->mu);
GPR_ASSERT(fdn->writable_registered);
CHECK(fdn->writable_registered);
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
const ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked();
fdn->writable_registered = false;
@ -929,7 +930,7 @@ static bool inner_resolve_as_ip_literal_locked(
false /* log errors */) ||
grpc_parse_ipv6_hostport(hostport->c_str(), &addr,
false /* log errors */)) {
GPR_ASSERT(*addrs == nullptr);
CHECK(*addrs == nullptr);
*addrs = std::make_unique<EndpointAddressesList>();
(*addrs)->emplace_back(addr, grpc_core::ChannelArgs());
return true;
@ -987,7 +988,7 @@ static bool inner_maybe_resolve_localhost_manually_locked(
*port = default_port;
}
if (gpr_stricmp(host->c_str(), "localhost") == 0) {
GPR_ASSERT(*addrs == nullptr);
CHECK(*addrs == nullptr);
*addrs = std::make_unique<grpc_core::EndpointAddressesList>();
uint16_t numeric_port = grpc_strhtons(port->c_str());
grpc_resolved_address address;
@ -1184,7 +1185,7 @@ grpc_ares_request* (*grpc_dns_lookup_txt_ares)(
int query_timeout_ms) = grpc_dns_lookup_txt_ares_impl;
static void grpc_cancel_ares_request_impl(grpc_ares_request* r) {
GPR_ASSERT(r != nullptr);
CHECK_NE(r, nullptr);
grpc_core::MutexLock lock(&r->mu);
GRPC_CARES_TRACE_LOG("request:%p grpc_cancel_ares_request ev_driver:%p", r,
r->ev_driver);

@ -25,6 +25,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
@ -434,7 +435,7 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper::
// Make sure field destroys before cleanup.
ValidationErrors::ScopedField field(&errors_, "txt lookup");
if (orphaned_) return;
GPR_ASSERT(is_txt_inflight_);
CHECK(is_txt_inflight_);
is_txt_inflight_ = false;
if (!service_config.ok()) {
errors_.AddError(service_config.status().message());

@ -24,6 +24,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"
@ -47,7 +48,7 @@ EndpointAddresses::EndpointAddresses(const grpc_resolved_address& address,
EndpointAddresses::EndpointAddresses(
std::vector<grpc_resolved_address> addresses, const ChannelArgs& args)
: addresses_(std::move(addresses)), args_(args) {
GPR_ASSERT(!addresses_.empty());
CHECK(!addresses_.empty());
}
EndpointAddresses::EndpointAddresses(const EndpointAddresses& other)
@ -110,7 +111,7 @@ bool EndpointAddressSet::operator==(const EndpointAddressSet& other) const {
if (addresses_.size() != other.addresses_.size()) return false;
auto other_it = other.addresses_.begin();
for (auto it = addresses_.begin(); it != addresses_.end(); ++it) {
GPR_ASSERT(other_it != other.addresses_.end());
CHECK(other_it != other.addresses_.end());
if (it->len != other_it->len ||
memcmp(it->addr, other_it->addr, it->len) != 0) {
return false;

@ -23,6 +23,7 @@
#include <type_traits>
#include <utility>
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include <grpc/support/log.h>
@ -95,7 +96,7 @@ void FakeResolver::StartLocked() {
void FakeResolver::RequestReresolutionLocked() {
// Re-resolution can't happen until after we return an initial result.
GPR_ASSERT(response_generator_ != nullptr);
CHECK(response_generator_ != nullptr);
response_generator_->ReresolutionRequested();
}

@ -21,6 +21,7 @@
#include <type_traits>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
@ -122,7 +123,7 @@ GoogleCloud2ProdResolver::GoogleCloud2ProdResolver(ResolverArgs args)
CoreConfiguration::Get().resolver_registry().CreateResolver(
absl::StrCat("dns:", name_to_resolve), args.args, args.pollset_set,
work_serializer_, std::move(args.result_handler));
GPR_ASSERT(child_resolver_ != nullptr);
CHECK(child_resolver_ != nullptr);
return;
}
// Maybe override metadata server name for testing
@ -141,7 +142,7 @@ GoogleCloud2ProdResolver::GoogleCloud2ProdResolver(ResolverArgs args)
child_resolver_ = CoreConfiguration::Get().resolver_registry().CreateResolver(
xds_uri, args.args, args.pollset_set, work_serializer_,
std::move(args.result_handler));
GPR_ASSERT(child_resolver_ != nullptr);
CHECK(child_resolver_ != nullptr);
}
void GoogleCloud2ProdResolver::StartLocked() {

@ -23,6 +23,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"
@ -171,7 +172,7 @@ void PollingResolver::OnRequestCompleteLocked(Result result) {
: result.service_config.status().ToString().c_str(),
result.resolution_note.c_str());
}
GPR_ASSERT(result.result_health_callback == nullptr);
CHECK(result.result_health_callback == nullptr);
result.result_health_callback =
[self = RefAsSubclass<PollingResolver>(
DEBUG_LOCATION, "result_health_callback")](absl::Status status) {
@ -206,7 +207,7 @@ void PollingResolver::GetResultStatus(absl::Status status) {
ExecCtx::Get()->InvalidateNow();
const Timestamp next_try = backoff_.NextAttemptTime();
const Duration timeout = next_try - Timestamp::Now();
GPR_ASSERT(!next_resolution_timer_handle_.has_value());
CHECK(!next_resolution_timer_handle_.has_value());
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
if (timeout > Duration::Zero()) {
gpr_log(GPR_INFO, "[polling resolver %p] retrying in %" PRId64 " ms",

@ -16,6 +16,7 @@
#include "src/core/resolver/resolver_registry.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/ascii.h"
@ -50,9 +51,9 @@ bool IsLowerCase(absl::string_view str) {
void ResolverRegistry::Builder::RegisterResolverFactory(
std::unique_ptr<ResolverFactory> factory) {
GPR_ASSERT(IsLowerCase(factory->scheme()));
CHECK(IsLowerCase(factory->scheme()));
auto p = state_.factories.emplace(factory->scheme(), std::move(factory));
GPR_ASSERT(p.second);
CHECK(p.second);
}
bool ResolverRegistry::Builder::HasResolverFactory(
@ -130,7 +131,7 @@ ResolverFactory* ResolverRegistry::LookupResolverFactory(
// point to the parsed URI.
ResolverFactory* ResolverRegistry::FindResolverFactory(
absl::string_view target, URI* uri, std::string* canonical_target) const {
GPR_ASSERT(uri != nullptr);
CHECK_NE(uri, nullptr);
absl::StatusOr<URI> tmp_uri = URI::Parse(target);
ResolverFactory* factory =
tmp_uri.ok() ? LookupResolverFactory(tmp_uri->scheme()) : nullptr;

@ -18,6 +18,7 @@
#include <set>
#include "absl/log/check.h"
#include "absl/strings/str_join.h"
#include <grpc/support/port_platform.h>
@ -729,7 +730,7 @@ bool XdsDependencyManager::PopulateClusterConfigMap(
std::set<absl::string_view>* eds_resources_seen,
std::set<absl::string_view>* dns_names_seen,
absl::StatusOr<std::vector<absl::string_view>>* leaf_clusters) {
if (depth > 0) GPR_ASSERT(leaf_clusters != nullptr);
if (depth > 0) CHECK_NE(leaf_clusters, nullptr);
if (depth == kMaxXdsAggregateClusterRecursionDepth) {
*leaf_clusters =
absl::UnavailableError("aggregate cluster graph exceeds max depth");

@ -26,6 +26,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -638,7 +639,7 @@ XdsResolver::XdsConfigSelector::XdsConfigSelector(
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);
// Add C-core filter to list.
if (filter_impl->channel_filter() != nullptr) {
filters_.push_back(filter_impl->channel_filter());
@ -688,7 +689,7 @@ absl::optional<uint64_t> HeaderHashHelper(
absl::Status XdsResolver::XdsConfigSelector::GetCallConfig(
GetCallConfigArgs args) {
Slice* path = args.initial_metadata->get_pointer(HttpPathMetadata());
GPR_ASSERT(path != nullptr);
CHECK_NE(path, nullptr);
auto* entry = route_config_data_->GetRouteForRequest(path->as_string_view(),
args.initial_metadata);
if (entry == nullptr) {
@ -736,7 +737,7 @@ absl::Status XdsResolver::XdsConfigSelector::GetCallConfig(
}
}
if (index == 0) index = start_index;
GPR_ASSERT(entry->weighted_cluster_state[index].range_end > key);
CHECK(entry->weighted_cluster_state[index].range_end > key);
cluster_name = absl::StrCat(
"cluster:", entry->weighted_cluster_state[index].cluster);
method_config = entry->weighted_cluster_state[index].method_config;
@ -750,7 +751,7 @@ absl::Status XdsResolver::XdsConfigSelector::GetCallConfig(
method_config = entry->method_config;
});
auto cluster = route_config_data_->FindClusterRef(cluster_name);
GPR_ASSERT(cluster != nullptr);
CHECK(cluster != nullptr);
// Generate a hash.
absl::optional<uint64_t> hash;
for (const auto& hash_policy : route_action->hash_policies) {
@ -854,7 +855,7 @@ void XdsResolver::ClusterSelectionFilter::Call::OnClientInitialMetadata(
GetContext<grpc_call_context_element>()
[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA]
.value);
GPR_ASSERT(service_config_call_data != nullptr);
CHECK_NE(service_config_call_data, nullptr);
auto* route_state_attribute = static_cast<XdsRouteStateAttributeImpl*>(
service_config_call_data->GetCallAttribute<XdsRouteStateAttribute>());
auto* cluster_name_attribute =
@ -992,7 +993,7 @@ void XdsResolver::OnResourceDoesNotExist(std::string context) {
Result result;
result.addresses.emplace();
result.service_config = ServiceConfigImpl::Create(args_, "{}");
GPR_ASSERT(result.service_config.ok());
CHECK(result.service_config.ok());
result.resolution_note = std::move(context);
result.args = args_;
result_handler_->ReportResult(std::move(result));

@ -24,6 +24,7 @@
#include <unordered_map>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
@ -89,7 +90,7 @@ class ServiceConfigImpl final : public ServiceConfig {
/// ServiceConfig object.
ServiceConfigParser::ParsedConfig* GetGlobalParsedConfig(
size_t index) override {
GPR_DEBUG_ASSERT(index < parsed_global_configs_.size());
DCHECK(index < parsed_global_configs_.size());
return parsed_global_configs_[index].get();
}

Loading…
Cancel
Save