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

[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 #36483

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36483 from tanvi-jagtap:tjagtap_src_core_load_balancing 71fb35f867
PiperOrigin-RevId: 630318657
pull/36503/head^2
Tanvi Jagtap 10 months ago committed by Copybara-Service
parent 86ea68786b
commit 042019e3bf
  1. 2
      BUILD
  2. 16
      src/core/BUILD
  3. 7
      src/core/load_balancing/child_policy_handler.cc
  4. 3
      src/core/load_balancing/endpoint_list.cc
  5. 47
      src/core/load_balancing/grpclb/grpclb.cc
  6. 3
      src/core/load_balancing/health_check_client.cc
  7. 3
      src/core/load_balancing/lb_policy_registry.cc
  8. 3
      src/core/load_balancing/oob_backend_metric.cc
  9. 3
      src/core/load_balancing/outlier_detection/outlier_detection.cc
  10. 49
      src/core/load_balancing/pick_first/pick_first.cc
  11. 7
      src/core/load_balancing/priority/priority.cc
  12. 9
      src/core/load_balancing/ring_hash/ring_hash.cc
  13. 23
      src/core/load_balancing/rls/rls.cc
  14. 17
      src/core/load_balancing/round_robin/round_robin.cc
  15. 5
      src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc
  16. 17
      src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc
  17. 9
      src/core/load_balancing/weighted_target/weighted_target.cc
  18. 14
      src/core/load_balancing/xds/cds.cc
  19. 5
      src/core/load_balancing/xds/xds_cluster_impl.cc
  20. 7
      src/core/load_balancing/xds/xds_override_host.cc

@ -3563,6 +3563,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/strings",
"@com_google_protobuf//upb:base",
@ -3604,6 +3605,7 @@ grpc_cc_library(
"//src/core:load_balancing/child_policy_handler.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/strings",
],

@ -3476,6 +3476,7 @@ grpc_cc_library(
srcs = ["load_balancing/lb_policy_registry.cc"],
hdrs = ["load_balancing/lb_policy_registry.h"],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4805,6 +4806,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/container:inlined_vector",
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4921,6 +4923,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/hash",
"absl/log:check",
"absl/random",
"absl/status",
"absl/status:statusor",
@ -5316,6 +5319,7 @@ grpc_cc_library(
"load_balancing/xds/cds.cc",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -5375,6 +5379,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -5536,6 +5541,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -5582,6 +5588,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/types:optional",
@ -5618,6 +5625,7 @@ grpc_cc_library(
],
external_deps = [
"absl/algorithm:container",
"absl/log:check",
"absl/random",
"absl/status",
"absl/status:statusor",
@ -5738,6 +5746,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/container:inlined_vector",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -5787,6 +5796,7 @@ grpc_cc_library(
"load_balancing/round_robin/round_robin.cc",
],
external_deps = [
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -5824,6 +5834,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
"absl/types:optional",
"absl/types:span",
],
@ -5838,6 +5849,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -5907,6 +5919,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -5955,6 +5968,7 @@ grpc_cc_library(
"load_balancing/priority/priority.cc",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -6002,6 +6016,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -6050,6 +6065,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",

@ -19,6 +19,7 @@
#include <memory>
#include <string>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
@ -114,12 +115,12 @@ class ChildPolicyHandler::Helper final
private:
bool CalledByPendingChild() const {
GPR_ASSERT(child_ != nullptr);
CHECK_NE(child_, nullptr);
return child_ == parent()->pending_child_policy_.get();
}
bool CalledByCurrentChild() const {
GPR_ASSERT(child_ != nullptr);
CHECK_NE(child_, nullptr);
return child_ == parent()->child_policy_.get();
};
@ -240,7 +241,7 @@ absl::Status ChildPolicyHandler::UpdateLocked(UpdateArgs args) {
? pending_child_policy_.get()
: child_policy_.get();
}
GPR_ASSERT(policy_to_update != nullptr);
CHECK_NE(policy_to_update, nullptr);
// Update the policy.
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
gpr_log(GPR_INFO, "[child_policy_handler %p] updating %schild policy %p",

@ -22,6 +22,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
@ -117,7 +118,7 @@ absl::Status EndpointList::Endpoint::Init(
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
Json::FromArray(
{Json::FromObject({{"pick_first", Json::FromObject({})}})}));
GPR_ASSERT(config.ok());
CHECK(config.ok());
// Update child policy.
LoadBalancingPolicy::UpdateArgs update_args;
update_args.addresses = std::make_shared<SingleEndpointIterator>(addresses);

@ -72,6 +72,7 @@
#include "absl/container/inlined_vector.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -884,8 +885,8 @@ GrpcLb::BalancerCallState::BalancerCallState(
GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace) ? "BalancerCallState"
: nullptr),
grpclb_policy_(std::move(parent_grpclb_policy)) {
GPR_ASSERT(grpclb_policy_ != nullptr);
GPR_ASSERT(!grpclb_policy()->shutting_down_);
CHECK(grpclb_policy_ != nullptr);
CHECK(!grpclb_policy()->shutting_down_);
// Init the LB call. Note that the LB call will progress every time there's
// activity in grpclb_policy_->interested_parties(), which is comprised of
// the polling entities from client_channel.
@ -922,7 +923,7 @@ GrpcLb::BalancerCallState::BalancerCallState(
}
GrpcLb::BalancerCallState::~BalancerCallState() {
GPR_ASSERT(lb_call_ != nullptr);
CHECK_NE(lb_call_, nullptr);
grpc_call_unref(lb_call_);
grpc_metadata_array_destroy(&lb_initial_metadata_recv_);
grpc_metadata_array_destroy(&lb_trailing_metadata_recv_);
@ -932,7 +933,7 @@ GrpcLb::BalancerCallState::~BalancerCallState() {
}
void GrpcLb::BalancerCallState::Orphan() {
GPR_ASSERT(lb_call_ != nullptr);
CHECK_NE(lb_call_, nullptr);
// If we are here because grpclb_policy wants to cancel the call,
// lb_on_balancer_status_received_ will complete the cancellation and clean
// up. Otherwise, we are here because grpclb_policy has to orphan a failed
@ -949,7 +950,7 @@ void GrpcLb::BalancerCallState::Orphan() {
}
void GrpcLb::BalancerCallState::StartQuery() {
GPR_ASSERT(lb_call_ != nullptr);
CHECK_NE(lb_call_, nullptr);
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO, "[grpclb %p] lb_calld=%p: Starting LB call %p",
grpclb_policy_.get(), this, lb_call_);
@ -967,7 +968,7 @@ void GrpcLb::BalancerCallState::StartQuery() {
op->reserved = nullptr;
op++;
// Op: send request message.
GPR_ASSERT(send_message_payload_ != nullptr);
CHECK_NE(send_message_payload_, nullptr);
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = send_message_payload_;
op->flags = 0;
@ -981,7 +982,7 @@ void GrpcLb::BalancerCallState::StartQuery() {
call_error = grpc_call_start_batch_and_execute(lb_call_, ops,
static_cast<size_t>(op - ops),
&lb_on_initial_request_sent_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
CHECK_EQ(call_error, GRPC_CALL_OK);
// Op: recv initial metadata.
op = ops;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
@ -1004,7 +1005,7 @@ void GrpcLb::BalancerCallState::StartQuery() {
call_error = grpc_call_start_batch_and_execute(
lb_call_, ops, static_cast<size_t>(op - ops),
&lb_on_balancer_message_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
CHECK_EQ(call_error, GRPC_CALL_OK);
// Op: recv server status.
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@ -1021,7 +1022,7 @@ void GrpcLb::BalancerCallState::StartQuery() {
call_error = grpc_call_start_batch_and_execute(
lb_call_, ops, static_cast<size_t>(op - ops),
&lb_on_balancer_status_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
CHECK_EQ(call_error, GRPC_CALL_OK);
}
void GrpcLb::BalancerCallState::ScheduleNextClientLoadReportLocked() {
@ -1053,7 +1054,7 @@ void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked() {
void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
// Construct message payload.
GPR_ASSERT(send_message_payload_ == nullptr);
CHECK_EQ(send_message_payload_, nullptr);
// Get snapshot of stats.
int64_t num_calls_started;
int64_t num_calls_finished;
@ -1097,7 +1098,7 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
gpr_log(GPR_ERROR,
"[grpclb %p] lb_calld=%p call_error=%d sending client load report",
grpclb_policy_.get(), this, call_error);
GPR_ASSERT(GRPC_CALL_OK == call_error);
CHECK_EQ(call_error, GRPC_CALL_OK);
}
}
@ -1197,7 +1198,7 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked() {
break;
}
case response.SERVERLIST: {
GPR_ASSERT(lb_call_ != nullptr);
CHECK_NE(lb_call_, nullptr);
auto serverlist_wrapper =
MakeRefCounted<Serverlist>(std::move(response.serverlist));
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
@ -1302,7 +1303,7 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked() {
// Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery().
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
lb_call_, &op, 1, &lb_on_balancer_message_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
CHECK_EQ(call_error, GRPC_CALL_OK);
} else {
Unref(DEBUG_LOCATION, "on_message_received+grpclb_shutdown");
}
@ -1318,7 +1319,7 @@ void GrpcLb::BalancerCallState::OnBalancerStatusReceived(
void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
grpc_error_handle error) {
GPR_ASSERT(lb_call_ != nullptr);
CHECK_NE(lb_call_, nullptr);
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
char* status_details = grpc_slice_to_c_string(lb_call_status_details_);
gpr_log(GPR_INFO,
@ -1337,7 +1338,7 @@ void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
// case.
grpclb_policy()->lb_calld_.reset();
if (grpclb_policy()->fallback_at_startup_checks_pending_) {
GPR_ASSERT(!seen_serverlist_);
CHECK(!seen_serverlist_);
gpr_log(GPR_INFO,
"[grpclb %p] Balancer call finished without receiving "
"serverlist; entering fallback mode",
@ -1352,7 +1353,7 @@ void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
// This handles the fallback-after-startup case.
grpclb_policy()->MaybeEnterFallbackModeAfterStartup();
}
GPR_ASSERT(!grpclb_policy()->shutting_down_);
CHECK(!grpclb_policy()->shutting_down_);
grpclb_policy()->channel_control_helper()->RequestReresolution();
if (seen_initial_response_) {
// If we lose connection to the LB server, reset the backoff and restart
@ -1508,7 +1509,7 @@ void GrpcLb::ShutdownLocked() {
if (lb_channel_ != nullptr) {
if (parent_channelz_node_ != nullptr) {
channelz::ChannelNode* child_channelz_node = lb_channel_->channelz_node();
GPR_ASSERT(child_channelz_node != nullptr);
CHECK_NE(child_channelz_node, nullptr);
parent_channelz_node_->RemoveChildChannel(child_channelz_node->uuid());
}
lb_channel_.reset();
@ -1560,7 +1561,7 @@ absl::Status GrpcLb::UpdateLocked(UpdateArgs args) {
}
const bool is_initial_update = lb_channel_ == nullptr;
config_ = args.config.TakeAsSubclass<GrpcLbConfig>();
GPR_ASSERT(config_ != nullptr);
CHECK(config_ != nullptr);
args_ = std::move(args.args);
// Update fallback address list.
if (!args.addresses.ok()) {
@ -1634,7 +1635,7 @@ absl::Status GrpcLb::UpdateBalancerChannelLocked() {
lb_channel_.reset(Channel::FromC(
grpc_channel_create(uri_str.c_str(), channel_credentials.get(),
lb_channel_args.ToC().get())));
GPR_ASSERT(lb_channel_ != nullptr);
CHECK(lb_channel_ != nullptr);
// Set up channelz linkage.
channelz::ChannelNode* child_channelz_node = lb_channel_->channelz_node();
auto parent_channelz_node = args_.GetObjectRef<channelz::ChannelNode>();
@ -1664,10 +1665,10 @@ void GrpcLb::CancelBalancerChannelConnectivityWatchLocked() {
//
void GrpcLb::StartBalancerCallLocked() {
GPR_ASSERT(lb_channel_ != nullptr);
CHECK(lb_channel_ != nullptr);
if (shutting_down_) return;
// Init the LB call data.
GPR_ASSERT(lb_calld_ == nullptr);
CHECK(lb_calld_ == nullptr);
lb_calld_ = MakeOrphanable<BalancerCallState>(Ref());
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO,
@ -1826,7 +1827,7 @@ void GrpcLb::CreateOrUpdateChildPolicyLocked() {
}
update_args.args =
CreateChildPolicyArgsLocked(is_backend_from_grpclb_load_balancer);
GPR_ASSERT(update_args.args != ChannelArgs());
CHECK(update_args.args != ChannelArgs());
update_args.config = config_->child_policy();
// Create child policy if needed.
if (child_policy_ == nullptr) {
@ -1856,7 +1857,7 @@ void GrpcLb::CacheDeletedSubchannelLocked(
}
void GrpcLb::StartSubchannelCacheTimerLocked() {
GPR_ASSERT(!cached_subchannels_.empty());
CHECK(!cached_subchannels_.empty());
subchannel_cache_timer_handle_ =
channel_control_helper()->GetEventEngine()->RunAfter(
cached_subchannels_.begin()->first - Timestamp::Now(),

@ -24,6 +24,7 @@
#include <type_traits>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -132,7 +133,7 @@ void HealthProducer::HealthChecker::OnConnectivityStateChangeLocked(
state_ = GRPC_CHANNEL_CONNECTING;
status_ = absl::OkStatus();
} else {
GPR_ASSERT(state_ == GRPC_CHANNEL_CONNECTING);
CHECK(state_ == GRPC_CHANNEL_CONNECTING);
}
// Start the health watch stream.
StartHealthStreamLocked();

@ -22,6 +22,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -44,7 +45,7 @@ void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
std::unique_ptr<LoadBalancingPolicyFactory> factory) {
gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"",
std::string(factory->name()).c_str());
GPR_ASSERT(factories_.find(factory->name()) == factories_.end());
CHECK(factories_.find(factory->name()) == factories_.end());
factories_.emplace(factory->name(), std::move(factory));
}

@ -23,6 +23,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/duration.upb.h"
@ -224,7 +225,7 @@ void OrcaProducer::Orphaned() {
MutexLock lock(&mu_);
stream_client_.reset();
}
GPR_ASSERT(subchannel_ != nullptr); // Should not be called before Start().
CHECK(subchannel_ != nullptr); // Should not be called before Start().
subchannel_->CancelConnectivityStateWatch(connectivity_watcher_);
subchannel_->RemoveDataProducer(this);
}

@ -31,6 +31,7 @@
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -333,7 +334,7 @@ class OutlierDetectionLb final : public LoadBalancingPolicy {
--multiplier_;
}
} else {
GPR_ASSERT(ejection_time_.has_value());
CHECK(ejection_time_.has_value());
auto change_time = ejection_time_.value() +
Duration::Milliseconds(std::min(
base_ejection_time_in_millis * multiplier_,

@ -27,6 +27,7 @@
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/log/check.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -424,7 +425,7 @@ PickFirst::~PickFirst() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
gpr_log(GPR_INFO, "Destroying Pick First %p", this);
}
GPR_ASSERT(subchannel_list_ == nullptr);
CHECK(subchannel_list_ == nullptr);
}
void PickFirst::ShutdownLocked() {
@ -698,7 +699,7 @@ void PickFirst::SubchannelList::SubchannelData::SubchannelState::Select() {
gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", pick_first_.get(),
subchannel_.get());
}
GPR_ASSERT(subchannel_data_ != nullptr);
CHECK_NE(subchannel_data_, nullptr);
pick_first_->UnsetSelectedSubchannel(); // Cancel health watch, if any.
pick_first_->selected_ = std::move(subchannel_data_->subchannel_state_);
// If health checking is enabled, start the health watch, but don't
@ -766,7 +767,7 @@ void PickFirst::SubchannelList::SubchannelData::SubchannelState::
return;
}
// We aren't trying to connect, so we must be the selected subchannel.
GPR_ASSERT(pick_first_->selected_.get() == this);
CHECK(pick_first_->selected_.get() == this);
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
gpr_log(GPR_INFO,
"Pick First %p selected subchannel connectivity changed to %s",
@ -822,12 +823,12 @@ void PickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange(
}
if (subchannel_list_->shutting_down_) return;
// The notification must be for a subchannel in the current list.
GPR_ASSERT(subchannel_list_ == p->subchannel_list_.get());
CHECK(subchannel_list_ == p->subchannel_list_.get());
// SHUTDOWN should never happen.
GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(new_state != GRPC_CHANNEL_SHUTDOWN);
// READY should be caught by SubchannelState, in which case it will
// not call us in the first place.
GPR_ASSERT(new_state != GRPC_CHANNEL_READY);
CHECK(new_state != GRPC_CHANNEL_READY);
// Update state.
absl::optional<grpc_connectivity_state> old_state = connectivity_state_;
connectivity_state_ = new_state;
@ -949,11 +950,11 @@ void PickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange(
}
void PickFirst::SubchannelList::SubchannelData::RequestConnectionWithTimer() {
GPR_ASSERT(connectivity_state_.has_value());
CHECK(connectivity_state_.has_value());
if (connectivity_state_ == GRPC_CHANNEL_IDLE) {
subchannel_state_->RequestConnection();
} else {
GPR_ASSERT(connectivity_state_ == GRPC_CHANNEL_CONNECTING);
CHECK(connectivity_state_ == GRPC_CHANNEL_CONNECTING);
}
// If this is not the last subchannel in the list, start the timer.
if (index_ != subchannel_list_->size() - 1) {
@ -1016,7 +1017,7 @@ PickFirst::SubchannelList::SubchannelList(RefCountedPtr<PickFirst> policy,
if (addresses == nullptr) return;
// Create a subchannel for each address.
addresses->ForEach([&](const EndpointAddresses& address) {
GPR_ASSERT(address.addresses().size() == 1);
CHECK_EQ(address.addresses().size(), 1u);
RefCountedPtr<SubchannelInterface> subchannel =
policy_->channel_control_helper()->CreateSubchannel(
address.address(), address.args(), args_);
@ -1053,7 +1054,7 @@ void PickFirst::SubchannelList::Orphan() {
gpr_log(GPR_INFO, "[PF %p] Shutting down subchannel_list %p", policy_.get(),
this);
}
GPR_ASSERT(!shutting_down_);
CHECK(!shutting_down_);
shutting_down_ = true;
// Cancel Happy Eyeballs timer, if any.
if (timer_handle_.has_value()) {
@ -1074,7 +1075,7 @@ void PickFirst::SubchannelList::StartConnectingNextSubchannel() {
// large recursion that could overflow the stack.
for (; attempting_index_ < size(); ++attempting_index_) {
SubchannelData* sc = subchannels_[attempting_index_].get();
GPR_ASSERT(sc->connectivity_state().has_value());
CHECK(sc->connectivity_state().has_value());
if (sc->connectivity_state() != GRPC_CHANNEL_TRANSIENT_FAILURE) {
// Found a subchannel not in TRANSIENT_FAILURE, so trigger a
// connection attempt.
@ -1398,8 +1399,8 @@ OldPickFirst::~OldPickFirst() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
gpr_log(GPR_INFO, "Destroying Pick First %p", this);
}
GPR_ASSERT(subchannel_list_ == nullptr);
GPR_ASSERT(latest_pending_subchannel_list_ == nullptr);
CHECK(subchannel_list_ == nullptr);
CHECK(latest_pending_subchannel_list_ == nullptr);
}
void OldPickFirst::ShutdownLocked() {
@ -1667,15 +1668,15 @@ void OldPickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange(
->GetStatsPluginGroup();
// The notification must be for a subchannel in either the current or
// latest pending subchannel lists.
GPR_ASSERT(subchannel_list_ == p->subchannel_list_.get() ||
subchannel_list_ == p->latest_pending_subchannel_list_.get());
GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(subchannel_list_ == p->subchannel_list_.get() ||
subchannel_list_ == p->latest_pending_subchannel_list_.get());
CHECK(new_state != GRPC_CHANNEL_SHUTDOWN);
absl::optional<grpc_connectivity_state> old_state = connectivity_state_;
connectivity_state_ = new_state;
connectivity_status_ = std::move(status);
// Handle updates for the currently selected subchannel.
if (p->selected_ == this) {
GPR_ASSERT(subchannel_list_ == p->subchannel_list_.get());
CHECK(subchannel_list_ == p->subchannel_list_.get());
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
gpr_log(GPR_INFO,
"Pick First %p selected subchannel connectivity changed to %s", p,
@ -1850,11 +1851,11 @@ void OldPickFirst::SubchannelList::SubchannelData::OnConnectivityStateChange(
void OldPickFirst::SubchannelList::SubchannelData::
RequestConnectionWithTimer() {
GPR_ASSERT(connectivity_state_.has_value());
CHECK(connectivity_state_.has_value());
if (connectivity_state_ == GRPC_CHANNEL_IDLE) {
subchannel_->RequestConnection();
} else {
GPR_ASSERT(connectivity_state_ == GRPC_CHANNEL_CONNECTING);
CHECK(connectivity_state_ == GRPC_CHANNEL_CONNECTING);
}
// If this is not the last subchannel in the list, start the timer.
if (index_ != subchannel_list_->size() - 1) {
@ -1913,8 +1914,8 @@ void OldPickFirst::SubchannelList::SubchannelData::
// for a subchannel in p->latest_pending_subchannel_list_. The
// goal here is to find a subchannel from the update that we can
// select in place of the current one.
GPR_ASSERT(subchannel_list_ == p->subchannel_list_.get() ||
subchannel_list_ == p->latest_pending_subchannel_list_.get());
CHECK(subchannel_list_ == p->subchannel_list_.get() ||
subchannel_list_ == p->latest_pending_subchannel_list_.get());
// Case 2. Promote p->latest_pending_subchannel_list_ to p->subchannel_list_.
if (subchannel_list_ == p->latest_pending_subchannel_list_.get()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
@ -1981,7 +1982,7 @@ OldPickFirst::SubchannelList::SubchannelList(
if (addresses == nullptr) return;
// Create a subchannel for each address.
addresses->ForEach([&](const EndpointAddresses& address) {
GPR_ASSERT(address.addresses().size() == 1);
CHECK_EQ(address.addresses().size(), 1u);
RefCountedPtr<SubchannelInterface> subchannel =
policy_->channel_control_helper()->CreateSubchannel(
address.address(), address.args(), args_);
@ -2017,7 +2018,7 @@ void OldPickFirst::SubchannelList::Orphan() {
gpr_log(GPR_INFO, "[PF %p] Shutting down subchannel_list %p", policy_.get(),
this);
}
GPR_ASSERT(!shutting_down_);
CHECK(!shutting_down_);
shutting_down_ = true;
for (auto& sd : subchannels_) {
sd.ShutdownLocked();
@ -2040,7 +2041,7 @@ void OldPickFirst::SubchannelList::StartConnectingNextSubchannel() {
// large recursion that could overflow the stack.
for (; attempting_index_ < size(); ++attempting_index_) {
SubchannelData* sc = &subchannels_[attempting_index_];
GPR_ASSERT(sc->connectivity_state().has_value());
CHECK(sc->connectivity_state().has_value());
if (sc->connectivity_state() != GRPC_CHANNEL_TRANSIENT_FAILURE) {
// Found a subchannel not in TRANSIENT_FAILURE, so trigger a
// connection attempt.

@ -25,6 +25,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"
@ -414,7 +415,7 @@ void PriorityLb::ChoosePriorityLocked() {
RefAsSubclass<PriorityLb>(DEBUG_LOCATION, "ChildPriority"),
child_name);
auto child_config = config_->children().find(child_name);
GPR_DEBUG_ASSERT(child_config != config_->children().end());
DCHECK(child_config != config_->children().end());
// If the child policy returns a non-OK status, request re-resolution.
// Note that this will initially cause fixed backoff delay in the
// resolver instead of exponential delay. However, once the
@ -469,7 +470,7 @@ void PriorityLb::ChoosePriorityLocked() {
priority, child_name.c_str());
}
auto& child = children_[child_name];
GPR_ASSERT(child != nullptr);
CHECK(child != nullptr);
if (child->connectivity_state() == GRPC_CHANNEL_CONNECTING) {
SetCurrentPriorityLocked(priority, /*deactivate_lower_priorities=*/false,
"CONNECTING (pass 2)");
@ -501,7 +502,7 @@ void PriorityLb::SetCurrentPriorityLocked(int32_t priority,
}
}
auto& child = children_[config_->priorities()[priority]];
GPR_ASSERT(child != nullptr);
CHECK(child != nullptr);
channel_control_helper()->UpdateState(child->connectivity_state(),
child->connectivity_status(),
child->GetPicker());

@ -29,6 +29,7 @@
#include "absl/base/attributes.h"
#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -517,7 +518,7 @@ void RingHash::RingHashEndpoint::RequestConnectionLocked() {
}
void RingHash::RingHashEndpoint::CreateChildPolicy() {
GPR_ASSERT(child_policy_ == nullptr);
CHECK(child_policy_ == nullptr);
LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.work_serializer = ring_hash_->work_serializer();
lb_policy_args.args =
@ -560,7 +561,7 @@ absl::Status RingHash::RingHashEndpoint::UpdateChildPolicyLocked() {
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
Json::FromArray(
{Json::FromObject({{"pick_first", Json::FromObject({})}})}));
GPR_ASSERT(config.ok());
CHECK(config.ok());
// Update child policy.
LoadBalancingPolicy::UpdateArgs update_args;
update_args.addresses =
@ -834,7 +835,7 @@ void RingHash::UpdateAggregatedConnectivityStateLocked(
for (size_t i = 0; i < endpoints_.size(); ++i) {
auto it =
endpoint_map_.find(EndpointAddressSet(endpoints_[i].addresses()));
GPR_ASSERT(it != endpoint_map_.end());
CHECK(it != endpoint_map_.end());
if (it->second->connectivity_state() == GRPC_CHANNEL_CONNECTING) {
first_idle_index = endpoints_.size();
break;
@ -847,7 +848,7 @@ void RingHash::UpdateAggregatedConnectivityStateLocked(
if (first_idle_index != endpoints_.size()) {
auto it = endpoint_map_.find(
EndpointAddressSet(endpoints_[first_idle_index].addresses()));
GPR_ASSERT(it != endpoint_map_.end());
CHECK(it != endpoint_map_.end());
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_ring_hash_trace)) {
gpr_log(GPR_INFO,
"[RH %p] triggering internal connection attempt for endpoint "

@ -41,6 +41,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -860,7 +861,7 @@ void RlsLb::ChildPolicyWrapper::StartUpdate() {
auto child_policy_config = InsertOrUpdateChildPolicyField(
lb_policy_->config_->child_policy_config_target_field_name(), target_,
lb_policy_->config_->child_policy_config(), &errors);
GPR_ASSERT(child_policy_config.has_value());
CHECK(child_policy_config.has_value());
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log(
GPR_INFO,
@ -950,7 +951,7 @@ void RlsLb::ChildPolicyWrapper::ChildPolicyHelper::UpdateState(
return;
}
wrapper_->connectivity_state_ = state;
GPR_DEBUG_ASSERT(picker != nullptr);
DCHECK(picker != nullptr);
if (picker != nullptr) {
wrapper_->picker_ = std::move(picker);
}
@ -973,7 +974,7 @@ std::map<std::string, std::string> BuildKeyMap(
if (it == key_builder_map.end()) {
// Didn't find exact match, try method wildcard.
last_slash_pos = path.rfind('/');
GPR_DEBUG_ASSERT(last_slash_pos != path.npos);
DCHECK(last_slash_pos != path.npos);
if (GPR_UNLIKELY(last_slash_pos == path.npos)) return {};
std::string service(path.substr(0, last_slash_pos + 1));
it = key_builder_map.find(service);
@ -1007,7 +1008,7 @@ std::map<std::string, std::string> BuildKeyMap(
if (!key_builder->service_key.empty()) {
if (last_slash_pos == path.npos) {
last_slash_pos = path.rfind('/');
GPR_DEBUG_ASSERT(last_slash_pos != path.npos);
DCHECK(last_slash_pos != path.npos);
if (GPR_UNLIKELY(last_slash_pos == path.npos)) return {};
}
key_map[key_builder->service_key] =
@ -1017,7 +1018,7 @@ std::map<std::string, std::string> BuildKeyMap(
if (!key_builder->method_key.empty()) {
if (last_slash_pos == path.npos) {
last_slash_pos = path.rfind('/');
GPR_DEBUG_ASSERT(last_slash_pos != path.npos);
DCHECK(last_slash_pos != path.npos);
if (GPR_UNLIKELY(last_slash_pos == path.npos)) return {};
}
key_map[key_builder->method_key] =
@ -1221,7 +1222,7 @@ void RlsLb::Cache::Entry::Orphan() {
size_t RlsLb::Cache::Entry::Size() const {
// lru_iterator_ is not valid once we're shut down.
GPR_ASSERT(!is_shutdown_);
CHECK(!is_shutdown_);
return lb_policy_->cache_.EntrySizeForKey(*lru_iterator_);
}
@ -1507,7 +1508,7 @@ void RlsLb::Cache::MaybeShrinkSize(size_t bytes) {
auto lru_it = lru_list_.begin();
if (GPR_UNLIKELY(lru_it == lru_list_.end())) break;
auto map_it = map_.find(*lru_it);
GPR_ASSERT(map_it != map_.end());
CHECK(map_it != map_.end());
if (!map_it->second->CanEvict()) break;
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log(GPR_INFO, "[rlslb %p] LRU eviction: removing entry %p %s",
@ -1662,7 +1663,7 @@ void RlsLb::RlsChannel::Orphan() {
// Remove channelz linkage.
if (parent_channelz_node_ != nullptr) {
channelz::ChannelNode* child_channelz_node = channel_->channelz_node();
GPR_ASSERT(child_channelz_node != nullptr);
CHECK_NE(child_channelz_node, nullptr);
parent_channelz_node_->RemoveChildChannel(child_channelz_node->uuid());
}
// Stop connectivity watch.
@ -1698,7 +1699,7 @@ void RlsLb::RlsChannel::ReportResponseLocked(bool response_succeeded) {
}
void RlsLb::RlsChannel::ResetBackoff() {
GPR_DEBUG_ASSERT(channel_ != nullptr);
DCHECK(channel_ != nullptr);
channel_->ResetConnectionBackoff();
}
@ -1732,7 +1733,7 @@ RlsLb::RlsRequest::RlsRequest(RefCountedPtr<RlsLb> lb_policy, RequestKey key,
absl::OkStatus());
}
RlsLb::RlsRequest::~RlsRequest() { GPR_ASSERT(call_ == nullptr); }
RlsLb::RlsRequest::~RlsRequest() { CHECK_EQ(call_, nullptr); }
void RlsLb::RlsRequest::Orphan() {
if (call_ != nullptr) {
@ -1795,7 +1796,7 @@ void RlsLb::RlsRequest::StartCallLocked() {
Ref(DEBUG_LOCATION, "OnRlsCallComplete").release();
auto call_error = grpc_call_start_batch_and_execute(
call_, ops, static_cast<size_t>(op - ops), &call_complete_cb_);
GPR_ASSERT(call_error == GRPC_CALL_OK);
CHECK_EQ(call_error, GRPC_CALL_OK);
}
void RlsLb::RlsRequest::OnRlsCallComplete(void* arg, grpc_error_handle error) {

@ -24,6 +24,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"
@ -219,8 +220,8 @@ RoundRobin::~RoundRobin() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) {
gpr_log(GPR_INFO, "[RR %p] Destroying Round Robin policy", this);
}
GPR_ASSERT(endpoint_list_ == nullptr);
GPR_ASSERT(latest_pending_endpoint_list_ == nullptr);
CHECK(endpoint_list_ == nullptr);
CHECK(latest_pending_endpoint_list_ == nullptr);
}
void RoundRobin::ShutdownLocked() {
@ -338,20 +339,20 @@ void RoundRobin::RoundRobinEndpointList::UpdateStateCountersLocked(
// We treat IDLE the same as CONNECTING, since it will immediately
// transition into that state anyway.
if (old_state.has_value()) {
GPR_ASSERT(*old_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(*old_state != GRPC_CHANNEL_SHUTDOWN);
if (*old_state == GRPC_CHANNEL_READY) {
GPR_ASSERT(num_ready_ > 0);
CHECK_GT(num_ready_, 0u);
--num_ready_;
} else if (*old_state == GRPC_CHANNEL_CONNECTING ||
*old_state == GRPC_CHANNEL_IDLE) {
GPR_ASSERT(num_connecting_ > 0);
CHECK_GT(num_connecting_, 0u);
--num_connecting_;
} else if (*old_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
GPR_ASSERT(num_transient_failure_ > 0);
CHECK_GT(num_transient_failure_, 0u);
--num_transient_failure_;
}
}
GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(new_state != GRPC_CHANNEL_SHUTDOWN);
if (new_state == GRPC_CHANNEL_READY) {
++num_ready_;
} else if (new_state == GRPC_CHANNEL_CONNECTING ||
@ -408,7 +409,7 @@ void RoundRobin::RoundRobinEndpointList::
pickers.push_back(endpoint->picker());
}
}
GPR_ASSERT(!pickers.empty());
CHECK(!pickers.empty());
round_robin->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY, absl::OkStatus(),
MakeRefCounted<Picker>(round_robin, std::move(pickers)));

@ -23,6 +23,7 @@
#include <vector>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -146,7 +147,7 @@ absl::optional<StaticStrideScheduler> StaticStrideScheduler::Make(
}
}
GPR_ASSERT(weights.size() == float_weights.size());
CHECK(weights.size() == float_weights.size());
return StaticStrideScheduler{std::move(weights),
std::move(next_sequence_func)};
}
@ -156,7 +157,7 @@ StaticStrideScheduler::StaticStrideScheduler(
absl::AnyInvocable<uint32_t()> next_sequence_func)
: next_sequence_func_(std::move(next_sequence_func)),
weights_(std::move(weights)) {
GPR_ASSERT(next_sequence_func_ != nullptr);
CHECK(next_sequence_func_ != nullptr);
}
size_t StaticStrideScheduler::Pick() const {

@ -28,6 +28,7 @@
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -571,7 +572,7 @@ void WeightedRoundRobin::Picker::Orphaned() {
WeightedRoundRobin::PickResult WeightedRoundRobin::Picker::Pick(PickArgs args) {
size_t index = PickIndex();
GPR_ASSERT(index < endpoints_.size());
CHECK(index < endpoints_.size());
auto& endpoint_info = endpoints_[index];
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
gpr_log(GPR_INFO,
@ -705,8 +706,8 @@ WeightedRoundRobin::~WeightedRoundRobin() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace)) {
gpr_log(GPR_INFO, "[WRR %p] Destroying Round Robin policy", this);
}
GPR_ASSERT(endpoint_list_ == nullptr);
GPR_ASSERT(latest_pending_endpoint_list_ == nullptr);
CHECK(endpoint_list_ == nullptr);
CHECK(latest_pending_endpoint_list_ == nullptr);
}
void WeightedRoundRobin::ShutdownLocked() {
@ -913,20 +914,20 @@ void WeightedRoundRobin::WrrEndpointList::UpdateStateCountersLocked(
// We treat IDLE the same as CONNECTING, since it will immediately
// transition into that state anyway.
if (old_state.has_value()) {
GPR_ASSERT(*old_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(*old_state != GRPC_CHANNEL_SHUTDOWN);
if (*old_state == GRPC_CHANNEL_READY) {
GPR_ASSERT(num_ready_ > 0);
CHECK_GT(num_ready_, 0u);
--num_ready_;
} else if (*old_state == GRPC_CHANNEL_CONNECTING ||
*old_state == GRPC_CHANNEL_IDLE) {
GPR_ASSERT(num_connecting_ > 0);
CHECK_GT(num_connecting_, 0u);
--num_connecting_;
} else if (*old_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
GPR_ASSERT(num_transient_failure_ > 0);
CHECK_GT(num_transient_failure_, 0u);
--num_transient_failure_;
}
}
GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN);
CHECK(new_state != GRPC_CHANNEL_SHUTDOWN);
if (new_state == GRPC_CHANNEL_READY) {
++num_ready_;
} else if (new_state == GRPC_CHANNEL_CONNECTING ||

@ -27,6 +27,7 @@
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -274,7 +275,7 @@ WeightedTargetLb::PickResult WeightedTargetLb::WeightedPicker::Pick(
}
}
if (index == 0) index = start_index;
GPR_ASSERT(pickers_[index].first > key);
CHECK(pickers_[index].first > key);
// Delegate to the child picker.
return pickers_[index].second->Pick(args);
}
@ -420,7 +421,7 @@ void WeightedTargetLb::UpdateStateLocked() {
}
switch (child->connectivity_state()) {
case GRPC_CHANNEL_READY: {
GPR_ASSERT(child->weight() > 0);
CHECK_GT(child->weight(), 0u);
ready_end += child->weight();
ready_picker_list.emplace_back(ready_end, std::move(child_picker));
break;
@ -434,7 +435,7 @@ void WeightedTargetLb::UpdateStateLocked() {
break;
}
case GRPC_CHANNEL_TRANSIENT_FAILURE: {
GPR_ASSERT(child->weight() > 0);
CHECK_GT(child->weight(), 0u);
tf_end += child->weight();
tf_picker_list.emplace_back(tf_end, std::move(child_picker));
break;
@ -513,7 +514,7 @@ void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::Orphan() {
}
void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::OnTimerLocked() {
GPR_ASSERT(timer_handle_.has_value());
CHECK(timer_handle_.has_value());
timer_handle_.reset();
weighted_child_->weighted_target_policy_->targets_.erase(
weighted_child_->name_);

@ -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"
@ -285,13 +286,13 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
gpr_log(GPR_INFO, "[cdslb %p] received update: cluster=%s is_dynamic=%d",
this, new_config->cluster().c_str(), new_config->is_dynamic());
}
GPR_ASSERT(new_config != nullptr);
CHECK(new_config != nullptr);
// Cluster name should never change, because we should use a different
// child name in xds_cluster_manager in that case.
if (cluster_name_.empty()) {
cluster_name_ = new_config->cluster();
} else {
GPR_ASSERT(cluster_name_ == new_config->cluster());
CHECK(cluster_name_ == new_config->cluster());
}
// Start dynamic subscription if needed.
if (new_config->is_dynamic() && subscription_ == nullptr) {
@ -347,7 +348,7 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
ReportTransientFailure(new_cluster_config.status());
return new_cluster_config.status();
}
GPR_ASSERT(new_cluster_config->cluster != nullptr);
CHECK_NE(new_cluster_config->cluster, nullptr);
// Find old cluster, if any.
const XdsConfig::ClusterConfig* old_cluster_config = nullptr;
if (xds_config_ != nullptr) {
@ -387,7 +388,7 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
ReportTransientFailure(aggregate_cluster_config.status());
return aggregate_cluster_config.status();
}
GPR_ASSERT(aggregate_cluster_config->cluster != nullptr);
CHECK_NE(aggregate_cluster_config->cluster, nullptr);
aggregate_cluster_resource = aggregate_cluster_config->cluster.get();
}
} else {
@ -469,9 +470,8 @@ CdsLb::ChildNameState CdsLb::ComputeChildNames(
const XdsConfig::ClusterConfig* old_cluster,
const XdsConfig::ClusterConfig& new_cluster,
const XdsConfig::ClusterConfig::EndpointConfig& endpoint_config) const {
GPR_ASSERT(
!absl::holds_alternative<XdsConfig::ClusterConfig::AggregateConfig>(
new_cluster.children));
CHECK(!absl::holds_alternative<XdsConfig::ClusterConfig::AggregateConfig>(
new_cluster.children));
// First, build some maps from locality to child number and the reverse
// from old_cluster and child_name_state_.
std::map<XdsLocalityName*, size_t /*child_number*/, XdsLocalityName::Less>

@ -25,6 +25,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/str_cat.h"
@ -328,7 +329,7 @@ class XdsClusterImplLb::Picker::SubchannelCallTracker final
locality_stats_.reset(DEBUG_LOCATION, "SubchannelCallTracker");
call_counter_.reset(DEBUG_LOCATION, "SubchannelCallTracker");
#ifndef NDEBUG
GPR_DEBUG_ASSERT(!started_);
DCHECK(!started_);
#endif
}
@ -553,7 +554,7 @@ absl::Status XdsClusterImplLb::UpdateLocked(UpdateArgs args) {
// different priority child name if that happens, which means that this
// policy instance will get replaced instead of being updated.
if (config_ != nullptr) {
GPR_ASSERT(config_->cluster_name() == new_config->cluster_name());
CHECK(config_->cluster_name() == new_config->cluster_name());
}
// Get xDS config.
auto new_xds_config = args.args.GetObjectRef<XdsConfig>();

@ -31,6 +31,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -228,7 +229,7 @@ class XdsOverrideHostLb final : public LoadBalancingPolicy {
// already has an owned subchannel.
void SetOwnedSubchannel(RefCountedPtr<SubchannelWrapper> subchannel)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsOverrideHostLb::mu_) {
GPR_DEBUG_ASSERT(!HasOwnedSubchannel());
DCHECK(!HasOwnedSubchannel());
subchannel_ = std::move(subchannel);
}
@ -474,7 +475,7 @@ XdsOverrideHostLb::Picker::Picker(
absl::optional<LoadBalancingPolicy::PickResult>
XdsOverrideHostLb::Picker::PickOverridenHost(
XdsOverrideHostAttribute* override_host_attr) const {
GPR_ASSERT(override_host_attr != nullptr);
CHECK_NE(override_host_attr, nullptr);
auto cookie_address_list = override_host_attr->cookie_address_list();
if (cookie_address_list.empty()) return absl::nullopt;
// The cookie has an address list, so look through the addresses in order.
@ -994,7 +995,7 @@ void XdsOverrideHostLb::CreateSubchannelForAddress(absl::string_view address) {
std::string(address).c_str());
}
auto addr = StringToSockaddr(address);
GPR_ASSERT(addr.ok());
CHECK(addr.ok());
// Note: We don't currently have any cases where per_address_args need to
// be passed through. If we encounter any such cases in the future, we
// will need to change this to store those attributes from the resolver

Loading…
Cancel
Save