Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2be1ae
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
59da5a9
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
17058be
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 25, 2024
8f3eacc
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
34b92a3
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
ed1a6d3
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
7ce4c69
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
3bfcc1e
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
de40488
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
e49282f
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
a8669e7
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
d995df1
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 25, 2024
3aad2e4
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 26, 2024
390fdf4
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 26, 2024
057ca8a
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 26, 2024
fa6bf1b
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 26, 2024
b70984c
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 26, 2024
92fd5b0
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 27, 2024
025ac1e
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 27, 2024
77edbbd
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 29, 2024
58c050c
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap Apr 30, 2024
ab2de29
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 30, 2024
cfe09cb
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 30, 2024
678649d
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap Apr 30, 2024
4dc7371
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap May 1, 2024
293c216
[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS…
tanvi-jagtap May 1, 2024
f3027bd
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap May 2, 2024
04d5e1b
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap May 2, 2024
5442361
Merge branch 'master' into tjagtap_ruby
tanvi-jagtap May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion BUILD
Expand Up @@ -1192,7 +1192,10 @@ grpc_cc_library(
hdrs = [
"src/cpp/client/secure_credentials.h",
],
external_deps = ["absl/strings"],
external_deps = [
"absl/log:check",
"absl/strings",
],
language = "c++",
deps = [
"exec_ctx",
Expand All @@ -1214,6 +1217,9 @@ grpc_cc_library(
hdrs = [
"src/cpp/server/secure_server_credentials.h",
],
external_deps = [
"absl/log:check",
],
language = "c++",
public_hdrs = [
"include/grpcpp/xds_server_builder.h",
Expand Down Expand Up @@ -2124,6 +2130,9 @@ grpc_cc_library(
"src/cpp/server/load_reporter/constants.h",
"src/cpp/server/load_reporter/load_data_store.h",
],
external_deps = [
"absl/log:check",
],
language = "c++",
deps = [
"gpr",
Expand Down Expand Up @@ -2182,6 +2191,7 @@ grpc_cc_library(
"src/cpp/server/load_reporter/load_reporter_async_service_impl.h",
],
external_deps = [
"absl/log:check",
"absl/memory",
"protobuf_headers",
],
Expand Down Expand Up @@ -2223,6 +2233,7 @@ grpc_cc_library(
"src/cpp/server/load_reporter/load_reporter.h",
],
external_deps = [
"absl/log:check",
"opencensus-stats",
"opencensus-tags",
"protobuf_headers",
Expand Down Expand Up @@ -2697,6 +2708,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/strings",
"absl/time",
"absl/types:optional",
Expand Down Expand Up @@ -2855,6 +2867,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/base:endian",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/client/call_credentials.cc
Expand Up @@ -11,6 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/log/check.h"
#include "absl/strings/str_cat.h"

#include <grpc/support/port_platform.h>
Expand All @@ -22,7 +24,7 @@ namespace grpc {

CallCredentials::CallCredentials(grpc_call_credentials* c_creds)
: c_creds_(c_creds) {
GPR_ASSERT(c_creds != nullptr);
CHECK_NE(c_creds, nullptr);
}

CallCredentials::~CallCredentials() { grpc_call_credentials_release(c_creds_); }
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/client/channel_cc.cc
Expand Up @@ -23,6 +23,8 @@
#include <utility>
#include <vector>

#include "absl/log/check.h"

#include <grpc/grpc.h>
#include <grpc/impl/connectivity_state.h>
#include <grpc/slice.h>
Expand Down Expand Up @@ -207,7 +209,7 @@ bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed,
void* tag = nullptr;
NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr);
cq.Next(&tag, &ok);
GPR_ASSERT(tag == nullptr);
CHECK_EQ(tag, nullptr);
return ok;
}

Expand Down
11 changes: 6 additions & 5 deletions src/cpp/client/client_context.cc
Expand Up @@ -24,6 +24,7 @@
#include <utility>
#include <vector>

#include "absl/log/check.h"
#include "absl/strings/str_format.h"

#include <grpc/compression.h>
Expand Down Expand Up @@ -125,7 +126,7 @@ void ClientContext::AddMetadata(const std::string& meta_key,
void ClientContext::set_call(grpc_call* call,
const std::shared_ptr<Channel>& channel) {
internal::MutexLock lock(&mu_);
GPR_ASSERT(call_ == nullptr);
CHECK_EQ(call_, nullptr);
call_ = call;
channel_ = channel;
if (creds_ && !creds_->ApplyToCall(call_)) {
Expand All @@ -148,7 +149,7 @@ void ClientContext::set_compression_algorithm(
grpc_core::Crash(absl::StrFormat(
"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);
}

Expand Down Expand Up @@ -180,9 +181,9 @@ std::string ClientContext::peer() const {
}

void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) {
GPR_ASSERT(g_client_callbacks == g_default_client_callbacks);
GPR_ASSERT(client_callbacks != nullptr);
GPR_ASSERT(client_callbacks != g_default_client_callbacks);
CHECK(g_client_callbacks == g_default_client_callbacks);
CHECK_NE(client_callbacks, nullptr);
CHECK(client_callbacks != g_default_client_callbacks);
g_client_callbacks = client_callbacks;
}

Expand Down
5 changes: 3 additions & 2 deletions src/cpp/client/secure_credentials.cc
Expand Up @@ -24,6 +24,7 @@
#include <memory>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_join.h"
Expand Down Expand Up @@ -362,7 +363,7 @@ class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
size_t* num_creds_md, grpc_status_code* status,
const char** error_details) {
GPR_ASSERT(wrapper);
CHECK(wrapper);
MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
if (!w->plugin_) {
Expand Down Expand Up @@ -393,7 +394,7 @@ class MetadataCredentialsPluginWrapper final : private internal::GrpcLibrary {
}

static char* DebugString(void* wrapper) {
GPR_ASSERT(wrapper);
CHECK(wrapper);
MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
return gpr_strdup(w->plugin_->DebugString().c_str());
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/client/xds_credentials.cc
Expand Up @@ -18,6 +18,8 @@

#include <memory>

#include "absl/log/check.h"

#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h>
Expand All @@ -30,13 +32,13 @@ class XdsChannelCredentialsImpl final : public ChannelCredentials {
const std::shared_ptr<ChannelCredentials>& fallback_creds)
: ChannelCredentials(
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(
const std::shared_ptr<ChannelCredentials>& fallback_creds) {
GPR_ASSERT(fallback_creds != nullptr);
CHECK_NE(fallback_creds, nullptr);
return std::make_shared<XdsChannelCredentialsImpl>(fallback_creds);
}

Expand Down
11 changes: 6 additions & 5 deletions src/cpp/common/alarm.cc
Expand Up @@ -20,6 +20,7 @@
#include <memory>
#include <utility>

#include "absl/log/check.h"
#include "absl/status/status.h"

#include <grpc/event_engine/event_engine.h>
Expand Down Expand Up @@ -65,10 +66,10 @@ class AlarmImpl : public grpc::internal::CompletionQueueTag {
GRPC_CQ_INTERNAL_REF(cq->cq(), "alarm");
cq_ = cq->cq();
tag_ = tag;
GPR_ASSERT(grpc_cq_begin_op(cq_, this));
CHECK(grpc_cq_begin_op(cq_, this));
Ref();
GPR_ASSERT(cq_armed_.exchange(true) == false);
GPR_ASSERT(!callback_armed_.load());
CHECK(cq_armed_.exchange(true) == false);
CHECK(!callback_armed_.load());
cq_timer_handle_ = event_engine_->RunAfter(
grpc_core::Timestamp::FromTimespecRoundUp(deadline) -
grpc_core::ExecCtx::Get()->Now(),
Expand All @@ -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
callback_ = std::move(f);
Ref();
GPR_ASSERT(callback_armed_.exchange(true) == false);
GPR_ASSERT(!cq_armed_.load());
CHECK(callback_armed_.exchange(true) == false);
CHECK(!cq_armed_.load());
callback_timer_handle_ = event_engine_->RunAfter(
grpc_core::Timestamp::FromTimespecRoundUp(deadline) -
grpc_core::ExecCtx::Get()->Now(),
Expand Down
10 changes: 6 additions & 4 deletions src/cpp/common/channel_arguments.cc
Expand Up @@ -20,6 +20,8 @@
#include <string>
#include <vector>

#include "absl/log/check.h"

#include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h>
#include <grpc/support/log.h>
Expand All @@ -45,7 +47,7 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
for (const auto& a : other.args_) {
grpc_arg ap;
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());
++list_it_src;
++list_it_dst;
Expand All @@ -54,7 +56,7 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
ap.value.integer = a.value.integer;
break;
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());
++list_it_src;
++list_it_dst;
Expand Down Expand Up @@ -101,7 +103,7 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
for (auto& arg : args_) {
if (arg.type == mutator_arg.type &&
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 = mutator_arg.value.pointer;
replaced = true;
Expand Down Expand Up @@ -130,7 +132,7 @@ void ChannelArguments::SetUserAgentPrefix(
++strings_it;
if (arg.type == GRPC_ARG_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;
arg.value.string = const_cast<char*>(strings_it->c_str());
replaced = true;
Expand Down
7 changes: 4 additions & 3 deletions src/cpp/common/completion_queue_cc.cc
Expand Up @@ -18,6 +18,7 @@
#include <vector>

#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"

#include <grpc/grpc.h>
#include <grpc/support/cpu.h>
Expand Down Expand Up @@ -83,7 +84,7 @@ struct CallbackAlternativeCQ {
gpr_time_from_millis(100, GPR_TIMESPAN)));
continue;
}
GPR_DEBUG_ASSERT(ev.type == GRPC_OP_COMPLETE);
DCHECK(ev.type == GRPC_OP_COMPLETE);
// We can always execute the callback inline rather than
// pushing it to another Executor thread because this
// thread is definitely running on a background thread, does not
Expand Down Expand Up @@ -169,7 +170,7 @@ CompletionQueue::CompletionQueueTLSCache::CompletionQueueTLSCache(
}

CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache() {
GPR_ASSERT(flushed_);
CHECK(flushed_);
}

bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) {
Expand Down Expand Up @@ -199,7 +200,7 @@ void CompletionQueue::ReleaseCallbackAlternativeCQ(CompletionQueue* cq)
(void)cq;
// This accesses g_callback_alternative_cq without acquiring the mutex
// 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();
}

Expand Down
8 changes: 5 additions & 3 deletions src/cpp/common/tls_certificate_provider.cc
Expand Up @@ -17,6 +17,8 @@
#include <string>
#include <vector>

#include "absl/log/check.h"

#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h>
Expand All @@ -28,15 +30,15 @@ namespace experimental {
StaticDataCertificateProvider::StaticDataCertificateProvider(
const std::string& root_certificate,
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();
for (const IdentityKeyCertPair& pair : identity_key_cert_pairs) {
grpc_tls_identity_pairs_add_pair(pairs_core, pair.private_key.c_str(),
pair.certificate_chain.c_str());
}
c_provider_ = grpc_tls_certificate_provider_static_data_create(
root_certificate.c_str(), pairs_core);
GPR_ASSERT(c_provider_ != nullptr);
CHECK_NE(c_provider_, nullptr);
};

StaticDataCertificateProvider::~StaticDataCertificateProvider() {
Expand All @@ -50,7 +52,7 @@ FileWatcherCertificateProvider::FileWatcherCertificateProvider(
c_provider_ = grpc_tls_certificate_provider_file_watcher_create(
private_key_path.c_str(), identity_certificate_path.c_str(),
root_cert_path.c_str(), refresh_interval_sec);
GPR_ASSERT(c_provider_ != nullptr);
CHECK_NE(c_provider_, nullptr);
};

FileWatcherCertificateProvider::~FileWatcherCertificateProvider() {
Expand Down
14 changes: 8 additions & 6 deletions src/cpp/common/tls_certificate_verifier.cc
Expand Up @@ -22,6 +22,8 @@
#include <utility>
#include <vector>

#include "absl/log/check.h"

#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/status.h>
Expand All @@ -39,7 +41,7 @@ namespace experimental {
TlsCustomVerificationCheckRequest::TlsCustomVerificationCheckRequest(
grpc_tls_custom_verification_check_request* request)
: c_request_(request) {
GPR_ASSERT(c_request_ != nullptr);
CHECK_NE(c_request_, nullptr);
}

grpc::string_ref TlsCustomVerificationCheckRequest::target_name() const {
Expand Down Expand Up @@ -119,8 +121,8 @@ CertificateVerifier::~CertificateVerifier() {
bool CertificateVerifier::Verify(TlsCustomVerificationCheckRequest* request,
std::function<void(grpc::Status)> callback,
grpc::Status* sync_status) {
GPR_ASSERT(request != nullptr);
GPR_ASSERT(request->c_request() != nullptr);
CHECK_NE(request, nullptr);
CHECK_NE(request->c_request(), nullptr);
{
internal::MutexLock lock(&mu_);
request_map_.emplace(request->c_request(), std::move(callback));
Expand All @@ -143,8 +145,8 @@ bool CertificateVerifier::Verify(TlsCustomVerificationCheckRequest* request,
}

void CertificateVerifier::Cancel(TlsCustomVerificationCheckRequest* request) {
GPR_ASSERT(request != nullptr);
GPR_ASSERT(request->c_request() != nullptr);
CHECK_NE(request, nullptr);
CHECK_NE(request->c_request(), nullptr);
grpc_tls_certificate_verifier_cancel(verifier_, request->c_request());
}

Expand Down Expand Up @@ -191,7 +193,7 @@ int ExternalCertificateVerifier::VerifyInCoreExternalVerifier(
internal::MutexLock lock(&self->mu_);
auto pair = self->request_map_.emplace(
request, AsyncRequestState(callback, callback_arg, request));
GPR_ASSERT(pair.second);
CHECK(pair.second);
cpp_request = &pair.first->second.cpp_request;
}
grpc::Status sync_current_verifier_status;
Expand Down