Merge branch 'master' into tjagtap_src_core_tsi

pull/36496/head
tanvi-jagtap 10 months ago
commit 4f9acc7739
  1. 19
      BUILD
  2. 26
      src/core/BUILD
  3. 3
      src/core/handshaker/security/secure_endpoint.cc
  4. 5
      src/core/handshaker/security/security_handshaker.cc
  5. 9
      src/core/lib/security/authorization/audit_logging.cc
  6. 4
      src/core/lib/security/authorization/grpc_authorization_engine.cc
  7. 11
      src/core/lib/security/authorization/grpc_authorization_policy_provider.cc
  8. 5
      src/core/lib/security/authorization/rbac_translator.cc
  9. 4
      src/core/lib/security/authorization/stdout_logger.cc
  10. 4
      src/core/lib/security/certificate_provider/certificate_provider_registry.cc
  11. 4
      src/core/lib/security/context/security_context.cc
  12. 21
      src/core/lib/security/security_connector/alts/alts_security_connector.cc
  13. 3
      src/core/lib/security/security_connector/fake/fake_security_connector.cc
  14. 6
      src/core/lib/security/security_connector/insecure/insecure_security_connector.cc
  15. 15
      src/core/lib/security/security_connector/local/local_security_connector.cc
  16. 10
      src/core/lib/security/security_connector/security_connector.cc
  17. 5
      src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
  18. 15
      src/core/lib/security/security_connector/ssl_utils.cc
  19. 21
      src/core/lib/security/security_connector/tls/tls_security_connector.cc
  20. 3
      src/core/lib/security/transport/server_auth_filter.cc
  21. 7
      src/core/load_balancing/child_policy_handler.cc
  22. 3
      src/core/load_balancing/endpoint_list.cc
  23. 47
      src/core/load_balancing/grpclb/grpclb.cc
  24. 3
      src/core/load_balancing/health_check_client.cc
  25. 3
      src/core/load_balancing/lb_policy_registry.cc
  26. 3
      src/core/load_balancing/oob_backend_metric.cc
  27. 3
      src/core/load_balancing/outlier_detection/outlier_detection.cc
  28. 49
      src/core/load_balancing/pick_first/pick_first.cc
  29. 7
      src/core/load_balancing/priority/priority.cc
  30. 9
      src/core/load_balancing/ring_hash/ring_hash.cc
  31. 23
      src/core/load_balancing/rls/rls.cc
  32. 17
      src/core/load_balancing/round_robin/round_robin.cc
  33. 5
      src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc
  34. 17
      src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc
  35. 9
      src/core/load_balancing/weighted_target/weighted_target.cc
  36. 14
      src/core/load_balancing/xds/cds.cc
  37. 5
      src/core/load_balancing/xds/xds_cluster_impl.cc
  38. 7
      src/core/load_balancing/xds/xds_override_host.cc
  39. 4
      src/cpp/client/call_credentials.cc
  40. 4
      src/cpp/client/channel_cc.cc
  41. 11
      src/cpp/client/client_context.cc
  42. 5
      src/cpp/client/secure_credentials.cc
  43. 6
      src/cpp/client/xds_credentials.cc
  44. 11
      src/cpp/common/alarm.cc
  45. 10
      src/cpp/common/channel_arguments.cc
  46. 7
      src/cpp/common/completion_queue_cc.cc
  47. 8
      src/cpp/common/tls_certificate_provider.cc
  48. 14
      src/cpp/common/tls_certificate_verifier.cc
  49. 14
      src/cpp/common/tls_credentials_options.cc
  50. 1
      src/cpp/ext/csm/BUILD
  51. 3
      src/cpp/ext/csm/metadata_exchange.cc
  52. 8
      src/cpp/ext/filters/census/client_filter.cc
  53. 1
      src/cpp/ext/gcp/BUILD
  54. 9
      src/cpp/ext/gcp/environment_autodetect.cc
  55. 1
      src/cpp/ext/otel/BUILD
  56. 8
      src/cpp/ext/otel/key_value_iterable.h
  57. 3
      src/cpp/ext/otel/otel_client_call_tracer.cc
  58. 80
      src/cpp/ext/otel/otel_plugin.cc
  59. 14
      src/cpp/server/external_connection_acceptor_impl.cc
  60. 3
      src/cpp/server/health/default_health_check_service.cc
  61. 40
      src/cpp/server/load_reporter/load_data_store.cc
  62. 25
      src/cpp/server/load_reporter/load_reporter.cc
  63. 12
      src/cpp/server/load_reporter/load_reporter_async_service_impl.cc
  64. 6
      src/cpp/server/load_reporter/load_reporter_async_service_impl.h
  65. 5
      src/cpp/server/orca/orca_service.cc
  66. 4
      src/cpp/server/server_builder.cc
  67. 55
      src/cpp/server/server_cc.cc
  68. 15
      src/cpp/server/server_context.cc
  69. 6
      src/cpp/server/xds_server_credentials.cc
  70. 5
      src/cpp/thread_manager/thread_manager.cc

19
BUILD

@ -1003,6 +1003,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",
@ -1192,7 +1193,10 @@ grpc_cc_library(
hdrs = [ hdrs = [
"src/cpp/client/secure_credentials.h", "src/cpp/client/secure_credentials.h",
], ],
external_deps = ["absl/strings"], external_deps = [
"absl/log:check",
"absl/strings",
],
language = "c++", language = "c++",
deps = [ deps = [
"exec_ctx", "exec_ctx",
@ -1214,6 +1218,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h",
], ],
external_deps = [
"absl/log:check",
],
language = "c++", language = "c++",
public_hdrs = [ public_hdrs = [
"include/grpcpp/xds_server_builder.h", "include/grpcpp/xds_server_builder.h",
@ -2124,6 +2131,9 @@ grpc_cc_library(
"src/cpp/server/load_reporter/constants.h", "src/cpp/server/load_reporter/constants.h",
"src/cpp/server/load_reporter/load_data_store.h", "src/cpp/server/load_reporter/load_data_store.h",
], ],
external_deps = [
"absl/log:check",
],
language = "c++", language = "c++",
deps = [ deps = [
"gpr", "gpr",
@ -2182,6 +2192,7 @@ grpc_cc_library(
"src/cpp/server/load_reporter/load_reporter_async_service_impl.h", "src/cpp/server/load_reporter/load_reporter_async_service_impl.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/memory", "absl/memory",
"protobuf_headers", "protobuf_headers",
], ],
@ -2223,6 +2234,7 @@ grpc_cc_library(
"src/cpp/server/load_reporter/load_reporter.h", "src/cpp/server/load_reporter/load_reporter.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"opencensus-stats", "opencensus-stats",
"opencensus-tags", "opencensus-tags",
"protobuf_headers", "protobuf_headers",
@ -2697,6 +2709,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/strings", "absl/strings",
"absl/time", "absl/time",
"absl/types:optional", "absl/types:optional",
@ -2855,6 +2868,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/base:endian", "absl/base:endian",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -3549,6 +3563,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
"@com_google_protobuf//upb:base", "@com_google_protobuf//upb:base",
@ -3590,6 +3605,7 @@ grpc_cc_library(
"//src/core:load_balancing/child_policy_handler.h", "//src/core:load_balancing/child_policy_handler.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
], ],
@ -3897,6 +3913,7 @@ grpc_cc_library(
"//src/core:lib/security/security_connector/alts/alts_security_connector.h", "//src/core:lib/security/security_connector/alts/alts_security_connector.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
"absl/types:optional", "absl/types:optional",

@ -3476,6 +3476,7 @@ grpc_cc_library(
srcs = ["load_balancing/lb_policy_registry.cc"], srcs = ["load_balancing/lb_policy_registry.cc"],
hdrs = ["load_balancing/lb_policy_registry.h"], hdrs = ["load_balancing/lb_policy_registry.h"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -3722,7 +3723,10 @@ grpc_cc_library(
hdrs = [ hdrs = [
"lib/security/certificate_provider/certificate_provider_registry.h", "lib/security/certificate_provider/certificate_provider_registry.h",
], ],
external_deps = ["absl/strings"], external_deps = [
"absl/log:check",
"absl/strings",
],
deps = [ deps = [
"certificate_provider_factory", "certificate_provider_factory",
"//:gpr", "//:gpr",
@ -3741,6 +3745,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",
@ -3841,6 +3846,7 @@ grpc_cc_library(
"load_balancing/grpclb/grpclb.h", "load_balancing/grpclb/grpclb.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -3886,6 +3892,7 @@ grpc_cc_library(
"lib/security/security_connector/insecure/insecure_security_connector.h", "lib/security/security_connector/insecure/insecure_security_connector.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
], ],
@ -3940,6 +3947,7 @@ grpc_cc_library(
"lib/security/security_connector/local/local_security_connector.h", "lib/security/security_connector/local/local_security_connector.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -4381,6 +4389,7 @@ grpc_cc_library(
"lib/security/authorization/rbac_policy.h", "lib/security/authorization/rbac_policy.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -4797,6 +4806,7 @@ grpc_cc_library(
"absl/base:core_headers", "absl/base:core_headers",
"absl/container:inlined_vector", "absl/container:inlined_vector",
"absl/functional:function_ref", "absl/functional:function_ref",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -4913,6 +4923,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/hash", "absl/hash",
"absl/log:check",
"absl/random", "absl/random",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
@ -5308,6 +5319,7 @@ grpc_cc_library(
"load_balancing/xds/cds.cc", "load_balancing/xds/cds.cc",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -5367,6 +5379,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",
@ -5528,6 +5541,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",
@ -5574,6 +5588,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/functional:function_ref", "absl/functional:function_ref",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/types:optional", "absl/types:optional",
@ -5610,6 +5625,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/algorithm:container", "absl/algorithm:container",
"absl/log:check",
"absl/random", "absl/random",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
@ -5730,6 +5746,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/container:inlined_vector", "absl/container:inlined_vector",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -5779,6 +5796,7 @@ grpc_cc_library(
"load_balancing/round_robin/round_robin.cc", "load_balancing/round_robin/round_robin.cc",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -5816,6 +5834,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/log:check",
"absl/types:optional", "absl/types:optional",
"absl/types:span", "absl/types:span",
], ],
@ -5830,6 +5849,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -5899,6 +5919,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -5947,6 +5968,7 @@ grpc_cc_library(
"load_balancing/priority/priority.cc", "load_balancing/priority/priority.cc",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -5994,6 +6016,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -6042,6 +6065,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/functional:function_ref", "absl/functional:function_ref",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",

@ -25,6 +25,7 @@
#include <memory> #include <memory>
#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/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -358,7 +359,7 @@ static void endpoint_read(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
SECURE_ENDPOINT_REF(ep, "read"); SECURE_ENDPOINT_REF(ep, "read");
if (ep->leftover_bytes.count) { if (ep->leftover_bytes.count) {
grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer); grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer);
GPR_ASSERT(ep->leftover_bytes.count == 0); CHECK_EQ(ep->leftover_bytes.count, 0u);
on_read(ep, absl::OkStatus()); on_read(ep, absl::OkStatus());
return; return;
} }

@ -28,6 +28,7 @@
#include <utility> #include <utility>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -381,7 +382,7 @@ grpc_error_handle SecurityHandshaker::OnHandshakeNextDoneLocked(
} }
// Read more if we need to. // Read more if we need to.
if (result == TSI_INCOMPLETE_DATA) { if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0); CHECK_EQ(bytes_to_send_size, 0u);
grpc_endpoint_read( grpc_endpoint_read(
args_->endpoint, args_->read_buffer, args_->endpoint, args_->read_buffer,
GRPC_CLOSURE_INIT( GRPC_CLOSURE_INIT(
@ -405,7 +406,7 @@ grpc_error_handle SecurityHandshaker::OnHandshakeNextDoneLocked(
} }
// Update handshaker result. // Update handshaker result.
if (handshaker_result != nullptr) { if (handshaker_result != nullptr) {
GPR_ASSERT(handshaker_result_ == nullptr); CHECK_EQ(handshaker_result_, nullptr);
handshaker_result_ = handshaker_result; handshaker_result_ = handshaker_result;
} }
if (bytes_to_send_size > 0) { if (bytes_to_send_size > 0) {

@ -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/str_format.h" #include "absl/strings/str_format.h"
@ -45,15 +46,15 @@ AuditLoggerRegistry* AuditLoggerRegistry::registry = new AuditLoggerRegistry();
AuditLoggerRegistry::AuditLoggerRegistry() { AuditLoggerRegistry::AuditLoggerRegistry() {
auto factory = std::make_unique<StdoutAuditLoggerFactory>(); auto factory = std::make_unique<StdoutAuditLoggerFactory>();
absl::string_view name = factory->name(); absl::string_view name = factory->name();
GPR_ASSERT(logger_factories_map_.emplace(name, std::move(factory)).second); CHECK(logger_factories_map_.emplace(name, std::move(factory)).second);
} }
void AuditLoggerRegistry::RegisterFactory( void AuditLoggerRegistry::RegisterFactory(
std::unique_ptr<AuditLoggerFactory> factory) { std::unique_ptr<AuditLoggerFactory> factory) {
GPR_ASSERT(factory != nullptr); CHECK(factory != nullptr);
MutexLock lock(mu); MutexLock lock(mu);
absl::string_view name = factory->name(); absl::string_view name = factory->name();
GPR_ASSERT( CHECK(
registry->logger_factories_map_.emplace(name, std::move(factory)).second); registry->logger_factories_map_.emplace(name, std::move(factory)).second);
} }
@ -78,7 +79,7 @@ std::unique_ptr<AuditLogger> AuditLoggerRegistry::CreateAuditLogger(
std::unique_ptr<AuditLoggerFactory::Config> config) { std::unique_ptr<AuditLoggerFactory::Config> config) {
MutexLock lock(mu); MutexLock lock(mu);
auto it = registry->logger_factories_map_.find(config->name()); auto it = registry->logger_factories_map_.find(config->name());
GPR_ASSERT(it != registry->logger_factories_map_.end()); CHECK(it != registry->logger_factories_map_.end());
return it->second->CreateAuditLogger(std::move(config)); return it->second->CreateAuditLogger(std::move(config));
} }

@ -18,6 +18,8 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -58,7 +60,7 @@ GrpcAuthorizationEngine::GrpcAuthorizationEngine(Rbac policy)
for (auto& logger_config : policy.logger_configs) { for (auto& logger_config : policy.logger_configs) {
auto logger = auto logger =
AuditLoggerRegistry::CreateAuditLogger(std::move(logger_config)); AuditLoggerRegistry::CreateAuditLogger(std::move(logger_config));
GPR_ASSERT(logger != nullptr); CHECK(logger != nullptr);
audit_loggers_.push_back(std::move(logger)); audit_loggers_.push_back(std::move(logger));
} }
} }

@ -18,6 +18,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
@ -82,8 +83,8 @@ gpr_timespec TimeoutSecondsToDeadline(int64_t seconds) {
absl::StatusOr<RefCountedPtr<grpc_authorization_policy_provider>> absl::StatusOr<RefCountedPtr<grpc_authorization_policy_provider>>
FileWatcherAuthorizationPolicyProvider::Create( FileWatcherAuthorizationPolicyProvider::Create(
absl::string_view authz_policy_path, unsigned int refresh_interval_sec) { absl::string_view authz_policy_path, unsigned int refresh_interval_sec) {
GPR_ASSERT(!authz_policy_path.empty()); CHECK(!authz_policy_path.empty());
GPR_ASSERT(refresh_interval_sec > 0); CHECK_GT(refresh_interval_sec, 0u);
absl::Status status; absl::Status status;
auto provider = MakeRefCounted<FileWatcherAuthorizationPolicyProvider>( auto provider = MakeRefCounted<FileWatcherAuthorizationPolicyProvider>(
authz_policy_path, refresh_interval_sec, &status); authz_policy_path, refresh_interval_sec, &status);
@ -105,7 +106,7 @@ FileWatcherAuthorizationPolicyProvider::FileWatcherAuthorizationPolicyProvider(
auto thread_lambda = [](void* arg) { auto thread_lambda = [](void* arg) {
WeakRefCountedPtr<FileWatcherAuthorizationPolicyProvider> provider( WeakRefCountedPtr<FileWatcherAuthorizationPolicyProvider> provider(
static_cast<FileWatcherAuthorizationPolicyProvider*>(arg)); static_cast<FileWatcherAuthorizationPolicyProvider*>(arg));
GPR_ASSERT(provider != nullptr); CHECK(provider != nullptr);
while (true) { while (true) {
void* value = gpr_event_wait( void* value = gpr_event_wait(
&provider->shutdown_event_, &provider->shutdown_event_,
@ -193,7 +194,7 @@ grpc_authorization_policy_provider*
grpc_authorization_policy_provider_static_data_create( grpc_authorization_policy_provider_static_data_create(
const char* authz_policy, grpc_status_code* code, const char* authz_policy, grpc_status_code* code,
const char** error_details) { const char** error_details) {
GPR_ASSERT(authz_policy != nullptr); CHECK_NE(authz_policy, nullptr);
auto provider_or = auto provider_or =
grpc_core::StaticDataAuthorizationPolicyProvider::Create(authz_policy); grpc_core::StaticDataAuthorizationPolicyProvider::Create(authz_policy);
if (!provider_or.ok()) { if (!provider_or.ok()) {
@ -209,7 +210,7 @@ grpc_authorization_policy_provider*
grpc_authorization_policy_provider_file_watcher_create( grpc_authorization_policy_provider_file_watcher_create(
const char* authz_policy_path, unsigned int refresh_interval_sec, const char* authz_policy_path, unsigned int refresh_interval_sec,
grpc_status_code* code, const char** error_details) { grpc_status_code* code, const char** error_details) {
GPR_ASSERT(authz_policy_path != nullptr); CHECK_NE(authz_policy_path, nullptr);
auto provider_or = grpc_core::FileWatcherAuthorizationPolicyProvider::Create( auto provider_or = grpc_core::FileWatcherAuthorizationPolicyProvider::Create(
authz_policy_path, refresh_interval_sec); authz_policy_path, refresh_interval_sec);
if (!provider_or.ok()) { if (!provider_or.ok()) {

@ -23,6 +23,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/match.h" #include "absl/strings/match.h"
@ -421,7 +422,7 @@ ParseAuditLogger(const Json& json, size_t pos) {
} }
absl::Status ParseAuditLoggingOptions(const Json& json, RbacPolicies* rbacs) { absl::Status ParseAuditLoggingOptions(const Json& json, RbacPolicies* rbacs) {
GPR_ASSERT(rbacs != nullptr); CHECK_NE(rbacs, nullptr);
for (auto it = json.object().begin(); it != json.object().end(); ++it) { for (auto it = json.object().begin(); it != json.object().end(); ++it) {
if (it->first == "audit_condition") { if (it->first == "audit_condition") {
if (it->second.type() != Json::Type::kString) { if (it->second.type() != Json::Type::kString) {
@ -475,7 +476,7 @@ absl::Status ParseAuditLoggingOptions(const Json& json, RbacPolicies* rbacs) {
// Parse again since it returns unique_ptr, but result should be ok // Parse again since it returns unique_ptr, but result should be ok
// this time. // this time.
auto result = ParseAuditLogger(loggers.at(i), i); auto result = ParseAuditLogger(loggers.at(i), i);
GPR_ASSERT(result.ok()); CHECK(result.ok());
rbacs->deny_policy->logger_configs.push_back( rbacs->deny_policy->logger_configs.push_back(
std::move(result.value())); std::move(result.value()));
} }

@ -18,6 +18,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "absl/log/check.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -65,7 +66,8 @@ StdoutAuditLoggerFactory::ParseAuditLoggerConfig(const Json&) {
std::unique_ptr<AuditLogger> StdoutAuditLoggerFactory::CreateAuditLogger( std::unique_ptr<AuditLogger> StdoutAuditLoggerFactory::CreateAuditLogger(
std::unique_ptr<AuditLoggerFactory::Config> config) { std::unique_ptr<AuditLoggerFactory::Config> config) {
// Sanity check. // Sanity check.
GPR_ASSERT(config != nullptr && config->name() == name()); CHECK(config != nullptr);
CHECK(config->name() == name());
return std::make_unique<StdoutAuditLogger>(); return std::make_unique<StdoutAuditLogger>();
} }

@ -21,6 +21,8 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -31,7 +33,7 @@ void CertificateProviderRegistry::Builder::RegisterCertificateProviderFactory(
absl::string_view name = factory->name(); absl::string_view name = factory->name();
gpr_log(GPR_DEBUG, "registering certificate provider factory for \"%s\"", gpr_log(GPR_DEBUG, "registering certificate provider factory for \"%s\"",
std::string(name).c_str()); std::string(name).c_str());
GPR_ASSERT(factories_.emplace(name, std::move(factory)).second); CHECK(factories_.emplace(name, std::move(factory)).second);
} }
CertificateProviderRegistry CertificateProviderRegistry::Builder::Build() { CertificateProviderRegistry CertificateProviderRegistry::Builder::Build() {

@ -22,6 +22,8 @@
#include <algorithm> #include <algorithm>
#include "absl/log/check.h"
#include <grpc/credentials.h> #include <grpc/credentials.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
@ -193,7 +195,7 @@ const grpc_auth_property* grpc_auth_property_iterator_next(
while (it->index < it->ctx->properties().count) { while (it->index < it->ctx->properties().count) {
const grpc_auth_property* prop = const grpc_auth_property* prop =
&it->ctx->properties().array[it->index++]; &it->ctx->properties().array[it->index++];
GPR_ASSERT(prop->name != nullptr); CHECK_NE(prop->name, nullptr);
if (strcmp(it->name, prop->name) == 0) { if (strcmp(it->name, prop->name) == 0) {
return prop; return prop;
} }

@ -23,6 +23,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -103,10 +104,10 @@ class grpc_alts_channel_security_connector final
static_cast<const grpc_alts_credentials*>(channel_creds()); static_cast<const grpc_alts_credentials*>(channel_creds());
const size_t user_specified_max_frame_size = const size_t user_specified_max_frame_size =
std::max(0, args.GetInt(GRPC_ARG_TSI_MAX_FRAME_SIZE).value_or(0)); std::max(0, args.GetInt(GRPC_ARG_TSI_MAX_FRAME_SIZE).value_or(0));
GPR_ASSERT(alts_tsi_handshaker_create( CHECK(alts_tsi_handshaker_create(creds->options(), target_name_,
creds->options(), target_name_, creds->handshaker_service_url(), true,
creds->handshaker_service_url(), true, interested_parties, interested_parties, &handshaker,
&handshaker, user_specified_max_frame_size) == TSI_OK); user_specified_max_frame_size) == TSI_OK);
handshake_manager->Add( handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args)); grpc_core::SecurityHandshakerCreate(handshaker, this, args));
} }
@ -156,10 +157,10 @@ class grpc_alts_server_security_connector final
static_cast<const grpc_alts_server_credentials*>(server_creds()); static_cast<const grpc_alts_server_credentials*>(server_creds());
size_t user_specified_max_frame_size = size_t user_specified_max_frame_size =
std::max(0, args.GetInt(GRPC_ARG_TSI_MAX_FRAME_SIZE).value_or(0)); std::max(0, args.GetInt(GRPC_ARG_TSI_MAX_FRAME_SIZE).value_or(0));
GPR_ASSERT(alts_tsi_handshaker_create( CHECK(alts_tsi_handshaker_create(creds->options(), nullptr,
creds->options(), nullptr, creds->handshaker_service_url(), creds->handshaker_service_url(), false,
false, interested_parties, &handshaker, interested_parties, &handshaker,
user_specified_max_frame_size) == TSI_OK); user_specified_max_frame_size) == TSI_OK);
handshake_manager->Add( handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args)); grpc_core::SecurityHandshakerCreate(handshaker, this, args));
} }
@ -251,8 +252,8 @@ RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer(
grpc_auth_context_add_property( grpc_auth_context_add_property(
ctx.get(), TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY, ctx.get(), TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY,
tsi_prop->value.data, tsi_prop->value.length); tsi_prop->value.data, tsi_prop->value.length);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name( CHECK(grpc_auth_context_set_peer_identity_property_name(
ctx.get(), TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY) == 1); ctx.get(), TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY) == 1);
} }
// Add alts context to auth context. // Add alts context to auth context.
if (strcmp(tsi_prop->name, TSI_ALTS_CONTEXT) == 0) { if (strcmp(tsi_prop->name, TSI_ALTS_CONTEXT) == 0) {

@ -24,6 +24,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -141,7 +142,7 @@ class grpc_fake_channel_security_connector final
private: private:
bool fake_check_target(const char* target, const char* set_str) const { bool fake_check_target(const char* target, const char* set_str) const {
GPR_ASSERT(target != nullptr); CHECK_NE(target, nullptr);
char** set = nullptr; char** set = nullptr;
size_t set_size = 0; size_t set_size = 0;
gpr_string_split(set_str, ",", &set, &set_size); gpr_string_split(set_str, ",", &set, &set_size);

@ -20,6 +20,8 @@
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -70,7 +72,7 @@ void InsecureChannelSecurityConnector::add_handshakers(
HandshakeManager* handshake_manager) { HandshakeManager* handshake_manager) {
tsi_handshaker* handshaker = nullptr; tsi_handshaker* handshaker = nullptr;
// Re-use local_tsi_handshaker_create as a minimalist handshaker. // Re-use local_tsi_handshaker_create as a minimalist handshaker.
GPR_ASSERT(tsi_local_handshaker_create(&handshaker) == TSI_OK); CHECK(tsi_local_handshaker_create(&handshaker) == TSI_OK);
handshake_manager->Add(SecurityHandshakerCreate(handshaker, this, args)); handshake_manager->Add(SecurityHandshakerCreate(handshaker, this, args));
} }
@ -97,7 +99,7 @@ void InsecureServerSecurityConnector::add_handshakers(
HandshakeManager* handshake_manager) { HandshakeManager* handshake_manager) {
tsi_handshaker* handshaker = nullptr; tsi_handshaker* handshaker = nullptr;
// Re-use local_tsi_handshaker_create as a minimalist handshaker. // Re-use local_tsi_handshaker_create as a minimalist handshaker.
GPR_ASSERT(tsi_local_handshaker_create(&handshaker) == TSI_OK); CHECK(tsi_local_handshaker_create(&handshaker) == TSI_OK);
handshake_manager->Add(SecurityHandshakerCreate(handshaker, this, args)); handshake_manager->Add(SecurityHandshakerCreate(handshaker, this, args));
} }

@ -23,6 +23,7 @@
#include <string> #include <string>
#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"
@ -77,12 +78,12 @@ grpc_core::RefCountedPtr<grpc_auth_context> local_auth_context_create(
grpc_auth_context_add_cstring_property( grpc_auth_context_add_cstring_property(
ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME, ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_LOCAL_TRANSPORT_SECURITY_TYPE); GRPC_LOCAL_TRANSPORT_SECURITY_TYPE);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name( CHECK(grpc_auth_context_set_peer_identity_property_name(
ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME) == 1); ctx.get(), GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME) == 1);
GPR_ASSERT(peer->property_count == 1); CHECK_EQ(peer->property_count, 1u);
const tsi_peer_property* prop = &peer->properties[0]; const tsi_peer_property* prop = &peer->properties[0];
GPR_ASSERT(prop != nullptr); CHECK_NE(prop, nullptr);
GPR_ASSERT(strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY) == 0); CHECK_EQ(strcmp(prop->name, TSI_SECURITY_LEVEL_PEER_PROPERTY), 0);
grpc_auth_context_add_property(ctx.get(), grpc_auth_context_add_property(ctx.get(),
GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME, GRPC_TRANSPORT_SECURITY_LEVEL_PROPERTY_NAME,
prop->value.data, prop->value.length); prop->value.data, prop->value.length);
@ -182,7 +183,7 @@ class grpc_local_channel_security_connector final
grpc_pollset_set* /*interested_parties*/, grpc_pollset_set* /*interested_parties*/,
grpc_core::HandshakeManager* handshake_manager) override { grpc_core::HandshakeManager* handshake_manager) override {
tsi_handshaker* handshaker = nullptr; tsi_handshaker* handshaker = nullptr;
GPR_ASSERT(tsi_local_handshaker_create(&handshaker) == TSI_OK); CHECK(tsi_local_handshaker_create(&handshaker) == TSI_OK);
handshake_manager->Add( handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args)); grpc_core::SecurityHandshakerCreate(handshaker, this, args));
} }
@ -237,7 +238,7 @@ class grpc_local_server_security_connector final
grpc_pollset_set* /*interested_parties*/, grpc_pollset_set* /*interested_parties*/,
grpc_core::HandshakeManager* handshake_manager) override { grpc_core::HandshakeManager* handshake_manager) override {
tsi_handshaker* handshaker = nullptr; tsi_handshaker* handshaker = nullptr;
GPR_ASSERT(tsi_local_handshaker_create(&handshaker) == TSI_OK); CHECK(tsi_local_handshaker_create(&handshaker) == TSI_OK);
handshake_manager->Add( handshake_manager->Add(
grpc_core::SecurityHandshakerCreate(handshaker, this, args)); grpc_core::SecurityHandshakerCreate(handshaker, this, args));
} }

@ -22,6 +22,8 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -45,8 +47,8 @@ int grpc_channel_security_connector::channel_security_connector_cmp(
const grpc_channel_security_connector* other) const { const grpc_channel_security_connector* other) const {
const grpc_channel_security_connector* other_sc = const grpc_channel_security_connector* other_sc =
static_cast<const grpc_channel_security_connector*>(other); static_cast<const grpc_channel_security_connector*>(other);
GPR_ASSERT(channel_creds() != nullptr); CHECK_NE(channel_creds(), nullptr);
GPR_ASSERT(other_sc->channel_creds() != nullptr); CHECK_NE(other_sc->channel_creds(), nullptr);
int c = channel_creds()->cmp(other_sc->channel_creds()); int c = channel_creds()->cmp(other_sc->channel_creds());
if (c != 0) return c; if (c != 0) return c;
return grpc_core::QsortCompare(request_metadata_creds(), return grpc_core::QsortCompare(request_metadata_creds(),
@ -67,8 +69,8 @@ int grpc_server_security_connector::server_security_connector_cmp(
const grpc_server_security_connector* other) const { const grpc_server_security_connector* other) const {
const grpc_server_security_connector* other_sc = const grpc_server_security_connector* other_sc =
static_cast<const grpc_server_security_connector*>(other); static_cast<const grpc_server_security_connector*>(other);
GPR_ASSERT(server_creds() != nullptr); CHECK_NE(server_creds(), nullptr);
GPR_ASSERT(other_sc->server_creds() != nullptr); CHECK_NE(other_sc->server_creds(), nullptr);
return grpc_core::QsortCompare(server_creds(), other_sc->server_creds()); return grpc_core::QsortCompare(server_creds(), other_sc->server_creds());
} }

@ -24,6 +24,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -330,7 +331,7 @@ class grpc_ssl_server_security_connector
tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr; tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr;
const grpc_ssl_server_credentials* server_creds = const grpc_ssl_server_credentials* server_creds =
static_cast<const grpc_ssl_server_credentials*>(this->server_creds()); static_cast<const grpc_ssl_server_credentials*>(this->server_creds());
GPR_DEBUG_ASSERT(config->pem_root_certs != nullptr); DCHECK_NE(config->pem_root_certs, nullptr);
tsi_ssl_server_handshaker_options options; tsi_ssl_server_handshaker_options options;
options.pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs( options.pem_key_cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
config->pem_key_cert_pairs, config->num_key_cert_pairs); config->pem_key_cert_pairs, config->num_key_cert_pairs);
@ -394,7 +395,7 @@ grpc_ssl_channel_security_connector_create(
grpc_core::RefCountedPtr<grpc_server_security_connector> grpc_core::RefCountedPtr<grpc_server_security_connector>
grpc_ssl_server_security_connector_create( grpc_ssl_server_security_connector_create(
grpc_core::RefCountedPtr<grpc_server_credentials> server_credentials) { grpc_core::RefCountedPtr<grpc_server_credentials> server_credentials) {
GPR_ASSERT(server_credentials != nullptr); CHECK(server_credentials != nullptr);
grpc_core::RefCountedPtr<grpc_ssl_server_security_connector> c = grpc_core::RefCountedPtr<grpc_ssl_server_security_connector> c =
grpc_core::MakeRefCounted<grpc_ssl_server_security_connector>( grpc_core::MakeRefCounted<grpc_ssl_server_security_connector>(
std::move(server_credentials)); std::move(server_credentials));

@ -25,6 +25,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#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_split.h" #include "absl/strings/str_split.h"
@ -191,7 +192,7 @@ absl::Status SslCheckCallHost(absl::string_view host,
} // namespace grpc_core } // namespace grpc_core
const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) { const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
GPR_ASSERT(num_alpn_protocols != nullptr); CHECK_NE(num_alpn_protocols, nullptr);
*num_alpn_protocols = grpc_chttp2_num_alpn_versions(); *num_alpn_protocols = grpc_chttp2_num_alpn_versions();
const char** alpn_protocol_strings = static_cast<const char**>( const char** alpn_protocol_strings = static_cast<const char**>(
gpr_malloc(sizeof(const char*) * (*num_alpn_protocols))); gpr_malloc(sizeof(const char*) * (*num_alpn_protocols)));
@ -252,7 +253,7 @@ grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
const char* peer_identity_property_name = nullptr; const char* peer_identity_property_name = nullptr;
// The caller has checked the certificate type property. // The caller has checked the certificate type property.
GPR_ASSERT(peer->property_count >= 1); CHECK_GE(peer->property_count, 1u);
grpc_core::RefCountedPtr<grpc_auth_context> ctx = grpc_core::RefCountedPtr<grpc_auth_context> ctx =
grpc_core::MakeRefCounted<grpc_auth_context>(nullptr); grpc_core::MakeRefCounted<grpc_auth_context>(nullptr);
grpc_auth_context_add_cstring_property( grpc_auth_context_add_cstring_property(
@ -319,14 +320,14 @@ grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
} }
} }
if (peer_identity_property_name != nullptr) { if (peer_identity_property_name != nullptr) {
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name( CHECK(grpc_auth_context_set_peer_identity_property_name(
ctx.get(), peer_identity_property_name) == 1); ctx.get(), peer_identity_property_name) == 1);
} }
// A valid SPIFFE certificate can only have exact one URI SAN field. // A valid SPIFFE certificate can only have exact one URI SAN field.
if (has_spiffe_id) { if (has_spiffe_id) {
if (uri_count == 1) { if (uri_count == 1) {
GPR_ASSERT(spiffe_length > 0); CHECK_GT(spiffe_length, 0u);
GPR_ASSERT(spiffe_data != nullptr); CHECK_NE(spiffe_data, nullptr);
grpc_auth_context_add_property(ctx.get(), grpc_auth_context_add_property(ctx.get(),
GRPC_PEER_SPIFFE_ID_PROPERTY_NAME, GRPC_PEER_SPIFFE_ID_PROPERTY_NAME,
spiffe_data, spiffe_length); spiffe_data, spiffe_length);
@ -587,7 +588,7 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() {
char* pem_root_certs = nullptr; char* pem_root_certs = nullptr;
ovrd_res = ssl_roots_override_cb(&pem_root_certs); ovrd_res = ssl_roots_override_cb(&pem_root_certs);
if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
GPR_ASSERT(pem_root_certs != nullptr); CHECK_NE(pem_root_certs, nullptr);
result = Slice::FromCopiedBuffer( result = Slice::FromCopiedBuffer(
pem_root_certs, pem_root_certs,
strlen(pem_root_certs) + 1); // nullptr terminator. strlen(pem_root_certs) + 1); // nullptr terminator.

@ -25,6 +25,7 @@
#include <vector> #include <vector>
#include "absl/functional/bind_front.h" #include "absl/functional/bind_front.h"
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -63,7 +64,7 @@ char* CopyCoreString(char* src, size_t length) {
void PendingVerifierRequestInit( void PendingVerifierRequestInit(
const char* target_name, tsi_peer peer, const char* target_name, tsi_peer peer,
grpc_tls_custom_verification_check_request* request) { grpc_tls_custom_verification_check_request* request) {
GPR_ASSERT(request != nullptr); CHECK_NE(request, nullptr);
// The verifier holds a ref to the security connector, so it's fine to // The verifier holds a ref to the security connector, so it's fine to
// directly point this to the name cached in the security connector. // directly point this to the name cached in the security connector.
request->target_name = target_name; request->target_name = target_name;
@ -175,7 +176,7 @@ void PendingVerifierRequestInit(
void PendingVerifierRequestDestroy( void PendingVerifierRequestDestroy(
grpc_tls_custom_verification_check_request* request) { grpc_tls_custom_verification_check_request* request) {
GPR_ASSERT(request != nullptr); CHECK_NE(request, nullptr);
if (request->peer_info.common_name != nullptr) { if (request->peer_info.common_name != nullptr) {
gpr_free(const_cast<char*>(request->peer_info.common_name)); gpr_free(const_cast<char*>(request->peer_info.common_name));
} }
@ -219,13 +220,13 @@ tsi_ssl_pem_key_cert_pair* ConvertToTsiPemKeyCertPair(
tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr; tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr;
size_t num_key_cert_pairs = cert_pair_list.size(); size_t num_key_cert_pairs = cert_pair_list.size();
if (num_key_cert_pairs > 0) { if (num_key_cert_pairs > 0) {
GPR_ASSERT(cert_pair_list.data() != nullptr); CHECK_NE(cert_pair_list.data(), nullptr);
tsi_pairs = static_cast<tsi_ssl_pem_key_cert_pair*>( tsi_pairs = static_cast<tsi_ssl_pem_key_cert_pair*>(
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair))); gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)));
} }
for (size_t i = 0; i < num_key_cert_pairs; i++) { for (size_t i = 0; i < num_key_cert_pairs; i++) {
GPR_ASSERT(!cert_pair_list[i].private_key().empty()); CHECK(!cert_pair_list[i].private_key().empty());
GPR_ASSERT(!cert_pair_list[i].cert_chain().empty()); CHECK(!cert_pair_list[i].cert_chain().empty());
tsi_pairs[i].cert_chain = tsi_pairs[i].cert_chain =
gpr_strdup(cert_pair_list[i].cert_chain().c_str()); gpr_strdup(cert_pair_list[i].cert_chain().c_str());
tsi_pairs[i].private_key = tsi_pairs[i].private_key =
@ -376,7 +377,7 @@ void TlsChannelSecurityConnector::check_peer(
} }
*auth_context = *auth_context =
grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE); grpc_ssl_peer_to_auth_context(&peer, GRPC_TLS_TRANSPORT_SECURITY_TYPE);
GPR_ASSERT(options_->certificate_verifier() != nullptr); CHECK_NE(options_->certificate_verifier(), nullptr);
auto* pending_request = new ChannelPendingVerifierRequest( auto* pending_request = new ChannelPendingVerifierRequest(
RefAsSubclass<TlsChannelSecurityConnector>(), on_peer_checked, peer, RefAsSubclass<TlsChannelSecurityConnector>(), on_peer_checked, peer,
target_name); target_name);
@ -435,7 +436,7 @@ ArenaPromise<absl::Status> TlsChannelSecurityConnector::CheckCallHost(
void TlsChannelSecurityConnector::TlsChannelCertificateWatcher:: void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::
OnCertificatesChanged(absl::optional<absl::string_view> root_certs, OnCertificatesChanged(absl::optional<absl::string_view> root_certs,
absl::optional<PemKeyCertPairList> key_cert_pairs) { absl::optional<PemKeyCertPairList> key_cert_pairs) {
GPR_ASSERT(security_connector_ != nullptr); CHECK_NE(security_connector_, nullptr);
MutexLock lock(&security_connector_->mu_); MutexLock lock(&security_connector_->mu_);
if (root_certs.has_value()) { if (root_certs.has_value()) {
security_connector_->pem_root_certs_ = root_certs; security_connector_->pem_root_certs_ = root_certs;
@ -700,7 +701,7 @@ int TlsServerSecurityConnector::cmp(
void TlsServerSecurityConnector::TlsServerCertificateWatcher:: void TlsServerSecurityConnector::TlsServerCertificateWatcher::
OnCertificatesChanged(absl::optional<absl::string_view> root_certs, OnCertificatesChanged(absl::optional<absl::string_view> root_certs,
absl::optional<PemKeyCertPairList> key_cert_pairs) { absl::optional<PemKeyCertPairList> key_cert_pairs) {
GPR_ASSERT(security_connector_ != nullptr); CHECK_NE(security_connector_, nullptr);
MutexLock lock(&security_connector_->mu_); MutexLock lock(&security_connector_->mu_);
if (root_certs.has_value()) { if (root_certs.has_value()) {
security_connector_->pem_root_certs_ = root_certs; security_connector_->pem_root_certs_ = root_certs;
@ -799,8 +800,8 @@ TlsServerSecurityConnector::UpdateHandshakerFactoryLocked() {
tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_); tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
} }
// The identity certs on the server side shouldn't be empty. // The identity certs on the server side shouldn't be empty.
GPR_ASSERT(pem_key_cert_pair_list_.has_value()); CHECK(pem_key_cert_pair_list_.has_value());
GPR_ASSERT(!(*pem_key_cert_pair_list_).empty()); CHECK(!(*pem_key_cert_pair_list_).empty());
std::string pem_root_certs; std::string pem_root_certs;
if (pem_root_certs_.has_value()) { if (pem_root_certs_.has_value()) {
// TODO(ZhenLian): update the underlying TSI layer to use C++ types like // TODO(ZhenLian): update the underlying TSI layer to use C++ types like

@ -23,6 +23,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"
@ -216,7 +217,7 @@ ServerAuthFilter::ServerAuthFilter(
absl::StatusOr<std::unique_ptr<ServerAuthFilter>> ServerAuthFilter::Create( absl::StatusOr<std::unique_ptr<ServerAuthFilter>> ServerAuthFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) { const ChannelArgs& args, ChannelFilter::Args) {
auto auth_context = args.GetObjectRef<grpc_auth_context>(); auto auth_context = args.GetObjectRef<grpc_auth_context>();
GPR_ASSERT(auth_context != nullptr); CHECK(auth_context != nullptr);
auto creds = args.GetObjectRef<grpc_server_credentials>(); auto creds = args.GetObjectRef<grpc_server_credentials>();
return std::make_unique<ServerAuthFilter>(std::move(creds), return std::make_unique<ServerAuthFilter>(std::move(creds),
std::move(auth_context)); std::move(auth_context));

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

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

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

@ -24,6 +24,7 @@
#include <type_traits> #include <type_traits>
#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"
@ -132,7 +133,7 @@ void HealthProducer::HealthChecker::OnConnectivityStateChangeLocked(
state_ = GRPC_CHANNEL_CONNECTING; state_ = GRPC_CHANNEL_CONNECTING;
status_ = absl::OkStatus(); status_ = absl::OkStatus();
} else { } else {
GPR_ASSERT(state_ == GRPC_CHANNEL_CONNECTING); CHECK(state_ == GRPC_CHANNEL_CONNECTING);
} }
// Start the health watch stream. // Start the health watch stream.
StartHealthStreamLocked(); StartHealthStreamLocked();

@ -22,6 +22,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/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -44,7 +45,7 @@ void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
std::unique_ptr<LoadBalancingPolicyFactory> factory) { std::unique_ptr<LoadBalancingPolicyFactory> factory) {
gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"", gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"",
std::string(factory->name()).c_str()); 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)); factories_.emplace(factory->name(), std::move(factory));
} }

@ -23,6 +23,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/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/duration.upb.h" #include "google/protobuf/duration.upb.h"
@ -224,7 +225,7 @@ void OrcaProducer::Orphaned() {
MutexLock lock(&mu_); MutexLock lock(&mu_);
stream_client_.reset(); 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_->CancelConnectivityStateWatch(connectivity_watcher_);
subchannel_->RemoveDataProducer(this); subchannel_->RemoveDataProducer(this);
} }

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

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

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

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

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

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

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

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

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

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

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

@ -31,6 +31,7 @@
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/functional/function_ref.h" #include "absl/functional/function_ref.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/str_cat.h" #include "absl/strings/str_cat.h"
@ -228,7 +229,7 @@ class XdsOverrideHostLb final : public LoadBalancingPolicy {
// already has an owned subchannel. // already has an owned subchannel.
void SetOwnedSubchannel(RefCountedPtr<SubchannelWrapper> subchannel) void SetOwnedSubchannel(RefCountedPtr<SubchannelWrapper> subchannel)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsOverrideHostLb::mu_) { ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsOverrideHostLb::mu_) {
GPR_DEBUG_ASSERT(!HasOwnedSubchannel()); DCHECK(!HasOwnedSubchannel());
subchannel_ = std::move(subchannel); subchannel_ = std::move(subchannel);
} }
@ -474,7 +475,7 @@ XdsOverrideHostLb::Picker::Picker(
absl::optional<LoadBalancingPolicy::PickResult> absl::optional<LoadBalancingPolicy::PickResult>
XdsOverrideHostLb::Picker::PickOverridenHost( XdsOverrideHostLb::Picker::PickOverridenHost(
XdsOverrideHostAttribute* override_host_attr) const { 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(); auto cookie_address_list = override_host_attr->cookie_address_list();
if (cookie_address_list.empty()) return absl::nullopt; if (cookie_address_list.empty()) return absl::nullopt;
// The cookie has an address list, so look through the addresses in order. // 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()); std::string(address).c_str());
} }
auto addr = StringToSockaddr(address); 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 // 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 // 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 // will need to change this to store those attributes from the resolver

@ -11,6 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -22,7 +24,7 @@ namespace grpc {
CallCredentials::CallCredentials(grpc_call_credentials* c_creds) CallCredentials::CallCredentials(grpc_call_credentials* c_creds)
: c_creds_(c_creds) { : c_creds_(c_creds) {
GPR_ASSERT(c_creds != nullptr); CHECK_NE(c_creds, nullptr);
} }
CallCredentials::~CallCredentials() { grpc_call_credentials_release(c_creds_); } CallCredentials::~CallCredentials() { grpc_call_credentials_release(c_creds_); }

@ -23,6 +23,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/connectivity_state.h> #include <grpc/impl/connectivity_state.h>
#include <grpc/slice.h> #include <grpc/slice.h>
@ -207,7 +209,7 @@ bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed,
void* tag = nullptr; void* tag = nullptr;
NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr); NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr);
cq.Next(&tag, &ok); cq.Next(&tag, &ok);
GPR_ASSERT(tag == nullptr); CHECK_EQ(tag, nullptr);
return ok; return ok;
} }

@ -24,6 +24,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/compression.h> #include <grpc/compression.h>
@ -125,7 +126,7 @@ void ClientContext::AddMetadata(const std::string& meta_key,
void ClientContext::set_call(grpc_call* call, void ClientContext::set_call(grpc_call* call,
const std::shared_ptr<Channel>& channel) { const std::shared_ptr<Channel>& channel) {
internal::MutexLock lock(&mu_); internal::MutexLock lock(&mu_);
GPR_ASSERT(call_ == nullptr); CHECK_EQ(call_, nullptr);
call_ = call; call_ = call;
channel_ = channel; channel_ = channel;
if (creds_ && !creds_->ApplyToCall(call_)) { if (creds_ && !creds_->ApplyToCall(call_)) {
@ -148,7 +149,7 @@ void ClientContext::set_compression_algorithm(
grpc_core::Crash(absl::StrFormat( grpc_core::Crash(absl::StrFormat(
"Name for compression algorithm '%d' unknown.", algorithm)); "Name for compression algorithm '%d' unknown.", algorithm));
} }
GPR_ASSERT(algorithm_name != nullptr); CHECK_NE(algorithm_name, nullptr);
AddMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name); AddMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name);
} }
@ -180,9 +181,9 @@ std::string ClientContext::peer() const {
} }
void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) { void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) {
GPR_ASSERT(g_client_callbacks == g_default_client_callbacks); CHECK(g_client_callbacks == g_default_client_callbacks);
GPR_ASSERT(client_callbacks != nullptr); CHECK_NE(client_callbacks, nullptr);
GPR_ASSERT(client_callbacks != g_default_client_callbacks); CHECK(client_callbacks != g_default_client_callbacks);
g_client_callbacks = client_callbacks; g_client_callbacks = client_callbacks;
} }

@ -24,6 +24,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/str_join.h" #include "absl/strings/str_join.h"
@ -362,7 +363,7 @@ class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
size_t* num_creds_md, grpc_status_code* status, size_t* num_creds_md, grpc_status_code* status,
const char** error_details) { const char** error_details) {
GPR_ASSERT(wrapper); CHECK(wrapper);
MetadataCredentialsPluginWrapper* w = MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper); static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
if (!w->plugin_) { if (!w->plugin_) {
@ -393,7 +394,7 @@ class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
} }
static char* DebugString(void* wrapper) { static char* DebugString(void* wrapper) {
GPR_ASSERT(wrapper); CHECK(wrapper);
MetadataCredentialsPluginWrapper* w = MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper); static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
return gpr_strdup(w->plugin_->DebugString().c_str()); return gpr_strdup(w->plugin_->DebugString().c_str());

@ -18,6 +18,8 @@
#include <memory> #include <memory>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -30,13 +32,13 @@ class XdsChannelCredentialsImpl final : public ChannelCredentials {
const std::shared_ptr<ChannelCredentials>& fallback_creds) const std::shared_ptr<ChannelCredentials>& fallback_creds)
: ChannelCredentials( : ChannelCredentials(
grpc_xds_credentials_create(fallback_creds->c_creds_)) { grpc_xds_credentials_create(fallback_creds->c_creds_)) {
GPR_ASSERT(fallback_creds->c_creds_ != nullptr); CHECK_NE(fallback_creds->c_creds_, nullptr);
} }
}; };
std::shared_ptr<ChannelCredentials> XdsCredentials( std::shared_ptr<ChannelCredentials> XdsCredentials(
const std::shared_ptr<ChannelCredentials>& fallback_creds) { const std::shared_ptr<ChannelCredentials>& fallback_creds) {
GPR_ASSERT(fallback_creds != nullptr); CHECK_NE(fallback_creds, nullptr);
return std::make_shared<XdsChannelCredentialsImpl>(fallback_creds); return std::make_shared<XdsChannelCredentialsImpl>(fallback_creds);
} }

@ -20,6 +20,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 <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
@ -65,10 +66,10 @@ class AlarmImpl : public grpc::internal::CompletionQueueTag {
GRPC_CQ_INTERNAL_REF(cq->cq(), "alarm"); GRPC_CQ_INTERNAL_REF(cq->cq(), "alarm");
cq_ = cq->cq(); cq_ = cq->cq();
tag_ = tag; tag_ = tag;
GPR_ASSERT(grpc_cq_begin_op(cq_, this)); CHECK(grpc_cq_begin_op(cq_, this));
Ref(); Ref();
GPR_ASSERT(cq_armed_.exchange(true) == false); CHECK(cq_armed_.exchange(true) == false);
GPR_ASSERT(!callback_armed_.load()); CHECK(!callback_armed_.load());
cq_timer_handle_ = event_engine_->RunAfter( cq_timer_handle_ = event_engine_->RunAfter(
grpc_core::Timestamp::FromTimespecRoundUp(deadline) - grpc_core::Timestamp::FromTimespecRoundUp(deadline) -
grpc_core::ExecCtx::Get()->Now(), grpc_core::ExecCtx::Get()->Now(),
@ -79,8 +80,8 @@ class AlarmImpl : public grpc::internal::CompletionQueueTag {
// Don't use any CQ at all. Instead just use the timer to fire the function // Don't use any CQ at all. Instead just use the timer to fire the function
callback_ = std::move(f); callback_ = std::move(f);
Ref(); Ref();
GPR_ASSERT(callback_armed_.exchange(true) == false); CHECK(callback_armed_.exchange(true) == false);
GPR_ASSERT(!cq_armed_.load()); CHECK(!cq_armed_.load());
callback_timer_handle_ = event_engine_->RunAfter( callback_timer_handle_ = event_engine_->RunAfter(
grpc_core::Timestamp::FromTimespecRoundUp(deadline) - grpc_core::Timestamp::FromTimespecRoundUp(deadline) -
grpc_core::ExecCtx::Get()->Now(), grpc_core::ExecCtx::Get()->Now(),

@ -20,6 +20,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h> #include <grpc/impl/compression_types.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -45,7 +47,7 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
for (const auto& a : other.args_) { for (const auto& a : other.args_) {
grpc_arg ap; grpc_arg ap;
ap.type = a.type; ap.type = a.type;
GPR_ASSERT(list_it_src->c_str() == a.key); CHECK(list_it_src->c_str() == a.key);
ap.key = const_cast<char*>(list_it_dst->c_str()); ap.key = const_cast<char*>(list_it_dst->c_str());
++list_it_src; ++list_it_src;
++list_it_dst; ++list_it_dst;
@ -54,7 +56,7 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
ap.value.integer = a.value.integer; ap.value.integer = a.value.integer;
break; break;
case GRPC_ARG_STRING: case GRPC_ARG_STRING:
GPR_ASSERT(list_it_src->c_str() == a.value.string); CHECK(list_it_src->c_str() == a.value.string);
ap.value.string = const_cast<char*>(list_it_dst->c_str()); ap.value.string = const_cast<char*>(list_it_dst->c_str());
++list_it_src; ++list_it_src;
++list_it_dst; ++list_it_dst;
@ -101,7 +103,7 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
for (auto& arg : args_) { for (auto& arg : args_) {
if (arg.type == mutator_arg.type && if (arg.type == mutator_arg.type &&
std::string(arg.key) == std::string(mutator_arg.key)) { std::string(arg.key) == std::string(mutator_arg.key)) {
GPR_ASSERT(!replaced); CHECK(!replaced);
arg.value.pointer.vtable->destroy(arg.value.pointer.p); arg.value.pointer.vtable->destroy(arg.value.pointer.p);
arg.value.pointer = mutator_arg.value.pointer; arg.value.pointer = mutator_arg.value.pointer;
replaced = true; replaced = true;
@ -130,7 +132,7 @@ void ChannelArguments::SetUserAgentPrefix(
++strings_it; ++strings_it;
if (arg.type == GRPC_ARG_STRING) { if (arg.type == GRPC_ARG_STRING) {
if (std::string(arg.key) == GRPC_ARG_PRIMARY_USER_AGENT_STRING) { if (std::string(arg.key) == GRPC_ARG_PRIMARY_USER_AGENT_STRING) {
GPR_ASSERT(arg.value.string == strings_it->c_str()); CHECK(arg.value.string == strings_it->c_str());
*(strings_it) = user_agent_prefix + " " + arg.value.string; *(strings_it) = user_agent_prefix + " " + arg.value.string;
arg.value.string = const_cast<char*>(strings_it->c_str()); arg.value.string = const_cast<char*>(strings_it->c_str());
replaced = true; replaced = true;

@ -18,6 +18,7 @@
#include <vector> #include <vector>
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
@ -83,7 +84,7 @@ struct CallbackAlternativeCQ {
gpr_time_from_millis(100, GPR_TIMESPAN))); gpr_time_from_millis(100, GPR_TIMESPAN)));
continue; continue;
} }
GPR_DEBUG_ASSERT(ev.type == GRPC_OP_COMPLETE); DCHECK(ev.type == GRPC_OP_COMPLETE);
// We can always execute the callback inline rather than // We can always execute the callback inline rather than
// pushing it to another Executor thread because this // pushing it to another Executor thread because this
// thread is definitely running on a background thread, does not // thread is definitely running on a background thread, does not
@ -169,7 +170,7 @@ CompletionQueue::CompletionQueueTLSCache::CompletionQueueTLSCache(
} }
CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache() { CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache() {
GPR_ASSERT(flushed_); CHECK(flushed_);
} }
bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) {
@ -199,7 +200,7 @@ void CompletionQueue::ReleaseCallbackAlternativeCQ(CompletionQueue* cq)
(void)cq; (void)cq;
// This accesses g_callback_alternative_cq without acquiring the mutex // This accesses g_callback_alternative_cq without acquiring the mutex
// but it's considered safe because it just reads the pointer address. // but it's considered safe because it just reads the pointer address.
GPR_DEBUG_ASSERT(cq == g_callback_alternative_cq.cq); DCHECK(cq == g_callback_alternative_cq.cq);
g_callback_alternative_cq.Unref(); g_callback_alternative_cq.Unref();
} }

@ -17,6 +17,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/credentials.h> #include <grpc/credentials.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -28,7 +30,7 @@ namespace experimental {
StaticDataCertificateProvider::StaticDataCertificateProvider( StaticDataCertificateProvider::StaticDataCertificateProvider(
const std::string& root_certificate, const std::string& root_certificate,
const std::vector<IdentityKeyCertPair>& identity_key_cert_pairs) { const std::vector<IdentityKeyCertPair>& identity_key_cert_pairs) {
GPR_ASSERT(!root_certificate.empty() || !identity_key_cert_pairs.empty()); CHECK(!root_certificate.empty() || !identity_key_cert_pairs.empty());
grpc_tls_identity_pairs* pairs_core = grpc_tls_identity_pairs_create(); grpc_tls_identity_pairs* pairs_core = grpc_tls_identity_pairs_create();
for (const IdentityKeyCertPair& pair : identity_key_cert_pairs) { for (const IdentityKeyCertPair& pair : identity_key_cert_pairs) {
grpc_tls_identity_pairs_add_pair(pairs_core, pair.private_key.c_str(), grpc_tls_identity_pairs_add_pair(pairs_core, pair.private_key.c_str(),
@ -36,7 +38,7 @@ StaticDataCertificateProvider::StaticDataCertificateProvider(
} }
c_provider_ = grpc_tls_certificate_provider_static_data_create( c_provider_ = grpc_tls_certificate_provider_static_data_create(
root_certificate.c_str(), pairs_core); root_certificate.c_str(), pairs_core);
GPR_ASSERT(c_provider_ != nullptr); CHECK_NE(c_provider_, nullptr);
}; };
StaticDataCertificateProvider::~StaticDataCertificateProvider() { StaticDataCertificateProvider::~StaticDataCertificateProvider() {
@ -50,7 +52,7 @@ FileWatcherCertificateProvider::FileWatcherCertificateProvider(
c_provider_ = grpc_tls_certificate_provider_file_watcher_create( c_provider_ = grpc_tls_certificate_provider_file_watcher_create(
private_key_path.c_str(), identity_certificate_path.c_str(), private_key_path.c_str(), identity_certificate_path.c_str(),
root_cert_path.c_str(), refresh_interval_sec); root_cert_path.c_str(), refresh_interval_sec);
GPR_ASSERT(c_provider_ != nullptr); CHECK_NE(c_provider_, nullptr);
}; };
FileWatcherCertificateProvider::~FileWatcherCertificateProvider() { FileWatcherCertificateProvider::~FileWatcherCertificateProvider() {

@ -22,6 +22,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/credentials.h> #include <grpc/credentials.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/status.h> #include <grpc/status.h>
@ -39,7 +41,7 @@ namespace experimental {
TlsCustomVerificationCheckRequest::TlsCustomVerificationCheckRequest( TlsCustomVerificationCheckRequest::TlsCustomVerificationCheckRequest(
grpc_tls_custom_verification_check_request* request) grpc_tls_custom_verification_check_request* request)
: c_request_(request) { : c_request_(request) {
GPR_ASSERT(c_request_ != nullptr); CHECK_NE(c_request_, nullptr);
} }
grpc::string_ref TlsCustomVerificationCheckRequest::target_name() const { grpc::string_ref TlsCustomVerificationCheckRequest::target_name() const {
@ -119,8 +121,8 @@ CertificateVerifier::~CertificateVerifier() {
bool CertificateVerifier::Verify(TlsCustomVerificationCheckRequest* request, bool CertificateVerifier::Verify(TlsCustomVerificationCheckRequest* request,
std::function<void(grpc::Status)> callback, std::function<void(grpc::Status)> callback,
grpc::Status* sync_status) { grpc::Status* sync_status) {
GPR_ASSERT(request != nullptr); CHECK_NE(request, nullptr);
GPR_ASSERT(request->c_request() != nullptr); CHECK_NE(request->c_request(), nullptr);
{ {
internal::MutexLock lock(&mu_); internal::MutexLock lock(&mu_);
request_map_.emplace(request->c_request(), std::move(callback)); request_map_.emplace(request->c_request(), std::move(callback));
@ -143,8 +145,8 @@ bool CertificateVerifier::Verify(TlsCustomVerificationCheckRequest* request,
} }
void CertificateVerifier::Cancel(TlsCustomVerificationCheckRequest* request) { void CertificateVerifier::Cancel(TlsCustomVerificationCheckRequest* request) {
GPR_ASSERT(request != nullptr); CHECK_NE(request, nullptr);
GPR_ASSERT(request->c_request() != nullptr); CHECK_NE(request->c_request(), nullptr);
grpc_tls_certificate_verifier_cancel(verifier_, request->c_request()); grpc_tls_certificate_verifier_cancel(verifier_, request->c_request());
} }
@ -191,7 +193,7 @@ int ExternalCertificateVerifier::VerifyInCoreExternalVerifier(
internal::MutexLock lock(&self->mu_); internal::MutexLock lock(&self->mu_);
auto pair = self->request_map_.emplace( auto pair = self->request_map_.emplace(
request, AsyncRequestState(callback, callback_arg, request)); request, AsyncRequestState(callback, callback_arg, request));
GPR_ASSERT(pair.second); CHECK(pair.second);
cpp_request = &pair.first->second.cpp_request; cpp_request = &pair.first->second.cpp_request;
} }
grpc::Status sync_current_verifier_status; grpc::Status sync_current_verifier_status;

@ -19,6 +19,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "absl/log/check.h"
#include <grpc/credentials.h> #include <grpc/credentials.h>
#include <grpc/grpc_crl_provider.h> #include <grpc/grpc_crl_provider.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
@ -104,13 +106,13 @@ void TlsCredentialsOptions::set_certificate_verifier(
void TlsCredentialsOptions::set_min_tls_version(grpc_tls_version tls_version) { void TlsCredentialsOptions::set_min_tls_version(grpc_tls_version tls_version) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_min_tls_version(options, tls_version); grpc_tls_credentials_options_set_min_tls_version(options, tls_version);
} }
void TlsCredentialsOptions::set_max_tls_version(grpc_tls_version tls_version) { void TlsCredentialsOptions::set_max_tls_version(grpc_tls_version tls_version) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_max_tls_version(options, tls_version); grpc_tls_credentials_options_set_max_tls_version(options, tls_version);
} }
@ -121,14 +123,14 @@ grpc_tls_credentials_options* TlsCredentialsOptions::c_credentials_options()
void TlsCredentialsOptions::set_check_call_host(bool check_call_host) { void TlsCredentialsOptions::set_check_call_host(bool check_call_host) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_check_call_host(options, check_call_host); grpc_tls_credentials_options_set_check_call_host(options, check_call_host);
} }
void TlsChannelCredentialsOptions::set_verify_server_certs( void TlsChannelCredentialsOptions::set_verify_server_certs(
bool verify_server_certs) { bool verify_server_certs) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_verify_server_cert(options, grpc_tls_credentials_options_set_verify_server_cert(options,
verify_server_certs); verify_server_certs);
} }
@ -136,7 +138,7 @@ void TlsChannelCredentialsOptions::set_verify_server_certs(
void TlsServerCredentialsOptions::set_cert_request_type( void TlsServerCredentialsOptions::set_cert_request_type(
grpc_ssl_client_certificate_request_type cert_request_type) { grpc_ssl_client_certificate_request_type cert_request_type) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_cert_request_type(options, grpc_tls_credentials_options_set_cert_request_type(options,
cert_request_type); cert_request_type);
} }
@ -144,7 +146,7 @@ void TlsServerCredentialsOptions::set_cert_request_type(
void TlsServerCredentialsOptions::set_send_client_ca_list( void TlsServerCredentialsOptions::set_send_client_ca_list(
bool send_client_ca_list) { bool send_client_ca_list) {
grpc_tls_credentials_options* options = mutable_c_credentials_options(); grpc_tls_credentials_options* options = mutable_c_credentials_options();
GPR_ASSERT(options != nullptr); CHECK_NE(options, nullptr);
grpc_tls_credentials_options_set_send_client_ca_list(options, grpc_tls_credentials_options_set_send_client_ca_list(options,
send_client_ca_list); send_client_ca_list);
} }

@ -41,6 +41,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/log:check",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
"absl/types:optional", "absl/types:optional",

@ -25,6 +25,7 @@
#include <cstdint> #include <cstdint>
#include <unordered_map> #include <unordered_map>
#include "absl/log/check.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
@ -263,7 +264,7 @@ NextFromAttributeList(absl::Span<const RemoteAttribute> attributes,
size_t start_index, size_t curr, size_t start_index, size_t curr,
google_protobuf_Struct* decoded_metadata, google_protobuf_Struct* decoded_metadata,
upb_Arena* arena) { upb_Arena* arena) {
GPR_DEBUG_ASSERT(curr >= start_index); DCHECK_GE(curr, start_index);
const size_t index = curr - start_index; const size_t index = curr - start_index;
if (index >= attributes.size()) return absl::nullopt; if (index >= attributes.size()) return absl::nullopt;
const auto& attribute = attributes[index]; const auto& attribute = attributes[index];

@ -28,6 +28,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/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -106,9 +107,8 @@ OpenCensusClientFilter::MakeCallPromise(
call_context, path != nullptr ? path->Ref() : grpc_core::Slice(), call_context, path != nullptr ? path->Ref() : grpc_core::Slice(),
grpc_core::GetContext<grpc_core::Arena>(), grpc_core::GetContext<grpc_core::Arena>(),
OpenCensusTracingEnabled() && tracing_enabled_); OpenCensusTracingEnabled() && tracing_enabled_);
GPR_DEBUG_ASSERT( DCHECK(call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value ==
call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value == nullptr);
nullptr);
call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = tracer; call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = tracer;
call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].destroy = nullptr; call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].destroy = nullptr;
return next_promise_factory(std::move(call_args)); return next_promise_factory(std::move(call_args));
@ -407,7 +407,7 @@ void OpenCensusCallTracer::RecordApiLatency(absl::Duration api_latency,
CensusContext OpenCensusCallTracer::CreateCensusContextForCallAttempt() { CensusContext OpenCensusCallTracer::CreateCensusContextForCallAttempt() {
if (!tracing_enabled_) return CensusContext(context_.tags()); if (!tracing_enabled_) return CensusContext(context_.tags());
GPR_DEBUG_ASSERT(context_.Context().IsValid()); DCHECK(context_.Context().IsValid());
auto context = CensusContext(absl::StrCat("Attempt.", method_), auto context = CensusContext(absl::StrCat("Attempt.", method_),
&(context_.Span()), context_.tags()); &(context_.Span()), context_.tags());
grpc::internal::OpenCensusRegistry::Get() grpc::internal::OpenCensusRegistry::Get()

@ -156,6 +156,7 @@ grpc_cc_library(
"absl/base:core_headers", "absl/base:core_headers",
"absl/container:flat_hash_map", "absl/container:flat_hash_map",
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/types:optional", "absl/types:optional",

@ -22,6 +22,7 @@
#include <utility> #include <utility>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.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/types/optional.h" #include "absl/types/optional.h"
@ -245,7 +246,7 @@ class EnvironmentAutoDetectHelper
void FetchMetadataServerAttributesAsynchronouslyLocked() void FetchMetadataServerAttributesAsynchronouslyLocked()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
GPR_ASSERT(!attributes_to_fetch_.empty()); CHECK(!attributes_to_fetch_.empty());
for (auto& element : attributes_to_fetch_) { for (auto& element : attributes_to_fetch_) {
queries_.push_back(grpc_core::MakeOrphanable<grpc_core::MetadataQuery>( queries_.push_back(grpc_core::MakeOrphanable<grpc_core::MetadataQuery>(
element.first, &pollent_, element.first, &pollent_,
@ -330,7 +331,9 @@ EnvironmentAutoDetect* g_autodetect = nullptr;
} // namespace } // namespace
void EnvironmentAutoDetect::Create(std::string project_id) { void EnvironmentAutoDetect::Create(std::string project_id) {
GPR_ASSERT(g_autodetect == nullptr && !project_id.empty()); CHECK_EQ(g_autodetect, nullptr);
CHECK(!project_id.empty());
g_autodetect = new EnvironmentAutoDetect(project_id); g_autodetect = new EnvironmentAutoDetect(project_id);
} }
@ -338,7 +341,7 @@ EnvironmentAutoDetect& EnvironmentAutoDetect::Get() { return *g_autodetect; }
EnvironmentAutoDetect::EnvironmentAutoDetect(std::string project_id) EnvironmentAutoDetect::EnvironmentAutoDetect(std::string project_id)
: project_id_(std::move(project_id)) { : project_id_(std::move(project_id)) {
GPR_ASSERT(!project_id_.empty()); CHECK(!project_id_.empty());
} }
void EnvironmentAutoDetect::NotifyOnDone(absl::AnyInvocable<void()> callback) { void EnvironmentAutoDetect::NotifyOnDone(absl::AnyInvocable<void()> callback) {

@ -47,6 +47,7 @@ grpc_cc_library(
"absl/container:flat_hash_map", "absl/container:flat_hash_map",
"absl/container:flat_hash_set", "absl/container:flat_hash_set",
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",

@ -23,6 +23,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "absl/types/span.h" #include "absl/types/span.h"
@ -101,10 +102,9 @@ class OpenTelemetryPlugin::KeyValueIterable
} }
// Add per-call optional labels // Add per-call optional labels
if (!optional_labels_.empty()) { if (!optional_labels_.empty()) {
GPR_ASSERT( CHECK(optional_labels_.size() ==
optional_labels_.size() == static_cast<size_t>(grpc_core::ClientCallTracer::CallAttemptTracer::
static_cast<size_t>(grpc_core::ClientCallTracer::CallAttemptTracer:: OptionalLabelKey::kSize));
OptionalLabelKey::kSize));
for (size_t i = 0; i < optional_labels_.size(); ++i) { for (size_t i = 0; i < optional_labels_.size(); ++i) {
if (!otel_plugin_->per_call_optional_label_bits_.test(i)) { if (!otel_plugin_->per_call_optional_label_bits_.test(i)) {
continue; continue;

@ -27,6 +27,7 @@
#include <utility> #include <utility>
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -209,7 +210,7 @@ OpenTelemetryPlugin::ClientCallTracer::CallAttemptTracer::StartNewTcpTrace() {
void OpenTelemetryPlugin::ClientCallTracer::CallAttemptTracer::SetOptionalLabel( void OpenTelemetryPlugin::ClientCallTracer::CallAttemptTracer::SetOptionalLabel(
OptionalLabelKey key, grpc_core::RefCountedStringValue value) { OptionalLabelKey key, grpc_core::RefCountedStringValue value) {
GPR_ASSERT(key < OptionalLabelKey::kSize); CHECK(key < OptionalLabelKey::kSize);
optional_labels_[static_cast<size_t>(key)] = std::move(value); optional_labels_[static_cast<size_t>(key)] = std::move(value);
} }

@ -22,6 +22,7 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter.h"
#include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/meter_provider.h"
#include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/metrics/sync_instruments.h"
@ -205,7 +206,7 @@ OpenTelemetryPluginBuilderImpl::SetServerSelector(
OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::AddPluginOption( OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::AddPluginOption(
std::unique_ptr<InternalOpenTelemetryPluginOption> option) { std::unique_ptr<InternalOpenTelemetryPluginOption> option) {
// We allow a limit of 64 plugin options to be registered at this time. // We allow a limit of 64 plugin options to be registered at this time.
GPR_ASSERT(plugin_options_.size() < 64); CHECK_LT(plugin_options_.size(), 64u);
plugin_options_.push_back(std::move(option)); plugin_options_.push_back(std::move(option));
return *this; return *this;
} }
@ -275,11 +276,11 @@ void OpenTelemetryPlugin::CallbackMetricReporter::Report(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
auto& cell = (*callback_gauge_state)->caches.at(key_); auto& cell = (*callback_gauge_state)->caches.at(key_);
std::vector<std::string> key; std::vector<std::string> key;
key.reserve(label_values.size() + key.reserve(label_values.size() +
@ -304,11 +305,11 @@ void OpenTelemetryPlugin::CallbackMetricReporter::Report(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
auto& cell = (*callback_gauge_state)->caches.at(key_); auto& cell = (*callback_gauge_state)->caches.at(key_);
std::vector<std::string> key; std::vector<std::string> key;
key.reserve(label_values.size() + key.reserve(label_values.size() +
@ -420,9 +421,9 @@ OpenTelemetryPlugin::OpenTelemetryPlugin(
"Compressed message bytes received per server call", "By"); "Compressed message bytes received per server call", "By");
} }
// Store optional label keys for per call metrics // Store optional label keys for per call metrics
GPR_ASSERT(static_cast<size_t>( CHECK(static_cast<size_t>(grpc_core::ClientCallTracer::CallAttemptTracer::
grpc_core::ClientCallTracer::CallAttemptTracer:: OptionalLabelKey::kSize) <=
OptionalLabelKey::kSize) <= kOptionalLabelsSizeLimit); kOptionalLabelsSizeLimit);
for (const auto& key : optional_label_keys) { for (const auto& key : optional_label_keys) {
auto optional_key = OptionalLabelStringToKey(key); auto optional_key = OptionalLabelStringToKey(key);
if (optional_key.has_value()) { if (optional_key.has_value()) {
@ -434,8 +435,8 @@ OpenTelemetryPlugin::OpenTelemetryPlugin(
grpc_core::GlobalInstrumentsRegistry::ForEach( grpc_core::GlobalInstrumentsRegistry::ForEach(
[&, this](const grpc_core::GlobalInstrumentsRegistry:: [&, this](const grpc_core::GlobalInstrumentsRegistry::
GlobalInstrumentDescriptor& descriptor) { GlobalInstrumentDescriptor& descriptor) {
GPR_ASSERT(descriptor.optional_label_keys.size() <= CHECK(descriptor.optional_label_keys.size() <=
kOptionalLabelsSizeLimit); kOptionalLabelsSizeLimit);
if (instruments_data_.size() < descriptor.index + 1) { if (instruments_data_.size() < descriptor.index + 1) {
instruments_data_.resize(descriptor.index + 1); instruments_data_.resize(descriptor.index + 1);
} }
@ -590,13 +591,13 @@ void OpenTelemetryPlugin::AddCounter(
// This instrument is disabled. // This instrument is disabled.
return; return;
} }
GPR_ASSERT(absl::holds_alternative< CHECK(absl::holds_alternative<
std::unique_ptr<opentelemetry::metrics::Counter<uint64_t>>>( std::unique_ptr<opentelemetry::metrics::Counter<uint64_t>>>(
instrument_data.instrument)); instrument_data.instrument));
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
absl::get<std::unique_ptr<opentelemetry::metrics::Counter<uint64_t>>>( absl::get<std::unique_ptr<opentelemetry::metrics::Counter<uint64_t>>>(
instrument_data.instrument) instrument_data.instrument)
->Add(value, NPCMetricsKeyValueIterable( ->Add(value, NPCMetricsKeyValueIterable(
@ -614,13 +615,13 @@ void OpenTelemetryPlugin::AddCounter(
// This instrument is disabled. // This instrument is disabled.
return; return;
} }
GPR_ASSERT(absl::holds_alternative< CHECK(absl::holds_alternative<
std::unique_ptr<opentelemetry::metrics::Counter<double>>>( std::unique_ptr<opentelemetry::metrics::Counter<double>>>(
instrument_data.instrument)); instrument_data.instrument));
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
absl::get<std::unique_ptr<opentelemetry::metrics::Counter<double>>>( absl::get<std::unique_ptr<opentelemetry::metrics::Counter<double>>>(
instrument_data.instrument) instrument_data.instrument)
->Add(value, NPCMetricsKeyValueIterable( ->Add(value, NPCMetricsKeyValueIterable(
@ -638,13 +639,13 @@ void OpenTelemetryPlugin::RecordHistogram(
// This instrument is disabled. // This instrument is disabled.
return; return;
} }
GPR_ASSERT(absl::holds_alternative< CHECK(absl::holds_alternative<
std::unique_ptr<opentelemetry::metrics::Histogram<uint64_t>>>( std::unique_ptr<opentelemetry::metrics::Histogram<uint64_t>>>(
instrument_data.instrument)); instrument_data.instrument));
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
absl::get<std::unique_ptr<opentelemetry::metrics::Histogram<uint64_t>>>( absl::get<std::unique_ptr<opentelemetry::metrics::Histogram<uint64_t>>>(
instrument_data.instrument) instrument_data.instrument)
->Record(value, ->Record(value,
@ -664,13 +665,13 @@ void OpenTelemetryPlugin::RecordHistogram(
// This instrument is disabled. // This instrument is disabled.
return; return;
} }
GPR_ASSERT(absl::holds_alternative< CHECK(absl::holds_alternative<
std::unique_ptr<opentelemetry::metrics::Histogram<double>>>( std::unique_ptr<opentelemetry::metrics::Histogram<double>>>(
instrument_data.instrument)); instrument_data.instrument));
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor(handle);
GPR_ASSERT(descriptor.label_keys.size() == label_values.size()); CHECK(descriptor.label_keys.size() == label_values.size());
GPR_ASSERT(descriptor.optional_label_keys.size() == optional_values.size()); CHECK(descriptor.optional_label_keys.size() == optional_values.size());
absl::get<std::unique_ptr<opentelemetry::metrics::Histogram<double>>>( absl::get<std::unique_ptr<opentelemetry::metrics::Histogram<double>>>(
instrument_data.instrument) instrument_data.instrument)
->Record(value, ->Record(value,
@ -702,7 +703,7 @@ void OpenTelemetryPlugin::AddCallback(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
(*callback_gauge_state) (*callback_gauge_state)
->caches.emplace(callback, ->caches.emplace(callback,
CallbackGaugeState<int64_t>::Cache{}); CallbackGaugeState<int64_t>::Cache{});
@ -722,7 +723,7 @@ void OpenTelemetryPlugin::AddCallback(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
(*callback_gauge_state) (*callback_gauge_state)
->caches.emplace(callback, CallbackGaugeState<double>::Cache{}); ->caches.emplace(callback, CallbackGaugeState<double>::Cache{});
if (!std::exchange((*callback_gauge_state)->ot_callback_registered, if (!std::exchange((*callback_gauge_state)->ot_callback_registered,
@ -770,9 +771,9 @@ void OpenTelemetryPlugin::RemoveCallback(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<int64_t>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
GPR_ASSERT((*callback_gauge_state)->ot_callback_registered); CHECK((*callback_gauge_state)->ot_callback_registered);
GPR_ASSERT((*callback_gauge_state)->caches.erase(callback) == 1); CHECK_EQ((*callback_gauge_state)->caches.erase(callback), 1u);
if ((*callback_gauge_state)->caches.empty()) { if ((*callback_gauge_state)->caches.empty()) {
gauges_that_need_to_remove_callback.push_back( gauges_that_need_to_remove_callback.push_back(
callback_gauge_state->get()); callback_gauge_state->get());
@ -789,9 +790,9 @@ void OpenTelemetryPlugin::RemoveCallback(
auto* callback_gauge_state = auto* callback_gauge_state =
absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>( absl::get_if<std::unique_ptr<CallbackGaugeState<double>>>(
&instrument_data.instrument); &instrument_data.instrument);
GPR_ASSERT(callback_gauge_state != nullptr); CHECK_NE(callback_gauge_state, nullptr);
GPR_ASSERT((*callback_gauge_state)->ot_callback_registered); CHECK((*callback_gauge_state)->ot_callback_registered);
GPR_ASSERT((*callback_gauge_state)->caches.erase(callback) == 1); CHECK_EQ((*callback_gauge_state)->caches.erase(callback), 1u);
if ((*callback_gauge_state)->caches.empty()) { if ((*callback_gauge_state)->caches.empty()) {
gauges_that_need_to_remove_callback.push_back( gauges_that_need_to_remove_callback.push_back(
callback_gauge_state->get()); callback_gauge_state->get());
@ -822,8 +823,8 @@ void OpenTelemetryPlugin::CallbackGaugeState<ValueType>::Observe(
const auto& descriptor = const auto& descriptor =
grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor({id}); grpc_core::GlobalInstrumentsRegistry::GetInstrumentDescriptor({id});
for (const auto& pair : cache) { for (const auto& pair : cache) {
GPR_ASSERT(pair.first.size() <= (descriptor.label_keys.size() + CHECK(pair.first.size() <= (descriptor.label_keys.size() +
descriptor.optional_label_keys.size())); descriptor.optional_label_keys.size()));
auto& instrument_data = ot_plugin->instruments_data_.at(id); auto& instrument_data = ot_plugin->instruments_data_.at(id);
opentelemetry::nostd::get<opentelemetry::nostd::shared_ptr< opentelemetry::nostd::get<opentelemetry::nostd::shared_ptr<
opentelemetry::metrics::ObserverResultT<ValueType>>>(result) opentelemetry::metrics::ObserverResultT<ValueType>>>(result)
@ -852,8 +853,7 @@ void OpenTelemetryPlugin::CallbackGaugeState<ValueType>::CallbackGaugeCallback(
auto* registered_metric_callback = elem.first; auto* registered_metric_callback = elem.first;
auto iter = callback_gauge_state->ot_plugin->callback_timestamps_.find( auto iter = callback_gauge_state->ot_plugin->callback_timestamps_.find(
registered_metric_callback); registered_metric_callback);
GPR_ASSERT(iter != CHECK(iter != callback_gauge_state->ot_plugin->callback_timestamps_.end());
callback_gauge_state->ot_plugin->callback_timestamps_.end());
if (now - iter->second < registered_metric_callback->min_interval()) { if (now - iter->second < registered_metric_callback->min_interval()) {
// Use cached value. // Use cached value.
callback_gauge_state->Observe(result, elem.second); callback_gauge_state->Observe(result, elem.second);

@ -21,6 +21,8 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/server_builder.h> #include <grpcpp/server_builder.h>
#include <grpcpp/support/byte_buffer.h> #include <grpcpp/support/byte_buffer.h>
@ -49,14 +51,14 @@ ExternalConnectionAcceptorImpl::ExternalConnectionAcceptorImpl(
ServerBuilder::experimental_type::ExternalConnectionType type, ServerBuilder::experimental_type::ExternalConnectionType type,
std::shared_ptr<ServerCredentials> creds) std::shared_ptr<ServerCredentials> creds)
: name_(name), creds_(std::move(creds)) { : name_(name), creds_(std::move(creds)) {
GPR_ASSERT(type == CHECK(type ==
ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD); ServerBuilder::experimental_type::ExternalConnectionType::FROM_FD);
} }
std::unique_ptr<experimental::ExternalConnectionAcceptor> std::unique_ptr<experimental::ExternalConnectionAcceptor>
ExternalConnectionAcceptorImpl::GetAcceptor() { ExternalConnectionAcceptorImpl::GetAcceptor() {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
GPR_ASSERT(!has_acceptor_); CHECK(!has_acceptor_);
has_acceptor_ = true; has_acceptor_ = true;
return std::unique_ptr<experimental::ExternalConnectionAcceptor>( return std::unique_ptr<experimental::ExternalConnectionAcceptor>(
new AcceptorWrapper(shared_from_this())); new AcceptorWrapper(shared_from_this()));
@ -85,9 +87,9 @@ void ExternalConnectionAcceptorImpl::Shutdown() {
void ExternalConnectionAcceptorImpl::Start() { void ExternalConnectionAcceptorImpl::Start() {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
GPR_ASSERT(!started_); CHECK(!started_);
GPR_ASSERT(has_acceptor_); CHECK(has_acceptor_);
GPR_ASSERT(!shutdown_); CHECK(!shutdown_);
started_ = true; started_ = true;
} }

@ -23,6 +23,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "upb/base/string_view.h" #include "upb/base/string_view.h"
#include "upb/mem/arena.hpp" #include "upb/mem/arena.hpp"
@ -109,7 +110,7 @@ void DefaultHealthCheckService::UnregisterWatch(
DefaultHealthCheckService::HealthCheckServiceImpl* DefaultHealthCheckService::HealthCheckServiceImpl*
DefaultHealthCheckService::GetHealthCheckService() { DefaultHealthCheckService::GetHealthCheckService() {
GPR_ASSERT(impl_ == nullptr); CHECK(impl_ == nullptr);
impl_ = std::make_unique<HealthCheckServiceImpl>(this); impl_ = std::make_unique<HealthCheckServiceImpl>(this);
return impl_.get(); return impl_.get();
} }

@ -26,6 +26,8 @@
#include <set> #include <set>
#include <unordered_map> #include <unordered_map>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -74,7 +76,7 @@ std::set<V> UnorderedMapOfSetExtract(std::unordered_map<K, std::set<V>>& map,
// From a non-empty container, returns a pointer to a random element. // From a non-empty container, returns a pointer to a random element.
template <typename C> template <typename C>
const typename C::value_type* RandomElement(const C& container) { const typename C::value_type* RandomElement(const C& container) {
GPR_ASSERT(!container.empty()); CHECK(!container.empty());
auto it = container.begin(); auto it = container.begin();
std::advance(it, std::rand() % container.size()); std::advance(it, std::rand() % container.size());
return &(*it); return &(*it);
@ -85,12 +87,12 @@ const typename C::value_type* RandomElement(const C& container) {
LoadRecordKey::LoadRecordKey(const std::string& client_ip_and_token, LoadRecordKey::LoadRecordKey(const std::string& client_ip_and_token,
std::string user_id) std::string user_id)
: user_id_(std::move(user_id)) { : user_id_(std::move(user_id)) {
GPR_ASSERT(client_ip_and_token.size() >= 2); CHECK_GE(client_ip_and_token.size(), 2u);
int ip_hex_size; int ip_hex_size;
GPR_ASSERT(sscanf(client_ip_and_token.substr(0, 2).c_str(), "%d", CHECK(sscanf(client_ip_and_token.substr(0, 2).c_str(), "%d", &ip_hex_size) ==
&ip_hex_size) == 1); 1);
GPR_ASSERT(ip_hex_size == 0 || ip_hex_size == kIpv4AddressLength || CHECK(ip_hex_size == 0 || ip_hex_size == kIpv4AddressLength ||
ip_hex_size == kIpv6AddressLength); ip_hex_size == kIpv6AddressLength);
size_t cur_pos = 2; size_t cur_pos = 2;
client_ip_hex_ = client_ip_and_token.substr(cur_pos, ip_hex_size); client_ip_hex_ = client_ip_and_token.substr(cur_pos, ip_hex_size);
cur_pos += ip_hex_size; cur_pos += ip_hex_size;
@ -159,9 +161,9 @@ void PerBalancerStore::MergeRow(const LoadRecordKey& key,
// We always keep track of num_calls_in_progress_, so that when this // We always keep track of num_calls_in_progress_, so that when this
// store is resumed, we still have a correct value of // store is resumed, we still have a correct value of
// num_calls_in_progress_. // num_calls_in_progress_.
GPR_ASSERT(static_cast<int64_t>(num_calls_in_progress_) + CHECK(static_cast<int64_t>(num_calls_in_progress_) +
value.GetNumCallsInProgressDelta() >= value.GetNumCallsInProgressDelta() >=
0); 0);
num_calls_in_progress_ += value.GetNumCallsInProgressDelta(); num_calls_in_progress_ += value.GetNumCallsInProgressDelta();
} }
@ -177,14 +179,14 @@ void PerBalancerStore::Resume() {
} }
uint64_t PerBalancerStore::GetNumCallsInProgressForReport() { uint64_t PerBalancerStore::GetNumCallsInProgressForReport() {
GPR_ASSERT(!suspended_); CHECK(!suspended_);
last_reported_num_calls_in_progress_ = num_calls_in_progress_; last_reported_num_calls_in_progress_ = num_calls_in_progress_;
return num_calls_in_progress_; return num_calls_in_progress_;
} }
void PerHostStore::ReportStreamCreated(const std::string& lb_id, void PerHostStore::ReportStreamCreated(const std::string& lb_id,
const std::string& load_key) { const std::string& load_key) {
GPR_ASSERT(lb_id != kInvalidLbId); CHECK(lb_id != kInvalidLbId);
SetUpForNewLbId(lb_id, load_key); SetUpForNewLbId(lb_id, load_key);
// Prior to this one, there was no load balancer receiving report, so we may // Prior to this one, there was no load balancer receiving report, so we may
// have unassigned orphaned stores to assign to this new balancer. // have unassigned orphaned stores to assign to this new balancer.
@ -210,11 +212,11 @@ void PerHostStore::ReportStreamCreated(const std::string& lb_id,
void PerHostStore::ReportStreamClosed(const std::string& lb_id) { void PerHostStore::ReportStreamClosed(const std::string& lb_id) {
auto it_store_for_gone_lb = per_balancer_stores_.find(lb_id); auto it_store_for_gone_lb = per_balancer_stores_.find(lb_id);
GPR_ASSERT(it_store_for_gone_lb != per_balancer_stores_.end()); CHECK(it_store_for_gone_lb != per_balancer_stores_.end());
// Remove this closed stream from our records. // Remove this closed stream from our records.
GPR_ASSERT(UnorderedMapOfSetEraseKeyValue( CHECK(UnorderedMapOfSetEraseKeyValue(load_key_to_receiving_lb_ids_,
load_key_to_receiving_lb_ids_, it_store_for_gone_lb->second->load_key(), it_store_for_gone_lb->second->load_key(),
lb_id)); lb_id));
std::set<PerBalancerStore*> orphaned_stores = std::set<PerBalancerStore*> orphaned_stores =
UnorderedMapOfSetExtract(assigned_stores_, lb_id); UnorderedMapOfSetExtract(assigned_stores_, lb_id);
// The stores that were assigned to this balancer are orphaned now. They // The stores that were assigned to this balancer are orphaned now. They
@ -256,7 +258,7 @@ const std::set<PerBalancerStore*>* PerHostStore::GetAssignedStores(
void PerHostStore::AssignOrphanedStore(PerBalancerStore* orphaned_store, void PerHostStore::AssignOrphanedStore(PerBalancerStore* orphaned_store,
const std::string& new_receiver) { const std::string& new_receiver) {
auto it = assigned_stores_.find(new_receiver); auto it = assigned_stores_.find(new_receiver);
GPR_ASSERT(it != assigned_stores_.end()); CHECK(it != assigned_stores_.end());
it->second.insert(orphaned_store); it->second.insert(orphaned_store);
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[PerHostStore %p] Re-assigned orphaned store (%p) with original LB" "[PerHostStore %p] Re-assigned orphaned store (%p) with original LB"
@ -269,8 +271,8 @@ void PerHostStore::SetUpForNewLbId(const std::string& lb_id,
const std::string& load_key) { const std::string& load_key) {
// The top-level caller (i.e., LoadReportService) should guarantee the // The top-level caller (i.e., LoadReportService) should guarantee the
// lb_id is unique for each reporting stream. // lb_id is unique for each reporting stream.
GPR_ASSERT(per_balancer_stores_.find(lb_id) == per_balancer_stores_.end()); CHECK(per_balancer_stores_.find(lb_id) == per_balancer_stores_.end());
GPR_ASSERT(assigned_stores_.find(lb_id) == assigned_stores_.end()); CHECK(assigned_stores_.find(lb_id) == assigned_stores_.end());
load_key_to_receiving_lb_ids_[load_key].insert(lb_id); load_key_to_receiving_lb_ids_[load_key].insert(lb_id);
std::unique_ptr<PerBalancerStore> per_balancer_store( std::unique_ptr<PerBalancerStore> per_balancer_store(
new PerBalancerStore(lb_id, load_key)); new PerBalancerStore(lb_id, load_key));
@ -335,7 +337,7 @@ void LoadDataStore::ReportStreamCreated(const std::string& hostname,
void LoadDataStore::ReportStreamClosed(const std::string& hostname, void LoadDataStore::ReportStreamClosed(const std::string& hostname,
const std::string& lb_id) { const std::string& lb_id) {
auto it_per_host_store = per_host_stores_.find(hostname); auto it_per_host_store = per_host_stores_.find(hostname);
GPR_ASSERT(it_per_host_store != per_host_stores_.end()); CHECK(it_per_host_store != per_host_stores_.end());
it_per_host_store->second.ReportStreamClosed(lb_id); it_per_host_store->second.ReportStreamClosed(lb_id);
} }

@ -27,6 +27,7 @@
#include <set> #include <set>
#include <tuple> #include <tuple>
#include "absl/log/check.h"
#include "opencensus/tags/tag_key.h" #include "opencensus/tags/tag_key.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -168,11 +169,10 @@ double CensusViewProvider::GetRelatedViewDataRowDouble(
const ViewDataMap& view_data_map, const char* view_name, const ViewDataMap& view_data_map, const char* view_name,
size_t view_name_len, const std::vector<std::string>& tag_values) { size_t view_name_len, const std::vector<std::string>& tag_values) {
auto it_vd = view_data_map.find(std::string(view_name, view_name_len)); auto it_vd = view_data_map.find(std::string(view_name, view_name_len));
GPR_ASSERT(it_vd != view_data_map.end()); CHECK(it_vd != view_data_map.end());
GPR_ASSERT(it_vd->second.type() == CHECK(it_vd->second.type() == ::opencensus::stats::ViewData::Type::kDouble);
::opencensus::stats::ViewData::Type::kDouble);
auto it_row = it_vd->second.double_data().find(tag_values); auto it_row = it_vd->second.double_data().find(tag_values);
GPR_ASSERT(it_row != it_vd->second.double_data().end()); CHECK(it_row != it_vd->second.double_data().end());
return it_row->second; return it_row->second;
} }
@ -180,12 +180,11 @@ uint64_t CensusViewProvider::GetRelatedViewDataRowInt(
const ViewDataMap& view_data_map, const char* view_name, const ViewDataMap& view_data_map, const char* view_name,
size_t view_name_len, const std::vector<std::string>& tag_values) { size_t view_name_len, const std::vector<std::string>& tag_values) {
auto it_vd = view_data_map.find(std::string(view_name, view_name_len)); auto it_vd = view_data_map.find(std::string(view_name, view_name_len));
GPR_ASSERT(it_vd != view_data_map.end()); CHECK(it_vd != view_data_map.end());
GPR_ASSERT(it_vd->second.type() == CHECK(it_vd->second.type() == ::opencensus::stats::ViewData::Type::kInt64);
::opencensus::stats::ViewData::Type::kInt64);
auto it_row = it_vd->second.int_data().find(tag_values); auto it_row = it_vd->second.int_data().find(tag_values);
GPR_ASSERT(it_row != it_vd->second.int_data().end()); CHECK(it_row != it_vd->second.int_data().end());
GPR_ASSERT(it_row->second >= 0); CHECK_GE(it_row->second, 0);
return it_row->second; return it_row->second;
} }
@ -230,7 +229,7 @@ std::string LoadReporter::GenerateLbId() {
} }
int64_t lb_id = next_lb_id_++; int64_t lb_id = next_lb_id_++;
// Overflow should never happen. // Overflow should never happen.
GPR_ASSERT(lb_id >= 0); CHECK_GE(lb_id, 0);
// Convert to padded hex string for a 32-bit LB ID. E.g, "0000ca5b". // Convert to padded hex string for a 32-bit LB ID. E.g, "0000ca5b".
char buf[kLbIdLength + 1]; char buf[kLbIdLength + 1];
snprintf(buf, sizeof(buf), "%08" PRIx64, lb_id); snprintf(buf, sizeof(buf), "%08" PRIx64, lb_id);
@ -299,11 +298,11 @@ LoadReporter::GenerateLoads(const std::string& hostname,
const std::string& lb_id) { const std::string& lb_id) {
grpc_core::MutexLock lock(&store_mu_); grpc_core::MutexLock lock(&store_mu_);
auto assigned_stores = load_data_store_.GetAssignedStores(hostname, lb_id); auto assigned_stores = load_data_store_.GetAssignedStores(hostname, lb_id);
GPR_ASSERT(assigned_stores != nullptr); CHECK_NE(assigned_stores, nullptr);
GPR_ASSERT(!assigned_stores->empty()); CHECK(!assigned_stores->empty());
::google::protobuf::RepeatedPtrField<grpc::lb::v1::Load> loads; ::google::protobuf::RepeatedPtrField<grpc::lb::v1::Load> loads;
for (PerBalancerStore* per_balancer_store : *assigned_stores) { for (PerBalancerStore* per_balancer_store : *assigned_stores) {
GPR_ASSERT(!per_balancer_store->IsSuspended()); CHECK(!per_balancer_store->IsSuspended());
if (!per_balancer_store->load_record_map().empty()) { if (!per_balancer_store->load_record_map().empty()) {
for (const auto& p : per_balancer_store->load_record_map()) { for (const auto& p : per_balancer_store->load_record_map()) {
const auto& key = p.first; const auto& key = p.first;

@ -22,6 +22,8 @@
#include <google/protobuf/repeated_ptr_field.h> #include <google/protobuf/repeated_ptr_field.h>
#include "absl/log/check.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <grpcpp/support/status.h> #include <grpcpp/support/status.h>
@ -34,8 +36,8 @@ namespace grpc {
namespace load_reporter { namespace load_reporter {
void LoadReporterAsyncServiceImpl::CallableTag::Run(bool ok) { void LoadReporterAsyncServiceImpl::CallableTag::Run(bool ok) {
GPR_ASSERT(handler_function_ != nullptr); CHECK(handler_function_ != nullptr);
GPR_ASSERT(handler_ != nullptr); CHECK_NE(handler_, nullptr);
handler_function_(std::move(handler_), ok); handler_function_(std::move(handler_), ok);
} }
@ -109,7 +111,7 @@ void LoadReporterAsyncServiceImpl::Work(void* arg) {
while (true) { while (true) {
if (!service->cq_->Next(&tag, &ok)) { if (!service->cq_->Next(&tag, &ok)) {
// The completion queue is shutting down. // The completion queue is shutting down.
GPR_ASSERT(service->shutdown_); CHECK(service->shutdown_);
break; break;
} }
if (tag == service) { if (tag == service) {
@ -164,7 +166,7 @@ void LoadReporterAsyncServiceImpl::ReportLoadHandler::OnRequestDelivered(
// tag will not pop out if the call never starts ( // tag will not pop out if the call never starts (
// https://github.com/grpc/grpc/issues/10136). So we need to manually // https://github.com/grpc/grpc/issues/10136). So we need to manually
// release the ownership of the handler in this case. // release the ownership of the handler in this case.
GPR_ASSERT(on_done_notified_.ReleaseHandler() != nullptr); CHECK_NE(on_done_notified_.ReleaseHandler(), nullptr);
} }
if (!ok || shutdown_) { if (!ok || shutdown_) {
// The value of ok being false means that the server is shutting down. // The value of ok being false means that the server is shutting down.
@ -325,7 +327,7 @@ void LoadReporterAsyncServiceImpl::ReportLoadHandler::SendReport(
void LoadReporterAsyncServiceImpl::ReportLoadHandler::OnDoneNotified( void LoadReporterAsyncServiceImpl::ReportLoadHandler::OnDoneNotified(
std::shared_ptr<ReportLoadHandler> self, bool ok) { std::shared_ptr<ReportLoadHandler> self, bool ok) {
GPR_ASSERT(ok); CHECK(ok);
done_notified_ = true; done_notified_ = true;
if (ctx_.IsCancelled()) { if (ctx_.IsCancelled()) {
is_cancelled_ = true; is_cancelled_ = true;

@ -27,6 +27,8 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpcpp/alarm.h> #include <grpcpp/alarm.h>
@ -81,8 +83,8 @@ class LoadReporterAsyncServiceImpl
CallableTag(HandlerFunction func, CallableTag(HandlerFunction func,
std::shared_ptr<ReportLoadHandler> handler) std::shared_ptr<ReportLoadHandler> handler)
: handler_function_(std::move(func)), handler_(std::move(handler)) { : handler_function_(std::move(func)), handler_(std::move(handler)) {
GPR_ASSERT(handler_function_ != nullptr); CHECK(handler_function_ != nullptr);
GPR_ASSERT(handler_ != nullptr); CHECK_NE(handler_, nullptr);
} }
// Runs the tag. This should be called only once. The handler is no longer // Runs the tag. This should be called only once. The handler is no longer

@ -21,6 +21,7 @@
#include <utility> #include <utility>
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -71,7 +72,7 @@ class OrcaService::Reactor : public ServerWriteReactor<ByteBuffer>,
engine_(grpc_event_engine::experimental::GetDefaultEventEngine()) { engine_(grpc_event_engine::experimental::GetDefaultEventEngine()) {
// Get slice from request. // Get slice from request.
Slice slice; Slice slice;
GPR_ASSERT(request_buffer->DumpToSingleSlice(&slice).ok()); CHECK(request_buffer->DumpToSingleSlice(&slice).ok());
// Parse request proto. // Parse request proto.
upb::Arena arena; upb::Arena arena;
xds_service_orca_v3_OrcaLoadReportRequest* request = xds_service_orca_v3_OrcaLoadReportRequest* request =
@ -173,7 +174,7 @@ OrcaService::OrcaService(ServerMetricRecorder* const server_metric_recorder,
Options options) Options options)
: server_metric_recorder_(server_metric_recorder), : server_metric_recorder_(server_metric_recorder),
min_report_duration_(options.min_report_duration) { min_report_duration_(options.min_report_duration) {
GPR_ASSERT(server_metric_recorder_ != nullptr); CHECK_NE(server_metric_recorder_, nullptr);
AddMethod(new internal::RpcServiceMethod( AddMethod(new internal::RpcServiceMethod(
"/xds.service.orca.v3.OpenRcaService/StreamCoreMetrics", "/xds.service.orca.v3.OpenRcaService/StreamCoreMetrics",
internal::RpcMethod::SERVER_STREAMING, /*handler=*/nullptr)); internal::RpcMethod::SERVER_STREAMING, /*handler=*/nullptr));

@ -25,6 +25,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h> #include <grpc/impl/compression_types.h>
@ -188,7 +190,7 @@ void ServerBuilder::experimental_type::SetAuthorizationPolicyProvider(
void ServerBuilder::experimental_type::EnableCallMetricRecording( void ServerBuilder::experimental_type::EnableCallMetricRecording(
experimental::ServerMetricRecorder* server_metric_recorder) { experimental::ServerMetricRecorder* server_metric_recorder) {
builder_->AddChannelArgument(GRPC_ARG_SERVER_CALL_METRIC_RECORDING, 1); builder_->AddChannelArgument(GRPC_ARG_SERVER_CALL_METRIC_RECORDING, 1);
GPR_ASSERT(builder_->server_metric_recorder_ == nullptr); CHECK_EQ(builder_->server_metric_recorder_, nullptr);
builder_->server_metric_recorder_ = server_metric_recorder; builder_->server_metric_recorder_ = server_metric_recorder;
} }

@ -29,6 +29,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 <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -239,11 +240,10 @@ void ServerInterface::RegisteredAsyncRequest::IssueRequest(
ServerCompletionQueue* notification_cq) { ServerCompletionQueue* notification_cq) {
// The following call_start_batch is internally-generated so no need for an // The following call_start_batch is internally-generated so no need for an
// explanatory log on failure. // explanatory log on failure.
GPR_ASSERT(grpc_server_request_registered_call( CHECK(grpc_server_request_registered_call(
server_->server(), registered_method, &call_, server_->server(), registered_method, &call_, &context_->deadline_,
&context_->deadline_, context_->client_metadata_.arr(), context_->client_metadata_.arr(), payload, call_cq_->cq(),
payload, call_cq_->cq(), notification_cq->cq(), notification_cq->cq(), this) == GRPC_CALL_OK);
this) == GRPC_CALL_OK);
} }
ServerInterface::GenericAsyncRequest::GenericAsyncRequest( ServerInterface::GenericAsyncRequest::GenericAsyncRequest(
@ -254,8 +254,8 @@ ServerInterface::GenericAsyncRequest::GenericAsyncRequest(
: BaseAsyncRequest(server, context, stream, call_cq, notification_cq, tag, : BaseAsyncRequest(server, context, stream, call_cq, notification_cq, tag,
delete_on_finalize) { delete_on_finalize) {
grpc_call_details_init(&call_details_); grpc_call_details_init(&call_details_);
GPR_ASSERT(notification_cq); CHECK(notification_cq);
GPR_ASSERT(call_cq); CHECK(call_cq);
if (issue_request) { if (issue_request) {
IssueRequest(); IssueRequest();
} }
@ -289,10 +289,10 @@ bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag,
void ServerInterface::GenericAsyncRequest::IssueRequest() { void ServerInterface::GenericAsyncRequest::IssueRequest() {
// The following call_start_batch is internally-generated so no need for an // The following call_start_batch is internally-generated so no need for an
// explanatory log on failure. // explanatory log on failure.
GPR_ASSERT(grpc_server_request_call(server_->server(), &call_, &call_details_, CHECK(grpc_server_request_call(server_->server(), &call_, &call_details_,
context_->client_metadata_.arr(), context_->client_metadata_.arr(),
call_cq_->cq(), notification_cq_->cq(), call_cq_->cq(), notification_cq_->cq(),
this) == GRPC_CALL_OK); this) == GRPC_CALL_OK);
} }
namespace { namespace {
@ -480,7 +480,7 @@ class Server::SyncRequest final : public grpc::internal::CompletionQueueTag {
// Ensure the cq_ is shutdown // Ensure the cq_ is shutdown
grpc::PhonyTag ignored_tag; grpc::PhonyTag ignored_tag;
GPR_ASSERT(cq_.Pluck(&ignored_tag) == false); CHECK(cq_.Pluck(&ignored_tag) == false);
// Cleanup structures allocated during Run/ContinueRunAfterInterception // Cleanup structures allocated during Run/ContinueRunAfterInterception
wrapped_call_.Destroy(); wrapped_call_.Destroy();
@ -642,8 +642,8 @@ class Server::CallbackRequest final
void Run(bool ok) { void Run(bool ok) {
void* ignored = req_; void* ignored = req_;
bool new_ok = ok; bool new_ok = ok;
GPR_ASSERT(!req_->FinalizeResult(&ignored, &new_ok)); CHECK(!req_->FinalizeResult(&ignored, &new_ok));
GPR_ASSERT(ignored == req_); CHECK(ignored == req_);
if (!ok) { if (!ok) {
// The call has been shutdown. // The call has been shutdown.
@ -824,8 +824,8 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager {
// Under the AllocatingRequestMatcher model we will never see an invalid tag // Under the AllocatingRequestMatcher model we will never see an invalid tag
// here. // here.
GPR_DEBUG_ASSERT(sync_req != nullptr); DCHECK_NE(sync_req, nullptr);
GPR_DEBUG_ASSERT(ok); DCHECK(ok);
sync_req->Run(global_callbacks_, resources); sync_req->Run(global_callbacks_, resources);
} }
@ -997,8 +997,8 @@ Server::~Server() {
} }
void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) {
GPR_ASSERT(!grpc::g_callbacks); CHECK(!grpc::g_callbacks);
GPR_ASSERT(callbacks); CHECK(callbacks);
grpc::g_callbacks.reset(callbacks); grpc::g_callbacks.reset(callbacks);
} }
@ -1042,8 +1042,8 @@ static grpc_server_register_method_payload_handling PayloadHandlingForMethod(
bool Server::RegisterService(const std::string* addr, grpc::Service* service) { bool Server::RegisterService(const std::string* addr, grpc::Service* service) {
bool has_async_methods = service->has_async_methods(); bool has_async_methods = service->has_async_methods();
if (has_async_methods) { if (has_async_methods) {
GPR_ASSERT(service->server_ == nullptr && CHECK_EQ(service->server_, nullptr)
"Can only register an asynchronous service against one server."); << "Can only register an asynchronous service against one server.";
service->server_ = this; service->server_ = this;
} }
@ -1100,17 +1100,16 @@ bool Server::RegisterService(const std::string* addr, grpc::Service* service) {
} }
void Server::RegisterAsyncGenericService(grpc::AsyncGenericService* service) { void Server::RegisterAsyncGenericService(grpc::AsyncGenericService* service) {
GPR_ASSERT(service->server_ == nullptr && CHECK_EQ(service->server_, nullptr)
"Can only register an async generic service against one server."); << "Can only register an async generic service against one server.";
service->server_ = this; service->server_ = this;
has_async_generic_service_ = true; has_async_generic_service_ = true;
} }
void Server::RegisterCallbackGenericService( void Server::RegisterCallbackGenericService(
grpc::CallbackGenericService* service) { grpc::CallbackGenericService* service) {
GPR_ASSERT( CHECK_EQ(service->server_, nullptr)
service->server_ == nullptr && << "Can only register a callback generic service against one server.";
"Can only register a callback generic service against one server.");
service->server_ = this; service->server_ = this;
has_callback_generic_service_ = true; has_callback_generic_service_ = true;
generic_handler_.reset(service->Handler()); generic_handler_.reset(service->Handler());
@ -1126,7 +1125,7 @@ void Server::RegisterCallbackGenericService(
int Server::AddListeningPort(const std::string& addr, int Server::AddListeningPort(const std::string& addr,
grpc::ServerCredentials* creds) { grpc::ServerCredentials* creds) {
GPR_ASSERT(!started_); CHECK(!started_);
int port = creds->AddPortToServer(addr, server_); int port = creds->AddPortToServer(addr, server_);
global_callbacks_->AddPort(this, addr, creds, port); global_callbacks_->AddPort(this, addr, creds, port);
return port; return port;
@ -1142,7 +1141,7 @@ void Server::UnrefWithPossibleNotify() {
// No refs outstanding means that shutdown has been initiated and no more // No refs outstanding means that shutdown has been initiated and no more
// callback requests are outstanding. // callback requests are outstanding.
grpc::internal::MutexLock lock(&mu_); grpc::internal::MutexLock lock(&mu_);
GPR_ASSERT(shutdown_); CHECK(shutdown_);
shutdown_done_ = true; shutdown_done_ = true;
shutdown_done_cv_.Signal(); shutdown_done_cv_.Signal();
} }
@ -1160,7 +1159,7 @@ void Server::UnrefAndWaitLocked() {
} }
void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) { void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) {
GPR_ASSERT(!started_); CHECK(!started_);
global_callbacks_->PreServerStart(this); global_callbacks_->PreServerStart(this);
started_ = true; started_ = true;

@ -28,6 +28,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -155,8 +156,8 @@ class ServerContextBase::CompletionOp final
return; return;
} }
// Start a phony op so that we can return the tag // Start a phony op so that we can return the tag
GPR_ASSERT(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag_, CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag_,
nullptr) == GRPC_CALL_OK); nullptr) == GRPC_CALL_OK);
} }
private: private:
@ -197,8 +198,8 @@ void ServerContextBase::CompletionOp::FillOps(internal::Call* call) {
interceptor_methods_.SetCallOpSetInterface(this); interceptor_methods_.SetCallOpSetInterface(this);
// The following call_start_batch is internally-generated so no need for an // The following call_start_batch is internally-generated so no need for an
// explanatory log on failure. // explanatory log on failure.
GPR_ASSERT(grpc_call_start_batch(call->call(), &ops, 1, core_cq_tag_, CHECK(grpc_call_start_batch(call->call(), &ops, 1, core_cq_tag_, nullptr) ==
nullptr) == GRPC_CALL_OK); GRPC_CALL_OK);
// No interceptors to run here // No interceptors to run here
} }
@ -302,7 +303,7 @@ ServerContextBase::CallWrapper::~CallWrapper() {
void ServerContextBase::BeginCompletionOp( void ServerContextBase::BeginCompletionOp(
internal::Call* call, std::function<void(bool)> callback, internal::Call* call, std::function<void(bool)> callback,
grpc::internal::ServerCallbackCall* callback_controller) { grpc::internal::ServerCallbackCall* callback_controller) {
GPR_ASSERT(!completion_op_); CHECK(!completion_op_);
if (rpc_info_) { if (rpc_info_) {
rpc_info_->Ref(); rpc_info_->Ref();
} }
@ -374,7 +375,7 @@ void ServerContextBase::set_compression_algorithm(
grpc_core::Crash(absl::StrFormat( grpc_core::Crash(absl::StrFormat(
"Name for compression algorithm '%d' unknown.", algorithm)); "Name for compression algorithm '%d' unknown.", algorithm));
} }
GPR_ASSERT(algorithm_name != nullptr); CHECK_NE(algorithm_name, nullptr);
AddInitialMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name); AddInitialMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name);
} }
@ -404,7 +405,7 @@ void ServerContextBase::SetLoadReportingCosts(
void ServerContextBase::CreateCallMetricRecorder( void ServerContextBase::CreateCallMetricRecorder(
experimental::ServerMetricRecorder* server_metric_recorder) { experimental::ServerMetricRecorder* server_metric_recorder) {
if (call_.call == nullptr) return; if (call_.call == nullptr) return;
GPR_ASSERT(call_metric_recorder_ == nullptr); CHECK_EQ(call_metric_recorder_, nullptr);
grpc_core::Arena* arena = grpc_call_get_arena(call_.call); grpc_core::Arena* arena = grpc_call_get_arena(call_.call);
auto* backend_metric_state = auto* backend_metric_state =
arena->New<BackendMetricState>(server_metric_recorder); arena->New<BackendMetricState>(server_metric_recorder);

@ -18,6 +18,8 @@
#include <memory> #include <memory>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -27,8 +29,8 @@ namespace grpc {
std::shared_ptr<ServerCredentials> XdsServerCredentials( std::shared_ptr<ServerCredentials> XdsServerCredentials(
const std::shared_ptr<ServerCredentials>& fallback_credentials) { const std::shared_ptr<ServerCredentials>& fallback_credentials) {
GPR_ASSERT(fallback_credentials != nullptr); CHECK_NE(fallback_credentials, nullptr);
GPR_ASSERT(fallback_credentials->c_creds_ != nullptr); CHECK_NE(fallback_credentials->c_creds_, nullptr);
return std::shared_ptr<ServerCredentials>(new ServerCredentials( return std::shared_ptr<ServerCredentials>(new ServerCredentials(
grpc_xds_server_credentials_create(fallback_credentials->c_creds_))); grpc_xds_server_credentials_create(fallback_credentials->c_creds_)));
} }

@ -20,6 +20,7 @@
#include <climits> #include <climits>
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -68,7 +69,7 @@ ThreadManager::ThreadManager(const char*, grpc_resource_quota* resource_quota,
ThreadManager::~ThreadManager() { ThreadManager::~ThreadManager() {
{ {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
GPR_ASSERT(num_threads_ == 0); CHECK_EQ(num_threads_, 0);
} }
CleanupCompletedThreads(); CleanupCompletedThreads();
@ -142,7 +143,7 @@ void ThreadManager::Initialize() {
for (int i = 0; i < min_pollers_; i++) { for (int i = 0; i < min_pollers_; i++) {
WorkerThread* worker = new WorkerThread(this); WorkerThread* worker = new WorkerThread(this);
GPR_ASSERT(worker->created()); // Must be able to create the minimum CHECK(worker->created()); // Must be able to create the minimum
worker->Start(); worker->Start();
} }
} }

Loading…
Cancel
Save