Merge branch 'nukage' into transport-refs-8

This commit is contained in:
Craig Tiller 2024-06-03 08:28:32 -07:00
commit df6b38bd97
55 changed files with 340 additions and 418 deletions

2
CMakeLists.txt generated
View File

@ -1878,7 +1878,6 @@ add_library(grpc
src/core/ext/filters/rbac/rbac_service_config_parser.cc
src/core/ext/filters/stateful_session/stateful_session_filter.cc
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc
src/core/ext/gcp/metadata_query.cc
src/core/ext/transport/chttp2/alpn/alpn.cc
src/core/ext/transport/chttp2/client/chttp2_connector.cc
src/core/ext/transport/chttp2/server/chttp2_server.cc
@ -2611,6 +2610,7 @@ add_library(grpc
src/core/tsi/ssl_transport_security_utils.cc
src/core/tsi/transport_security.cc
src/core/tsi/transport_security_grpc.cc
src/core/util/gcp_metadata_query.cc
src/core/util/http_client/format_request.cc
src/core/util/http_client/httpcli.cc
src/core/util/http_client/httpcli_security_connector.cc

2
Makefile generated
View File

@ -703,7 +703,6 @@ LIBGRPC_SRC = \
src/core/ext/filters/rbac/rbac_service_config_parser.cc \
src/core/ext/filters/stateful_session/stateful_session_filter.cc \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \
src/core/ext/gcp/metadata_query.cc \
src/core/ext/transport/chttp2/alpn/alpn.cc \
src/core/ext/transport/chttp2/client/chttp2_connector.cc \
src/core/ext/transport/chttp2/server/chttp2_server.cc \
@ -1458,6 +1457,7 @@ LIBGRPC_SRC = \
src/core/util/alloc.cc \
src/core/util/android/log.cc \
src/core/util/atm.cc \
src/core/util/gcp_metadata_query.cc \
src/core/util/http_client/format_request.cc \
src/core/util/http_client/httpcli.cc \
src/core/util/http_client/httpcli_security_connector.cc \

4
Package.swift generated
View File

@ -193,8 +193,6 @@ let package = Package(
"src/core/ext/filters/stateful_session/stateful_session_filter.h",
"src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc",
"src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h",
"src/core/ext/gcp/metadata_query.cc",
"src/core/ext/gcp/metadata_query.h",
"src/core/ext/transport/chttp2/alpn/alpn.cc",
"src/core/ext/transport/chttp2/alpn/alpn.h",
"src/core/ext/transport/chttp2/client/chttp2_connector.cc",
@ -1917,6 +1915,8 @@ let package = Package(
"src/core/util/alloc.h",
"src/core/util/android/log.cc",
"src/core/util/atm.cc",
"src/core/util/gcp_metadata_query.cc",
"src/core/util/gcp_metadata_query.h",
"src/core/util/http_client/format_request.cc",
"src/core/util/http_client/format_request.h",
"src/core/util/http_client/httpcli.cc",

View File

@ -261,7 +261,6 @@ libs:
- src/core/ext/filters/rbac/rbac_service_config_parser.h
- src/core/ext/filters/stateful_session/stateful_session_filter.h
- src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h
- src/core/ext/gcp/metadata_query.h
- src/core/ext/transport/chttp2/alpn/alpn.h
- src/core/ext/transport/chttp2/client/chttp2_connector.h
- src/core/ext/transport/chttp2/server/chttp2_server.h
@ -1206,6 +1205,7 @@ libs:
- src/core/tsi/transport_security.h
- src/core/tsi/transport_security_grpc.h
- src/core/tsi/transport_security_interface.h
- src/core/util/gcp_metadata_query.h
- src/core/util/http_client/format_request.h
- src/core/util/http_client/httpcli.h
- src/core/util/http_client/httpcli_ssl_credentials.h
@ -1288,7 +1288,6 @@ libs:
- src/core/ext/filters/rbac/rbac_service_config_parser.cc
- src/core/ext/filters/stateful_session/stateful_session_filter.cc
- src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc
- src/core/ext/gcp/metadata_query.cc
- src/core/ext/transport/chttp2/alpn/alpn.cc
- src/core/ext/transport/chttp2/client/chttp2_connector.cc
- src/core/ext/transport/chttp2/server/chttp2_server.cc
@ -2021,6 +2020,7 @@ libs:
- src/core/tsi/ssl_transport_security_utils.cc
- src/core/tsi/transport_security.cc
- src/core/tsi/transport_security_grpc.cc
- src/core/util/gcp_metadata_query.cc
- src/core/util/http_client/format_request.cc
- src/core/util/http_client/httpcli.cc
- src/core/util/http_client/httpcli_security_connector.cc

3
config.m4 generated
View File

@ -78,7 +78,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/rbac/rbac_service_config_parser.cc \
src/core/ext/filters/stateful_session/stateful_session_filter.cc \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \
src/core/ext/gcp/metadata_query.cc \
src/core/ext/transport/chttp2/alpn/alpn.cc \
src/core/ext/transport/chttp2/client/chttp2_connector.cc \
src/core/ext/transport/chttp2/server/chttp2_server.cc \
@ -833,6 +832,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/util/alloc.cc \
src/core/util/android/log.cc \
src/core/util/atm.cc \
src/core/util/gcp_metadata_query.cc \
src/core/util/http_client/format_request.cc \
src/core/util/http_client/httpcli.cc \
src/core/util/http_client/httpcli_security_connector.cc \
@ -1404,7 +1404,6 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/message_size)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/rbac)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/stateful_session)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/gcp)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/alpn)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/client)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server)

3
config.w32 generated
View File

@ -43,7 +43,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\rbac\\rbac_service_config_parser.cc " +
"src\\core\\ext\\filters\\stateful_session\\stateful_session_filter.cc " +
"src\\core\\ext\\filters\\stateful_session\\stateful_session_service_config_parser.cc " +
"src\\core\\ext\\gcp\\metadata_query.cc " +
"src\\core\\ext\\transport\\chttp2\\alpn\\alpn.cc " +
"src\\core\\ext\\transport\\chttp2\\client\\chttp2_connector.cc " +
"src\\core\\ext\\transport\\chttp2\\server\\chttp2_server.cc " +
@ -798,6 +797,7 @@ if (PHP_GRPC != "no") {
"src\\core\\util\\alloc.cc " +
"src\\core\\util\\android\\log.cc " +
"src\\core\\util\\atm.cc " +
"src\\core\\util\\gcp_metadata_query.cc " +
"src\\core\\util\\http_client\\format_request.cc " +
"src\\core\\util\\http_client\\httpcli.cc " +
"src\\core\\util\\http_client\\httpcli_security_connector.cc " +
@ -1398,7 +1398,6 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\message_size");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\rbac");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\stateful_session");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\gcp");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\alpn");

4
gRPC-C++.podspec generated
View File

@ -302,7 +302,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
'src/core/ext/filters/stateful_session/stateful_session_filter.h',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h',
'src/core/ext/gcp/metadata_query.h',
'src/core/ext/transport/binder/client/binder_connector.cc',
'src/core/ext/transport/binder/client/binder_connector.h',
'src/core/ext/transport/binder/client/channel_create.cc',
@ -1305,6 +1304,7 @@ Pod::Spec.new do |s|
'src/core/tsi/transport_security_grpc.h',
'src/core/tsi/transport_security_interface.h',
'src/core/util/alloc.h',
'src/core/util/gcp_metadata_query.h',
'src/core/util/http_client/format_request.h',
'src/core/util/http_client/httpcli.h',
'src/core/util/http_client/httpcli_ssl_credentials.h',
@ -1595,7 +1595,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
'src/core/ext/filters/stateful_session/stateful_session_filter.h',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h',
'src/core/ext/gcp/metadata_query.h',
'src/core/ext/transport/binder/client/binder_connector.h',
'src/core/ext/transport/binder/client/channel_create_impl.h',
'src/core/ext/transport/binder/client/connection_id_generator.h',
@ -2580,6 +2579,7 @@ Pod::Spec.new do |s|
'src/core/tsi/transport_security_grpc.h',
'src/core/tsi/transport_security_interface.h',
'src/core/util/alloc.h',
'src/core/util/gcp_metadata_query.h',
'src/core/util/http_client/format_request.h',
'src/core/util/http_client/httpcli.h',
'src/core/util/http_client/httpcli_ssl_credentials.h',

6
gRPC-Core.podspec generated
View File

@ -312,8 +312,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/stateful_session/stateful_session_filter.h',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h',
'src/core/ext/gcp/metadata_query.cc',
'src/core/ext/gcp/metadata_query.h',
'src/core/ext/transport/chttp2/alpn/alpn.cc',
'src/core/ext/transport/chttp2/alpn/alpn.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
@ -2032,6 +2030,8 @@ Pod::Spec.new do |s|
'src/core/util/alloc.h',
'src/core/util/android/log.cc',
'src/core/util/atm.cc',
'src/core/util/gcp_metadata_query.cc',
'src/core/util/gcp_metadata_query.h',
'src/core/util/http_client/format_request.cc',
'src/core/util/http_client/format_request.h',
'src/core/util/http_client/httpcli.cc',
@ -2399,7 +2399,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
'src/core/ext/filters/stateful_session/stateful_session_filter.h',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h',
'src/core/ext/gcp/metadata_query.h',
'src/core/ext/transport/chttp2/alpn/alpn.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/chttp2/server/chttp2_server.h',
@ -3364,6 +3363,7 @@ Pod::Spec.new do |s|
'src/core/tsi/transport_security_grpc.h',
'src/core/tsi/transport_security_interface.h',
'src/core/util/alloc.h',
'src/core/util/gcp_metadata_query.h',
'src/core/util/http_client/format_request.h',
'src/core/util/http_client/httpcli.h',
'src/core/util/http_client/httpcli_ssl_credentials.h',

4
grpc.gemspec generated
View File

@ -199,8 +199,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/stateful_session/stateful_session_filter.h )
s.files += %w( src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc )
s.files += %w( src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h )
s.files += %w( src/core/ext/gcp/metadata_query.cc )
s.files += %w( src/core/ext/gcp/metadata_query.h )
s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.cc )
s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.h )
s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.cc )
@ -1919,6 +1917,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/util/alloc.h )
s.files += %w( src/core/util/android/log.cc )
s.files += %w( src/core/util/atm.cc )
s.files += %w( src/core/util/gcp_metadata_query.cc )
s.files += %w( src/core/util/gcp_metadata_query.h )
s.files += %w( src/core/util/http_client/format_request.cc )
s.files += %w( src/core/util/http_client/format_request.h )
s.files += %w( src/core/util/http_client/httpcli.cc )

View File

@ -312,7 +312,7 @@
'src/core/ext/filters/server_config_selector/server_config_selector_filter.cc',
'src/core/ext/filters/stateful_session/stateful_session_filter.cc',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc',
'src/core/ext/gcp/metadata_query.cc',
'src/core/util/gcp_metadata_query.cc',
'src/core/ext/transport/chttp2/alpn/alpn.cc',
'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
'src/core/ext/transport/chttp2/server/chttp2_server.cc',

View File

@ -24,13 +24,13 @@
#include <memory>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/impl/compression_types.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/client_context.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h>
@ -976,8 +976,8 @@ class CallOpSet : public CallOpSetInterface,
// A failure here indicates an API misuse; for example, doing a Write
// while another Write is already pending on the same RPC or invoking
// WritesDone multiple times
gpr_log(GPR_ERROR, "API misuse of type %s observed",
grpc_call_error_to_string(err));
LOG(ERROR) << "API misuse of type " << grpc_call_error_to_string(err)
<< " observed";
CHECK(false);
}
}

View File

@ -26,8 +26,8 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/config.h>
@ -116,12 +116,12 @@ class RpcServiceMethod : public RpcMethod {
// this is not an error condition, as it allows users to declare a server
// like WithRawMethod_foo<AsyncService>. However since it
// overwrites behavior, it should be logged.
gpr_log(
GPR_INFO,
"You are marking method %s as '%s', even though it was "
"previously marked '%s'. This behavior will overwrite the original "
"behavior. If you expected this then ignore this message.",
name(), TypeToString(api_type_), TypeToString(type));
LOG(INFO) << "You are marking method " << name() << " as '"
<< TypeToString(api_type_)
<< "', even though it was previously marked '"
<< TypeToString(type)
<< "'. This behavior will overwrite the original behavior. If "
"you expected this then ignore this message.";
}
api_type_ = type;
}

4
package.xml generated
View File

@ -181,8 +181,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/stateful_session/stateful_session_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/gcp/metadata_query.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/gcp/metadata_query.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.cc" role="src" />
@ -1901,6 +1899,8 @@
<file baseinstalldir="/" name="src/core/util/alloc.h" role="src" />
<file baseinstalldir="/" name="src/core/util/android/log.cc" role="src" />
<file baseinstalldir="/" name="src/core/util/atm.cc" role="src" />
<file baseinstalldir="/" name="src/core/util/gcp_metadata_query.cc" role="src" />
<file baseinstalldir="/" name="src/core/util/gcp_metadata_query.h" role="src" />
<file baseinstalldir="/" name="src/core/util/http_client/format_request.cc" role="src" />
<file baseinstalldir="/" name="src/core/util/http_client/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/util/http_client/httpcli.cc" role="src" />

View File

@ -2234,6 +2234,9 @@ grpc_cc_library(
hdrs = [
"lib/event_engine/posix_engine/internal_errqueue.h",
],
external_deps = [
"absl/log:log",
],
deps = [
"iomgr_port",
"strerror",
@ -7188,10 +7191,10 @@ grpc_cc_library(
grpc_cc_library(
name = "gcp_metadata_query",
srcs = [
"ext/gcp/metadata_query.cc",
"util/gcp_metadata_query.cc",
],
hdrs = [
"ext/gcp/metadata_query.h",
"util/gcp_metadata_query.h",
],
external_deps = [
"absl/functional:any_invocable",

View File

@ -22,10 +22,10 @@
#include <inttypes.h>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/config/config_vars.h"
@ -66,10 +66,9 @@ void grpc_client_channel_global_init_backup_polling() {
int32_t poll_interval_ms =
grpc_core::ConfigVars::Get().ClientChannelBackupPollIntervalMs();
if (poll_interval_ms < 0) {
gpr_log(GPR_ERROR,
"Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %d, "
"default value %" PRId64 " will be used.",
poll_interval_ms, g_poll_interval.millis());
LOG(ERROR) << "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: "
<< poll_interval_ms << ", default value "
<< g_poll_interval.millis() << " will be used.";
} else {
g_poll_interval = grpc_core::Duration::Milliseconds(poll_interval_ms);
}

View File

@ -23,6 +23,7 @@
#include <utility>
#include <vector>
#include "absl/log/log.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
@ -30,7 +31,6 @@
#include <grpc/impl/channel_arg_names.h>
#include <grpc/status.h>
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/status_util.h"
@ -142,9 +142,8 @@ void RetryMethodConfig::JsonPostLoad(const Json& json, const JsonArgs& args,
if (max_attempts_ <= 1) {
errors->AddError("must be at least 2");
} else if (max_attempts_ > MAX_MAX_RETRY_ATTEMPTS) {
gpr_log(GPR_ERROR,
"service config: clamped retryPolicy.maxAttempts at %d",
MAX_MAX_RETRY_ATTEMPTS);
LOG(ERROR) << "service config: clamped retryPolicy.maxAttempts at "
<< MAX_MAX_RETRY_ATTEMPTS;
max_attempts_ = MAX_MAX_RETRY_ATTEMPTS;
}
}

View File

@ -24,9 +24,9 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/status.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/debug_location.h"
@ -77,22 +77,22 @@ SubchannelStreamClient::SubchannelStreamClient(
SUBCHANNEL_STREAM_RECONNECT_MAX_BACKOFF_SECONDS))),
event_engine_(connected_subchannel_->args().GetObject<EventEngine>()) {
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: created SubchannelStreamClient", tracer_, this);
LOG(INFO) << tracer_ << " " << this << ": created SubchannelStreamClient";
}
StartCall();
}
SubchannelStreamClient::~SubchannelStreamClient() {
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: destroying SubchannelStreamClient", tracer_,
this);
LOG(INFO) << tracer_ << " " << this
<< ": destroying SubchannelStreamClient";
}
}
void SubchannelStreamClient::Orphan() {
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: SubchannelStreamClient shutting down", tracer_,
this);
LOG(INFO) << tracer_ << " " << this
<< ": SubchannelStreamClient shutting down";
}
{
MutexLock lock(&mu_);
@ -119,8 +119,9 @@ void SubchannelStreamClient::StartCallLocked() {
}
call_state_ = MakeOrphanable<CallState>(Ref(), interested_parties_);
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: SubchannelStreamClient created CallState %p",
tracer_, this, call_state_.get());
LOG(INFO) << tracer_ << " " << this
<< ": SubchannelStreamClient created CallState "
<< call_state_.get();
}
call_state_->StartCallLocked();
}
@ -131,13 +132,13 @@ void SubchannelStreamClient::StartRetryTimerLocked() {
}
const Duration timeout = retry_backoff_.NextAttemptTime() - Timestamp::Now();
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: SubchannelStreamClient health check call lost...",
tracer_, this);
LOG(INFO) << tracer_ << " " << this
<< ": SubchannelStreamClient health check call lost...";
if (timeout > Duration::Zero()) {
gpr_log(GPR_INFO, "%s %p: ... will retry in %" PRId64 "ms.", tracer_,
this, timeout.millis());
LOG(INFO) << tracer_ << " " << this << ": ... will retry in "
<< timeout.millis() << "ms.";
} else {
gpr_log(GPR_INFO, "%s %p: ... retrying immediately.", tracer_, this);
LOG(INFO) << tracer_ << " " << this << ": ... retrying immediately.";
}
}
retry_timer_handle_ = event_engine_->RunAfter(
@ -154,9 +155,8 @@ void SubchannelStreamClient::OnRetryTimer() {
if (event_handler_ != nullptr && retry_timer_handle_.has_value() &&
call_state_ == nullptr) {
if (GPR_UNLIKELY(tracer_ != nullptr)) {
gpr_log(GPR_INFO,
"%s %p: SubchannelStreamClient restarting health check call",
tracer_, this);
LOG(INFO) << tracer_ << " " << this
<< ": SubchannelStreamClient restarting health check call";
}
StartCallLocked();
}
@ -176,9 +176,9 @@ SubchannelStreamClient::CallState::CallState(
SubchannelStreamClient::CallState::~CallState() {
if (GPR_UNLIKELY(subchannel_stream_client_->tracer_ != nullptr)) {
gpr_log(GPR_INFO, "%s %p: SubchannelStreamClient destroying CallState %p",
subchannel_stream_client_->tracer_, subchannel_stream_client_.get(),
this);
LOG(INFO) << subchannel_stream_client_->tracer_ << " "
<< subchannel_stream_client_.get()
<< ": SubchannelStreamClient destroying CallState " << this;
}
// Unset the call combiner cancellation closure. This has the
// effect of scheduling the previously set cancellation closure, if
@ -210,11 +210,10 @@ void SubchannelStreamClient::CallState::StartCallLocked() {
call_->SetAfterCallStackDestroy(&after_call_stack_destruction_);
// Check if creation failed.
if (!error.ok() || subchannel_stream_client_->event_handler_ == nullptr) {
gpr_log(GPR_ERROR,
"SubchannelStreamClient %p CallState %p: error creating "
"stream on subchannel (%s); will retry",
subchannel_stream_client_.get(), this,
StatusToString(error).c_str());
LOG(ERROR) << "SubchannelStreamClient " << subchannel_stream_client_.get()
<< " CallState " << this << ": error creating "
<< "stream on subchannel (" << StatusToString(error)
<< "); will retry";
CallEndedLocked(/*retry=*/true);
return;
}
@ -362,12 +361,10 @@ void SubchannelStreamClient::CallState::RecvMessageReady() {
subchannel_stream_client_.get(), recv_message_->JoinIntoString());
if (!status.ok()) {
if (GPR_UNLIKELY(subchannel_stream_client_->tracer_ != nullptr)) {
gpr_log(GPR_INFO,
"%s %p: SubchannelStreamClient CallState %p: failed to "
"parse response message: %s",
subchannel_stream_client_->tracer_,
subchannel_stream_client_.get(), this,
status.ToString().c_str());
LOG(INFO) << subchannel_stream_client_->tracer_ << " "
<< subchannel_stream_client_.get()
<< ": SubchannelStreamClient CallState " << this
<< ": failed to parse response message: " << status;
}
Cancel();
}
@ -410,11 +407,10 @@ void SubchannelStreamClient::CallState::RecvTrailingMetadataReady(
nullptr /* error_string */);
}
if (GPR_UNLIKELY(self->subchannel_stream_client_->tracer_ != nullptr)) {
gpr_log(GPR_INFO,
"%s %p: SubchannelStreamClient CallState %p: health watch failed "
"with status %d",
self->subchannel_stream_client_->tracer_,
self->subchannel_stream_client_.get(), self, status);
LOG(INFO) << self->subchannel_stream_client_->tracer_ << " "
<< self->subchannel_stream_client_.get()
<< ": SubchannelStreamClient CallState " << self
<< ": health watch failed with status " << status;
}
// Clean up.
self->recv_trailing_metadata_.Clear();

View File

@ -18,9 +18,6 @@
#include "src/core/lib/address_utils/parse_address.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h" // IWYU pragma: keep
@ -44,12 +41,12 @@
#endif // GRPC_HAVE_UNIX_SOCKET
#include <string>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/strip.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
@ -64,8 +61,7 @@
bool grpc_parse_unix(const grpc_core::URI& uri,
grpc_resolved_address* resolved_addr) {
if (uri.scheme() != "unix") {
gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'",
uri.scheme().c_str());
LOG(ERROR) << "Expected 'unix' scheme, got '" << uri.scheme() << "'";
return false;
}
grpc_error_handle error =
@ -80,8 +76,8 @@ bool grpc_parse_unix(const grpc_core::URI& uri,
bool grpc_parse_unix_abstract(const grpc_core::URI& uri,
grpc_resolved_address* resolved_addr) {
if (uri.scheme() != "unix-abstract") {
gpr_log(GPR_ERROR, "Expected 'unix-abstract' scheme, got '%s'",
uri.scheme().c_str());
LOG(ERROR) << "Expected 'unix-abstract' scheme, got '" << uri.scheme()
<< "'";
return false;
}
grpc_error_handle error =
@ -164,8 +160,7 @@ grpc_error_handle UnixAbstractSockaddrPopulate(
bool grpc_parse_vsock(const grpc_core::URI& uri,
grpc_resolved_address* resolved_addr) {
if (uri.scheme() != "vsock") {
gpr_log(GPR_ERROR, "Expected 'vsock' scheme, got '%s'",
uri.scheme().c_str());
LOG(ERROR) << "Expected 'vsock' scheme, got '" << uri.scheme() << "'";
return false;
}
grpc_error_handle error =
@ -221,8 +216,7 @@ bool grpc_parse_ipv4_hostport(absl::string_view hostport,
std::string port;
if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
if (log_errors) {
gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)",
std::string(hostport).c_str());
LOG(ERROR) << "Failed gpr_split_host_port(" << hostport << ", ...)";
}
return false;
}
@ -233,7 +227,7 @@ bool grpc_parse_ipv4_hostport(absl::string_view hostport,
in->sin_family = GRPC_AF_INET;
if (grpc_inet_pton(GRPC_AF_INET, host.c_str(), &in->sin_addr) == 0) {
if (log_errors) {
gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host.c_str());
LOG(ERROR) << "invalid ipv4 address: '" << host << "'";
}
goto done;
}
@ -245,7 +239,7 @@ bool grpc_parse_ipv4_hostport(absl::string_view hostport,
int port_num;
if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
port_num > 65535) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port.c_str());
if (log_errors) LOG(ERROR) << "invalid ipv4 port: '" << port << "'";
goto done;
}
in->sin_port = grpc_htons(static_cast<uint16_t>(port_num));
@ -257,8 +251,7 @@ done:
bool grpc_parse_ipv4(const grpc_core::URI& uri,
grpc_resolved_address* resolved_addr) {
if (uri.scheme() != "ipv4") {
gpr_log(GPR_ERROR, "Expected 'ipv4' scheme, got '%s'",
uri.scheme().c_str());
LOG(ERROR) << "Expected 'ipv4' scheme, got '" << uri.scheme() << "'";
return false;
}
return grpc_parse_ipv4_hostport(absl::StripPrefix(uri.path(), "/"),
@ -273,8 +266,7 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
std::string port;
if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
if (log_errors) {
gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)",
std::string(hostport).c_str());
LOG(ERROR) << "Failed gpr_split_host_port(" << hostport << ", ...)";
}
return false;
}
@ -294,11 +286,9 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
uint32_t sin6_scope_id = 0;
if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) {
if (log_errors) {
gpr_log(
GPR_ERROR,
"invalid ipv6 address length %zu. Length cannot be greater than "
"GRPC_INET6_ADDRSTRLEN i.e %d)",
host_without_scope_len, GRPC_INET6_ADDRSTRLEN);
LOG(ERROR) << "invalid ipv6 address length " << host_without_scope_len
<< ". Length cannot be greater than "
<< "GRPC_INET6_ADDRSTRLEN i.e " << GRPC_INET6_ADDRSTRLEN;
}
goto done;
}
@ -307,7 +297,7 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) ==
0) {
if (log_errors) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
LOG(ERROR) << "invalid ipv6 address: '" << host_without_scope << "'";
}
goto done;
}
@ -315,10 +305,8 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
host.size() - host_without_scope_len - 1,
&sin6_scope_id) == 0) {
if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) {
gpr_log(GPR_ERROR,
"Invalid interface name: '%s'. "
"Non-numeric and failed if_nametoindex.",
host_end + 1);
LOG(ERROR) << "Invalid interface name: '" << host_end + 1
<< "'. Non-numeric and failed if_nametoindex.";
goto done;
}
}
@ -327,7 +315,7 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
} else {
if (grpc_inet_pton(GRPC_AF_INET6, host.c_str(), &in6->sin6_addr) == 0) {
if (log_errors) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host.c_str());
LOG(ERROR) << "invalid ipv6 address: '" << host << "'";
}
goto done;
}
@ -340,7 +328,7 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
int port_num;
if (sscanf(port.c_str(), "%d", &port_num) != 1 || port_num < 0 ||
port_num > 65535) {
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port.c_str());
if (log_errors) LOG(ERROR) << "invalid ipv6 port: '" << port << "'";
goto done;
}
in6->sin6_port = grpc_htons(static_cast<uint16_t>(port_num));
@ -352,8 +340,7 @@ done:
bool grpc_parse_ipv6(const grpc_core::URI& uri,
grpc_resolved_address* resolved_addr) {
if (uri.scheme() != "ipv6") {
gpr_log(GPR_ERROR, "Expected 'ipv6' scheme, got '%s'",
uri.scheme().c_str());
LOG(ERROR) << "Expected 'ipv6' scheme, got '" << uri.scheme() << "'";
return false;
}
return grpc_parse_ipv6_hostport(absl::StripPrefix(uri.path(), "/"),
@ -377,7 +364,7 @@ bool grpc_parse_uri(const grpc_core::URI& uri,
if (uri.scheme() == "ipv6") {
return grpc_parse_ipv6(uri, resolved_addr);
}
gpr_log(GPR_ERROR, "Can't parse scheme '%s'", uri.scheme().c_str());
LOG(ERROR) << "Can't parse scheme '" << uri.scheme() << "'";
return false;
}

View File

@ -32,12 +32,11 @@
#include <string>
#include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/port.h"
@ -372,8 +371,8 @@ int grpc_sockaddr_get_port(const grpc_resolved_address* resolved_addr) {
return 1;
#endif
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_get_port",
addr->sa_family);
LOG(ERROR) << "Unknown socket family " << addr->sa_family
<< " in grpc_sockaddr_get_port";
return 0;
}
}
@ -394,8 +393,8 @@ int grpc_sockaddr_set_port(grpc_resolved_address* resolved_addr, int port) {
grpc_htons(static_cast<uint16_t>(port));
return 1;
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_set_port",
addr->sa_family);
LOG(ERROR) << "Unknown socket family " << addr->sa_family
<< " in grpc_sockaddr_set_port";
return 0;
}
}

View File

@ -19,13 +19,13 @@
#include <memory>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
@ -164,14 +164,14 @@ int EpollCreateAndCloexec() {
#ifdef GRPC_LINUX_EPOLL_CREATE1
int fd = epoll_create1(EPOLL_CLOEXEC);
if (fd < 0) {
gpr_log(GPR_ERROR, "epoll_create1 unavailable");
LOG(ERROR) << "epoll_create1 unavailable";
}
#else
int fd = epoll_create(MAX_EPOLL_EVENTS);
if (fd < 0) {
gpr_log(GPR_ERROR, "epoll_create unavailable");
LOG(ERROR) << "epoll_create unavailable";
} else if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) {
gpr_log(GPR_ERROR, "fcntl following epoll_create failed");
LOG(ERROR) << "fcntl following epoll_create failed";
return -1;
}
#endif
@ -297,8 +297,8 @@ void Epoll1EventHandle::OrphanHandle(PosixEngineClosure* on_done,
epoll_event phony_event;
if (epoll_ctl(poller_->g_epoll_set_.epfd, EPOLL_CTL_DEL, fd_,
&phony_event) != 0) {
gpr_log(GPR_ERROR, "OrphanHandle: epoll_ctl failed: %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "OrphanHandle: epoll_ctl failed: "
<< grpc_core::StrError(errno);
}
}
*release_fd = fd_;
@ -341,8 +341,8 @@ void Epoll1EventHandle::HandleShutdownInternal(absl::Status why,
epoll_event phony_event;
if (epoll_ctl(poller_->g_epoll_set_.epfd, EPOLL_CTL_DEL, fd_,
&phony_event) != 0) {
gpr_log(GPR_ERROR, "HandleShutdownInternal: epoll_ctl failed: %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "HandleShutdownInternal: epoll_ctl failed: "
<< grpc_core::StrError(errno);
}
}
write_closure_->SetShutdown(why);
@ -356,7 +356,7 @@ Epoll1Poller::Epoll1Poller(Scheduler* scheduler)
wakeup_fd_ = *CreateWakeupFd();
CHECK(wakeup_fd_ != nullptr);
CHECK_GE(g_epoll_set_.epfd, 0);
gpr_log(GPR_INFO, "grpc epoll fd: %d", g_epoll_set_.epfd);
LOG(INFO) << "grpc epoll fd: " << g_epoll_set_.epfd;
struct epoll_event ev;
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
ev.data.ptr = wakeup_fd_.get();
@ -414,8 +414,7 @@ EventHandle* Epoll1Poller::CreateHandle(int fd, absl::string_view /*name*/,
ev.data.ptr = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(new_handle) |
(track_err ? 1 : 0));
if (epoll_ctl(g_epoll_set_.epfd, EPOLL_CTL_ADD, fd, &ev) != 0) {
gpr_log(GPR_ERROR, "epoll_ctl failed: %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "epoll_ctl failed: " << grpc_core::StrError(errno);
}
return new_handle;

View File

@ -14,7 +14,8 @@
#include "src/core/lib/event_engine/posix_engine/internal_errqueue.h"
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
@ -49,7 +50,7 @@ bool KernelSupportsErrqueue() {
// least 4.0.0
struct utsname buffer;
if (uname(&buffer) != 0) {
gpr_log(GPR_ERROR, "uname: %s", grpc_core::StrError(errno).c_str());
LOG(ERROR) << "uname: " << grpc_core::StrError(errno);
return false;
}
char* release = buffer.release;
@ -60,7 +61,7 @@ bool KernelSupportsErrqueue() {
if (strtol(release, nullptr, 10) >= 4) {
return true;
} else {
gpr_log(GPR_DEBUG, "ERRQUEUE support not enabled");
VLOG(2) << "ERRQUEUE support not enabled";
}
#endif // GRPC_LINUX_ERRQUEUE
return false;

View File

@ -37,7 +37,6 @@
#include <grpc/event_engine/slice.h>
#include <grpc/event_engine/slice_buffer.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
@ -503,9 +502,7 @@ void PosixEndpointImpl::UpdateRcvLowat() {
if (result.ok()) {
set_rcvlowat_ = *result;
} else {
gpr_log(GPR_ERROR, "%s",
absl::StrCat("ERROR in SO_RCVLOWAT: ", result.status().message())
.c_str());
LOG(ERROR) << "ERROR in SO_RCVLOWAT: " << result.status().message();
}
}
@ -1280,15 +1277,14 @@ PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
if (zerocopy_enabled) {
if (GetRLimitMemLockMax() == 0) {
zerocopy_enabled = false;
gpr_log(
GPR_ERROR,
"Tx zero-copy will not be used by gRPC since RLIMIT_MEMLOCK value is "
"not set. Consider raising its value with setrlimit().");
LOG(ERROR) << "Tx zero-copy will not be used by gRPC since RLIMIT_MEMLOCK"
<< " value is not set. Consider raising its value with "
<< "setrlimit().";
} else if (GetUlimitHardMemLock() == 0) {
zerocopy_enabled = false;
gpr_log(GPR_ERROR,
"Tx zero-copy will not be used by gRPC since hard memlock ulimit "
"value is not set. Use ulimit -l <value> to set its value.");
LOG(ERROR) << "Tx zero-copy will not be used by gRPC since hard memlock "
<< "ulimit value is not set. Use ulimit -l <value> to set its "
<< "value.";
} else {
const int enable = 1;
if (setsockopt(fd_, SOL_SOCKET, SO_ZEROCOPY, &enable, sizeof(enable)) !=
@ -1299,10 +1295,9 @@ PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
}
if (zerocopy_enabled) {
gpr_log(GPR_INFO,
"Tx-zero copy enabled for gRPC sends. RLIMIT_MEMLOCK value = "
"%" PRIu64 ",ulimit hard memlock value = %" PRIu64,
GetRLimitMemLockMax(), GetUlimitHardMemLock());
LOG(INFO) << "Tx-zero copy enabled for gRPC sends. RLIMIT_MEMLOCK value "
<< "=" << GetRLimitMemLockMax()
<< ",ulimit hard memlock value = " << GetUlimitHardMemLock();
}
}
#endif // GRPC_LINUX_ERRQUEUE
@ -1314,7 +1309,7 @@ PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
if (setsockopt(fd_, SOL_TCP, TCP_INQ, &one, sizeof(one)) == 0) {
inq_capable_ = true;
} else {
gpr_log(GPR_DEBUG, "cannot set inq fd=%d errno=%d", fd_, errno);
VLOG(2) << "cannot set inq fd=" << fd_ << " errno=" << errno;
inq_capable_ = false;
}
#else

View File

@ -32,13 +32,13 @@
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/event_engine/posix_engine/posix_endpoint.h"
@ -155,8 +155,8 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
// nothing to accept. This is not a performant code path, but if an fd
// limit has been reached, the system is likely in an unhappy state
// regardless.
GRPC_LOG_EVERY_N_SEC(1, GPR_ERROR, "%s",
"File descriptor limit reached. Retrying.");
LOG_EVERY_N_SEC(ERROR, 1)
<< "File descriptor limit reached. Retrying.";
handle_->NotifyOnRead(notify_on_accept_);
// Do not schedule another timer if one is already armed.
if (retry_timer_armed_.exchange(true)) return;
@ -177,8 +177,8 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
handle_->NotifyOnRead(notify_on_accept_);
return;
default:
gpr_log(GPR_ERROR, "Closing acceptor. Failed accept4: %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "Closing acceptor. Failed accept4: "
<< grpc_core::StrError(errno);
// Shutting down the acceptor. Unref the ref grabbed in
// AsyncConnectionAcceptor::Start().
Unref();
@ -192,13 +192,12 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
socklen_t len = EventEngine::ResolvedAddress::MAX_SIZE_BYTES;
if (getpeername(fd, const_cast<sockaddr*>(addr.address()), &len) < 0) {
auto listener_addr_uri = ResolvedAddressToURI(socket_.addr);
gpr_log(
GPR_ERROR,
"Failed getpeername: %s. Dropping the connection, and continuing "
"to listen on %s:%d.",
grpc_core::StrError(errno).c_str(),
listener_addr_uri.ok() ? listener_addr_uri->c_str() : "<unknown>",
socket_.port);
LOG(ERROR) << "Failed getpeername: " << grpc_core::StrError(errno)
<< ". Dropping the connection, and continuing "
"to listen on "
<< (listener_addr_uri.ok() ? *listener_addr_uri
: "<unknown>")
<< ":" << socket_.port;
close(fd);
handle_->NotifyOnRead(notify_on_accept_);
return;
@ -211,8 +210,8 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
auto result = sock.ApplySocketMutatorInOptions(
GRPC_FD_SERVER_CONNECTION_USAGE, listener_->options_);
if (!result.ok()) {
gpr_log(GPR_ERROR, "Closing acceptor. Failed to apply socket mutator: %s",
result.ToString().c_str());
LOG(ERROR) << "Closing acceptor. Failed to apply socket mutator: "
<< result;
// Shutting down the acceptor. Unref the ref grabbed in
// AsyncConnectionAcceptor::Start().
Unref();
@ -222,8 +221,7 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
// Create an Endpoint here.
auto peer_name = ResolvedAddressToURI(addr);
if (!peer_name.ok()) {
gpr_log(GPR_ERROR, "Invalid address: %s",
peer_name.status().ToString().c_str());
LOG(ERROR) << "Invalid address: " << peer_name.status();
// Shutting down the acceptor. Unref the ref grabbed in
// AsyncConnectionAcceptor::Start().
Unref();

View File

@ -29,7 +29,6 @@
#include "absl/strings/str_replace.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h"
@ -121,10 +120,8 @@ int InitMaxAcceptQueueSize() {
max_accept_queue_size = n;
if (max_accept_queue_size < MIN_SAFE_ACCEPT_QUEUE_SIZE) {
gpr_log(GPR_INFO,
"Suspiciously small accept queue (%d) will probably lead to "
"connection drops",
max_accept_queue_size);
LOG(INFO) << "Suspiciously small accept queue (" << max_accept_queue_size
<< ") will probably lead to connection drops";
}
return max_accept_queue_size;
}
@ -180,8 +177,8 @@ absl::Status PrepareSocket(const PosixTcpOptions& options,
if (bind(fd, socket.addr.address(), socket.addr.size()) < 0) {
auto sockaddr_str = ResolvedAddressToString(socket.addr);
if (!sockaddr_str.ok()) {
gpr_log(GPR_ERROR, "Could not convert sockaddr to string: %s",
sockaddr_str.status().ToString().c_str());
LOG(ERROR) << "Could not convert sockaddr to string: "
<< sockaddr_str.status();
sockaddr_str = "<unparsable>";
}
sockaddr_str = absl::StrReplaceAll(*sockaddr_str, {{"\0", "@"}});
@ -277,14 +274,14 @@ absl::StatusOr<int> ListenerContainerAddAllLocalAddresses(
addr = EventEngine::ResolvedAddress(ifa_it->ifa_addr, len);
ResolvedAddressSetPort(addr, requested_port);
std::string addr_str = *ResolvedAddressToString(addr);
gpr_log(GPR_DEBUG,
"Adding local addr from interface %s flags 0x%x to server: %s",
ifa_name, ifa_it->ifa_flags, addr_str.c_str());
VLOG(2) << absl::StrFormat(
"Adding local addr from interface %s flags 0x%x to server: %s",
ifa_name, ifa_it->ifa_flags, addr_str.c_str());
// We could have multiple interfaces with the same address (e.g.,
// bonding), so look for duplicates.
if (listener_sockets.Find(addr).ok()) {
gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s",
addr_str.c_str(), ifa_name);
VLOG(2) << "Skipping duplicate addr " << addr_str << " on interface "
<< ifa_name;
continue;
}
auto result = CreateAndPrepareListenerSocket(options, addr);
@ -348,16 +345,14 @@ absl::StatusOr<int> ListenerContainerAddWildcardAddresses(
}
if (assigned_port > 0) {
if (!v6_sock.ok()) {
gpr_log(GPR_INFO,
"Failed to add :: listener, the environment may not support "
"IPv6: %s",
v6_sock.status().ToString().c_str());
LOG(INFO) << "Failed to add :: listener, the environment may not support "
"IPv6: "
<< v6_sock.status();
}
if (!v4_sock.ok()) {
gpr_log(GPR_INFO,
"Failed to add 0.0.0.0 listener, "
"the environment may not support IPv4: %s",
v4_sock.status().ToString().c_str());
LOG(INFO) << "Failed to add 0.0.0.0 listener, "
"the environment may not support IPv4: "
<< v4_sock.status();
}
return assigned_port;
} else {

View File

@ -18,7 +18,6 @@
#include <limits.h>
#include "absl/cleanup/cleanup.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
@ -50,10 +49,9 @@
#include <cstring>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/tcp_socket_utils.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/gprpp/strerror.h"
@ -629,27 +627,25 @@ void PosixSocketWrapper::TrySetSocketTcpUserTimeout(
// if it is available.
if (g_socket_supports_tcp_user_timeout.load() == 0) {
if (0 != getsockopt(fd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
gpr_log(GPR_INFO,
"TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT won't "
"be used thereafter");
LOG(INFO) << "TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT "
"won't be used thereafter";
g_socket_supports_tcp_user_timeout.store(-1);
} else {
gpr_log(GPR_INFO,
"TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will be "
"used thereafter");
LOG(INFO) << "TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will be "
"used thereafter";
g_socket_supports_tcp_user_timeout.store(1);
}
}
if (g_socket_supports_tcp_user_timeout.load() > 0) {
if (0 != setsockopt(fd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
sizeof(timeout))) {
gpr_log(GPR_ERROR, "setsockopt(TCP_USER_TIMEOUT) %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "setsockopt(TCP_USER_TIMEOUT) "
<< grpc_core::StrError(errno);
return;
}
if (0 != getsockopt(fd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
gpr_log(GPR_ERROR, "getsockopt(TCP_USER_TIMEOUT) %s",
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "getsockopt(TCP_USER_TIMEOUT) "
<< grpc_core::StrError(errno);
return;
}
if (newval != timeout) {
@ -694,8 +690,7 @@ bool PosixSocketWrapper::IsIpv6LoopbackAvailable() {
if (bind(fd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == 0) {
loopback_available = true;
} else {
gpr_log(GPR_INFO,
"Disabling AF_INET6 sockets because ::1 is not available.");
LOG(INFO) << "Disabling AF_INET6 sockets because ::1 is not available.";
}
close(fd);
}

View File

@ -54,12 +54,11 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/resolved_address.h"
@ -286,8 +285,8 @@ int ResolvedAddressGetPort(const EventEngine::ResolvedAddress& resolved_addr) {
return 1;
#endif
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in ResolvedAddressGetPort",
addr->sa_family);
LOG(ERROR) << "Unknown socket family " << addr->sa_family
<< " in ResolvedAddressGetPort";
abort();
}
}
@ -309,8 +308,8 @@ void ResolvedAddressSetPort(EventEngine::ResolvedAddress& resolved_addr,
htons(static_cast<uint16_t>(port));
return;
default:
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_set_port",
addr->sa_family);
LOG(ERROR) << "Unknown socket family " << addr->sa_family
<< " in grpc_sockaddr_set_port";
abort();
}
}
@ -446,8 +445,7 @@ absl::StatusOr<EventEngine::ResolvedAddress> URIToResolvedAddress(
grpc_resolved_address addr;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(address_str);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "Failed to parse URI. Error: %s",
uri.status().ToString().c_str());
LOG(ERROR) << "Failed to parse URI. Error: " << uri.status();
}
GRPC_RETURN_IF_ERROR(uri.status());
CHECK(grpc_parse_uri(*uri, &addr));

View File

@ -32,7 +32,6 @@
#include "absl/time/time.h"
#include "absl/types/optional.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/thd_id.h>
@ -157,11 +156,10 @@ std::atomic<size_t> g_reported_dump_count{0};
void DumpSignalHandler(int /* sig */) {
const auto trace = grpc_core::GetCurrentStackTrace();
if (!trace.has_value()) {
gpr_log(GPR_ERROR, "DumpStack::%" PRIdPTR ": Stack trace not available",
gpr_thd_currentid());
LOG(ERROR) << "DumpStack::" << gpr_thd_currentid()
<< ": Stack trace not available";
} else {
gpr_log(GPR_ERROR, "DumpStack::%" PRIdPTR ": %s", gpr_thd_currentid(),
trace->c_str());
LOG(ERROR) << "DumpStack::" << gpr_thd_currentid() << ": " << trace.value();
}
g_reported_dump_count.fetch_add(1);
grpc_core::Thread::Kill(gpr_thd_currentid());
@ -351,10 +349,9 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::UntrackThread(
void WorkStealingThreadPool::WorkStealingThreadPoolImpl::DumpStacksAndCrash() {
grpc_core::MutexLock lock(&thd_set_mu_);
gpr_log(GPR_ERROR,
"Pool did not quiesce in time, gRPC will not shut down cleanly. "
"Dumping all %zu thread stacks.",
thds_.size());
LOG(ERROR) << "Pool did not quiesce in time, gRPC will not shut down "
"cleanly. Dumping all "
<< thds_.size() << " thread stacks.";
for (const auto tid : thds_) {
grpc_core::Thread::Signal(tid, kDumpStackSignal);
}

View File

@ -15,6 +15,7 @@
#ifdef GPR_WINDOWS
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log_windows.h>
@ -73,8 +74,7 @@ void WinSocket::Shutdown() {
DisconnectEx(socket_, NULL, 0, 0);
} else {
char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_INFO, "Unable to retrieve DisconnectEx pointer : %s",
utf8_message);
LOG(INFO) << "Unable to retrieve DisconnectEx pointer : " << utf8_message;
gpr_free(utf8_message);
}
closesocket(socket_);

View File

@ -16,6 +16,7 @@
#ifdef GPR_WINDOWS
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
@ -197,11 +198,8 @@ void WindowsEventEngineListener::SinglePortSocketListener::
const auto& overlapped_result =
io_state_->listener_socket->read_info()->result();
if (overlapped_result.wsa_error != 0) {
gpr_log(GPR_ERROR, "%s",
GRPC_WSA_ERROR(overlapped_result.wsa_error,
"Skipping on_accept due to error")
.ToString()
.c_str());
LOG(ERROR) << GRPC_WSA_ERROR(overlapped_result.wsa_error,
"Skipping on_accept due to error");
return close_socket_and_restart();
}
SOCKET tmp_listener_socket = io_state_->listener_socket->raw_socket();
@ -210,8 +208,7 @@ void WindowsEventEngineListener::SinglePortSocketListener::
reinterpret_cast<char*>(&tmp_listener_socket),
sizeof(tmp_listener_socket));
if (err != 0) {
gpr_log(GPR_ERROR, "%s",
GRPC_WSA_ERROR(WSAGetLastError(), "setsockopt").ToString().c_str());
LOG(ERROR) << GRPC_WSA_ERROR(WSAGetLastError(), "setsockopt");
return close_socket_and_restart();
}
EventEngine::ResolvedAddress peer_address;
@ -220,9 +217,7 @@ void WindowsEventEngineListener::SinglePortSocketListener::
const_cast<sockaddr*>(peer_address.address()),
&peer_name_len);
if (err != 0) {
gpr_log(
GPR_ERROR, "%s",
GRPC_WSA_ERROR(WSAGetLastError(), "getpeername").ToString().c_str());
LOG(ERROR) << GRPC_WSA_ERROR(WSAGetLastError(), "getpeername");
return close_socket_and_restart();
}
peer_address =
@ -231,8 +226,7 @@ void WindowsEventEngineListener::SinglePortSocketListener::
std::string peer_name = "unknown";
if (!addr_uri.ok()) {
// TODO(hork): test an early exit/restart here with end2end tests
gpr_log(GPR_ERROR, "invalid peer name: %s",
addr_uri.status().ToString().c_str());
LOG(ERROR) << "invalid peer name: " << addr_uri.status();
} else {
peer_name = *addr_uri;
}
@ -398,11 +392,10 @@ WindowsEventEngineListener::AddSinglePortSocketListener(
grpc_core::MutexLock lock(&port_listeners_mu_);
port_listeners_.emplace_back(std::move(*single_port_listener));
if (started_.load()) {
gpr_log(GPR_ERROR,
"WindowsEventEngineListener::%p Bind was called concurrently while "
"the Listener was starting. This is invalid usage, all ports must "
"be bound before the Listener is started.",
this);
LOG(ERROR) << "WindowsEventEngineListener::" << this
<< " Bind was called concurrently while the Listener was "
"starting. This is invalid usage, all ports must be bound "
"before the Listener is started.";
GRPC_RETURN_IF_ERROR(single_port_listener_ptr->Start());
}
return single_port_listener_ptr;

View File

@ -26,8 +26,7 @@
#include <string.h>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gprpp/crash.h"
@ -67,13 +66,13 @@ static void create_sockets(SOCKET sv[2]) {
closesocket(lst_sock);
grpc_error_handle error = grpc_tcp_prepare_socket(cli_sock);
if (!error.ok()) {
gpr_log(GPR_INFO, "Prepare cli_sock failed with error: %s",
grpc_core::StatusToString(error).c_str());
LOG(INFO) << "Prepare cli_sock failed with error: "
<< grpc_core::StatusToString(error);
}
error = grpc_tcp_prepare_socket(svr_sock);
if (!error.ok()) {
gpr_log(GPR_INFO, "Prepare svr_sock failed with error: %s",
grpc_core::StatusToString(error).c_str());
LOG(INFO) << "Prepare svr_sock failed with error: "
<< grpc_core::StatusToString(error);
}
sv[1] = cli_sock;

View File

@ -28,9 +28,10 @@
#include <string.h>
#include "absl/log/log.h"
#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/fork.h"
@ -60,24 +61,21 @@ void grpc_prefork() {
}
grpc_core::ExecCtx exec_ctx;
if (!grpc_core::Fork::Enabled()) {
gpr_log(GPR_ERROR,
"Fork support not enabled; try running with the "
"environment variable GRPC_ENABLE_FORK_SUPPORT=1");
LOG(ERROR) << "Fork support not enabled; try running with the "
"environment variable GRPC_ENABLE_FORK_SUPPORT=1";
return;
}
const char* poll_strategy_name = grpc_get_poll_strategy_name();
if (poll_strategy_name == nullptr ||
(strcmp(poll_strategy_name, "epoll1") != 0 &&
strcmp(poll_strategy_name, "poll") != 0)) {
gpr_log(GPR_INFO,
"Fork support is only compatible with the epoll1 and poll polling "
"strategies");
LOG(INFO) << "Fork support is only compatible with the epoll1 and poll "
"polling strategies";
return;
}
if (!grpc_core::Fork::BlockExecCtx()) {
gpr_log(GPR_INFO,
"Other threads are currently calling into gRPC, skipping fork() "
"handlers");
LOG(INFO) << "Other threads are currently calling into gRPC, skipping "
"fork() handlers";
return;
}
grpc_timer_manager_set_threading(false);

View File

@ -25,7 +25,7 @@
#include <errno.h>
#include <net/if.h>
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
@ -33,8 +33,7 @@
uint32_t grpc_if_nametoindex(char* name) {
uint32_t out = if_nametoindex(name);
if (out == 0) {
gpr_log(GPR_DEBUG, "if_nametoindex failed for name %s. errno %d", name,
errno);
VLOG(2) << "if_nametoindex failed for name " << name << ". errno " << errno;
}
return out;
}

View File

@ -22,16 +22,14 @@
#if GRPC_IF_NAMETOINDEX == 0 || !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
uint32_t grpc_if_nametoindex(char* name) {
gpr_log(GPR_DEBUG,
"Not attempting to convert interface name %s to index for current "
"platform.",
name);
VLOG(2) << "Not attempting to convert interface name " << name
<< " to index for current platform.";
return 0;
}

View File

@ -22,8 +22,9 @@
#include <stdlib.h>
#include <string.h>
#include "absl/log/log.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
@ -82,7 +83,7 @@ size_t grpc_iomgr_count_objects_for_testing(void) {
static void dump_objects(const char* kind) {
grpc_iomgr_object* obj;
for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) {
gpr_log(GPR_DEBUG, "%s OBJECT: %s %p", kind, obj->name, obj);
VLOG(2) << kind << " OBJECT: " << obj->name << " " << obj;
}
}
@ -102,9 +103,8 @@ void grpc_iomgr_shutdown() {
gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
if (g_root_object.next != &g_root_object) {
gpr_log(GPR_DEBUG,
"Waiting for %" PRIuPTR " iomgr objects to be destroyed",
count_objects());
VLOG(2) << "Waiting for " << count_objects()
<< " iomgr objects to be destroyed";
}
last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
}
@ -118,11 +118,9 @@ void grpc_iomgr_shutdown() {
}
if (g_root_object.next != &g_root_object) {
if (grpc_iomgr_abort_on_leaks()) {
gpr_log(GPR_DEBUG,
"Failed to free %" PRIuPTR
" iomgr objects before shutdown deadline: "
"memory leaks are likely",
count_objects());
VLOG(2) << "Failed to free " << count_objects()
<< " iomgr objects before shutdown deadline: "
<< "memory leaks are likely";
dump_objects("LEAKED");
abort();
}
@ -133,11 +131,9 @@ void grpc_iomgr_shutdown() {
if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) >
0) {
if (g_root_object.next != &g_root_object) {
gpr_log(GPR_DEBUG,
"Failed to free %" PRIuPTR
" iomgr objects before shutdown deadline: "
"memory leaks are likely",
count_objects());
VLOG(2) << "Failed to free " << count_objects()
<< " iomgr objects before shutdown deadline: "
<< "memory leaks are likely";
dump_objects("LEAKED");
}
break;

View File

@ -32,7 +32,6 @@
#include "absl/strings/str_format.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include "src/core/lib/gprpp/crash.h"
@ -133,8 +132,7 @@ void grpc_winsocket_shutdown(grpc_winsocket* winsocket) {
DisconnectEx(winsocket->socket, NULL, 0, 0);
} else {
char* utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_INFO, "Unable to retrieve DisconnectEx pointer : %s",
utf8_message);
LOG(INFO) << "Unable to retrieve DisconnectEx pointer : " << utf8_message;
gpr_free(utf8_message);
}
// Calling closesocket triggers invocation of any pending I/O operations with
@ -227,8 +225,7 @@ static void probe_ipv6_once(void) {
if (bind(s, reinterpret_cast<grpc_sockaddr*>(&addr), sizeof(addr)) == 0) {
g_ipv6_loopback_available = 1;
} else {
gpr_log(GPR_INFO,
"Disabling AF_INET6 sockets because ::1 is not available.");
LOG(INFO) << "Disabling AF_INET6 sockets because ::1 is not available.";
}
closesocket(s);
}

View File

@ -36,7 +36,6 @@
#include "absl/strings/str_cat.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/address_utils/sockaddr_utils.h"
@ -73,10 +72,8 @@ static void init_max_accept_queue_size(void) {
s_max_accept_queue_size = n;
if (s_max_accept_queue_size < MIN_SAFE_ACCEPT_QUEUE_SIZE) {
gpr_log(GPR_INFO,
"Suspiciously small accept queue (%d) will probably lead to "
"connection drops",
s_max_accept_queue_size);
LOG(INFO) << "Suspiciously small accept queue (" << s_max_accept_queue_size
<< ") will probably lead to connection drops";
}
}

View File

@ -35,7 +35,6 @@
#include "absl/strings/str_cat.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gprpp/crash.h"
@ -151,14 +150,14 @@ grpc_error_handle grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s,
if (!addr_str.ok()) {
return GRPC_ERROR_CREATE(addr_str.status().ToString());
}
gpr_log(GPR_DEBUG,
"Adding local addr from interface %s flags 0x%x to server: %s",
ifa_name, ifa_it->ifa_flags, addr_str->c_str());
VLOG(2) << absl::StrFormat(
"Adding local addr from interface %s flags 0x%x to server: %s",
ifa_name, ifa_it->ifa_flags, addr_str->c_str());
// We could have multiple interfaces with the same address (e.g., bonding),
// so look for duplicates.
if (find_listener_with_addr(s, &addr) != nullptr) {
gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s",
addr_str->c_str(), ifa_name);
VLOG(2) << "Skipping duplicate addr " << *addr_str << " on interface "
<< ifa_name;
continue;
}
if ((err = grpc_tcp_server_add_addr(s, &addr, port_index, fd_index, &dsmode,

View File

@ -35,7 +35,6 @@
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
@ -387,8 +386,8 @@ static void on_accept(void* arg, grpc_error_handle error) {
// this is necessary in the read/write case, it's useless for the accept
// case. We only need to adjust the pending callback count
if (!error.ok()) {
gpr_log(GPR_INFO, "Skipping on_accept due to error: %s",
grpc_core::StatusToString(error).c_str());
LOG(INFO) << "Skipping on_accept due to error: "
<< grpc_core::StatusToString(error);
gpr_mu_unlock(&sp->server->mu);
return;
@ -423,8 +422,7 @@ static void on_accept(void* arg, grpc_error_handle error) {
if (addr_uri.ok()) {
peer_name_string = addr_uri.value();
} else {
gpr_log(GPR_ERROR, "invalid peer name: %s",
addr_uri.status().ToString().c_str());
LOG(ERROR) << "invalid peer name: " << addr_uri.status();
}
} else {
char* utf8_message = gpr_format_message(WSAGetLastError());

View File

@ -26,7 +26,7 @@
#include <string.h>
#include <unistd.h>
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
@ -38,8 +38,8 @@ static grpc_error_handle pipe_init(grpc_wakeup_fd* fd_info) {
int pipefd[2];
int r = pipe(pipefd);
if (0 != r) {
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno,
grpc_core::StrError(errno).c_str());
LOG(ERROR) << "pipe creation failed (" << errno
<< "): " << grpc_core::StrError(errno);
return GRPC_OS_ERROR(errno, "pipe");
}
grpc_error_handle err;

View File

@ -23,13 +23,13 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -103,9 +103,9 @@ absl::Status EndpointList::Endpoint::Init(
CoreConfiguration::Get().lb_policy_registry().CreateLoadBalancingPolicy(
"pick_first", std::move(lb_policy_args));
if (GPR_UNLIKELY(endpoint_list_->tracer_ != nullptr)) {
gpr_log(GPR_INFO, "[%s %p] endpoint %p: created child policy %p",
endpoint_list_->tracer_, endpoint_list_->policy_.get(), this,
child_policy_.get());
LOG(INFO) << "[" << endpoint_list_->tracer_ << " "
<< endpoint_list_->policy_.get() << "] endpoint " << this
<< ": created child policy " << child_policy_.get();
}
// Add our interested_parties pollset_set to that of the newly created
// child policy. This will make the child policy progress upon activity on

View File

@ -22,11 +22,11 @@
#include <algorithm>
#include "absl/log/log.h"
#include "google/protobuf/duration.upb.h"
#include "google/protobuf/timestamp.upb.h"
#include "upb/base/string_view.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -145,9 +145,8 @@ bool ParseServerList(const grpc_lb_v1_LoadBalanceResponse& response,
} else if (token.size <= GRPC_GRPCLB_SERVER_LOAD_BALANCE_TOKEN_MAX_SIZE) {
memcpy(cur.load_balance_token, token.data, token.size);
} else {
gpr_log(GPR_ERROR,
"grpc_lb_v1_LoadBalanceResponse has too long token. len=%zu",
token.size);
LOG(ERROR) << "grpc_lb_v1_LoadBalanceResponse has too long token. len="
<< token.size;
}
cur.drop = grpc_lb_v1_Server_drop(servers[i]);
}

View File

@ -23,6 +23,7 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -30,7 +31,6 @@
#include "absl/strings/string_view.h"
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/load_balancing/lb_policy.h"
@ -43,8 +43,7 @@ namespace grpc_core {
void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
std::unique_ptr<LoadBalancingPolicyFactory> factory) {
gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"",
std::string(factory->name()).c_str());
VLOG(2) << "registering LB policy factory for \"" << factory->name() << "\"";
CHECK(factories_.find(factory->name()) == factories_.end());
factories_.emplace(factory->name(), std::move(factory));
}

View File

@ -30,10 +30,8 @@
#include "absl/types/optional.h"
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/ext/gcp/metadata_query.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/debug_location.h"
@ -49,6 +47,7 @@
#include "src/core/resolver/resolver.h"
#include "src/core/resolver/resolver_factory.h"
#include "src/core/resolver/resolver_registry.h"
#include "src/core/util/gcp_metadata_query.h"
#include "src/core/util/json/json.h"
#include "src/core/util/json/json_writer.h"
#include "src/core/xds/grpc/xds_client_grpc.h"
@ -82,10 +81,10 @@ class GoogleCloud2ProdResolver final : public Resolver {
std::string metadata_server_name_ = "metadata.google.internal.";
bool shutdown_ = false;
OrphanablePtr<MetadataQuery> zone_query_;
OrphanablePtr<GcpMetadataQuery> zone_query_;
absl::optional<std::string> zone_;
OrphanablePtr<MetadataQuery> ipv6_query_;
OrphanablePtr<GcpMetadataQuery> ipv6_query_;
absl::optional<bool> supports_ipv6_;
};
@ -152,8 +151,8 @@ void GoogleCloud2ProdResolver::StartLocked() {
return;
}
// Using xDS. Start metadata server queries.
zone_query_ = MakeOrphanable<MetadataQuery>(
metadata_server_name_, std::string(MetadataQuery::kZoneAttribute),
zone_query_ = MakeOrphanable<GcpMetadataQuery>(
metadata_server_name_, std::string(GcpMetadataQuery::kZoneAttribute),
&pollent_,
[resolver = RefAsSubclass<GoogleCloud2ProdResolver>()](
std::string /* attribute */,
@ -166,8 +165,8 @@ void GoogleCloud2ProdResolver::StartLocked() {
DEBUG_LOCATION);
},
Duration::Seconds(10));
ipv6_query_ = MakeOrphanable<MetadataQuery>(
metadata_server_name_, std::string(MetadataQuery::kIPv6Attribute),
ipv6_query_ = MakeOrphanable<GcpMetadataQuery>(
metadata_server_name_, std::string(GcpMetadataQuery::kIPv6Attribute),
&pollent_,
[resolver = RefAsSubclass<GoogleCloud2ProdResolver>()](
std::string /* attribute */,
@ -306,9 +305,8 @@ class ExperimentalGoogleCloud2ProdResolverFactory final
bool IsValidUri(const URI& uri) const override {
if (GPR_UNLIKELY(!uri.authority().empty())) {
gpr_log(
GPR_ERROR,
"google-c2p-experimental URI scheme does not support authorities");
LOG(ERROR) << "google-c2p-experimental URI scheme does not support "
"authorities";
return false;
}
return true;

View File

@ -24,12 +24,12 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/strip.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/backoff/backoff.h"
@ -60,13 +60,13 @@ PollingResolver::PollingResolver(ResolverArgs args,
min_time_between_resolutions_(min_time_between_resolutions),
backoff_(backoff_options) {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] created", this);
LOG(INFO) << "[polling resolver " << this << "] created";
}
}
PollingResolver::~PollingResolver() {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] destroying", this);
LOG(INFO) << "[polling resolver " << this << "] destroying";
}
}
@ -97,7 +97,7 @@ void PollingResolver::ResetBackoffLocked() {
void PollingResolver::ShutdownLocked() {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] shutting down", this);
LOG(INFO) << "[polling resolver " << this << "] shutting down";
}
shutdown_ = true;
MaybeCancelNextResolutionTimer();
@ -119,9 +119,8 @@ void PollingResolver::ScheduleNextResolutionTimer(const Duration& timeout) {
void PollingResolver::OnNextResolutionLocked() {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO,
"[polling resolver %p] re-resolution timer fired: shutdown_=%d",
this, shutdown_);
LOG(INFO) << "[polling resolver " << this
<< "] re-resolution timer fired: shutdown_=" << shutdown_;
}
// If we haven't been cancelled nor shutdown, then start resolving.
if (next_resolution_timer_handle_.has_value() && !shutdown_) {
@ -133,8 +132,8 @@ void PollingResolver::OnNextResolutionLocked() {
void PollingResolver::MaybeCancelNextResolutionTimer() {
if (next_resolution_timer_handle_.has_value()) {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] cancel re-resolution timer",
this);
LOG(INFO) << "[polling resolver " << this
<< "] cancel re-resolution timer";
}
channel_args_.GetObject<EventEngine>()->Cancel(
*next_resolution_timer_handle_);
@ -151,26 +150,24 @@ void PollingResolver::OnRequestComplete(Result result) {
void PollingResolver::OnRequestCompleteLocked(Result result) {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] request complete", this);
LOG(INFO) << "[polling resolver " << this << "] request complete";
}
request_.reset();
if (!shutdown_) {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO,
"[polling resolver %p] returning result: "
"addresses=%s, service_config=%s, resolution_note=%s",
this,
result.addresses.ok()
LOG(INFO)
<< "[polling resolver " << this << "] returning result: addresses="
<< (result.addresses.ok()
? absl::StrCat("<", result.addresses->size(), " addresses>")
.c_str()
: result.addresses.status().ToString().c_str(),
result.service_config.ok()
: result.addresses.status().ToString())
<< ", service_config="
<< (result.service_config.ok()
? (*result.service_config == nullptr
? "<null>"
: std::string((*result.service_config)->json_string())
.c_str())
: result.service_config.status().ToString().c_str(),
result.resolution_note.c_str());
: result.service_config.status().ToString())
<< ", resolution_note=" << result.resolution_note;
}
CHECK(result.result_health_callback == nullptr);
result.result_health_callback =
@ -186,8 +183,8 @@ void PollingResolver::OnRequestCompleteLocked(Result result) {
void PollingResolver::GetResultStatus(absl::Status status) {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
gpr_log(GPR_INFO, "[polling resolver %p] result status from channel: %s",
this, status.ToString().c_str());
LOG(INFO) << "[polling resolver " << this
<< "] result status from channel: " << status;
}
if (status.ok()) {
// Reset backoff state so that we start from the beginning when the
@ -210,10 +207,10 @@ void PollingResolver::GetResultStatus(absl::Status status) {
CHECK(!next_resolution_timer_handle_.has_value());
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
if (timeout > Duration::Zero()) {
gpr_log(GPR_INFO, "[polling resolver %p] retrying in %" PRId64 " ms",
this, timeout.millis());
LOG(INFO) << "[polling resolver " << this << "] retrying in "
<< timeout.millis() << " ms";
} else {
gpr_log(GPR_INFO, "[polling resolver %p] retrying immediately", this);
LOG(INFO) << "[polling resolver " << this << "] retrying immediately";
}
}
ScheduleNextResolutionTimer(timeout);
@ -241,12 +238,11 @@ void PollingResolver::MaybeStartResolvingLocked() {
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
const Duration last_resolution_ago =
Timestamp::Now() - *last_resolution_timestamp_;
gpr_log(GPR_INFO,
"[polling resolver %p] in cooldown from last resolution "
"(from %" PRId64 " ms ago); will resolve again in %" PRId64
" ms",
this, last_resolution_ago.millis(),
time_until_next_resolution.millis());
LOG(INFO) << "[polling resolver " << this
<< "] in cooldown from last resolution (from "
<< last_resolution_ago.millis()
<< " ms ago); will resolve again in "
<< time_until_next_resolution.millis() << " ms";
}
ScheduleNextResolutionTimer(time_until_next_resolution);
return;
@ -260,11 +256,10 @@ void PollingResolver::StartResolvingLocked() {
last_resolution_timestamp_ = Timestamp::Now();
if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) {
if (request_ != nullptr) {
gpr_log(GPR_INFO,
"[polling resolver %p] starting resolution, request_=%p", this,
request_.get());
LOG(INFO) << "[polling resolver " << this
<< "] starting resolution, request_=" << request_.get();
} else {
gpr_log(GPR_INFO, "[polling resolver %p] StartRequest failed", this);
LOG(INFO) << "[polling resolver " << this << "] StartRequest failed";
}
}
}

View File

@ -17,13 +17,13 @@
#include "src/core/resolver/resolver_registry.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
namespace grpc_core {
@ -147,15 +147,13 @@ ResolverFactory* ResolverRegistry::FindResolverFactory(
return factory;
}
if (!tmp_uri.ok() || !tmp_uri2.ok()) {
gpr_log(GPR_ERROR, "%s",
absl::StrFormat("Error parsing URI(s). '%s':%s; '%s':%s", target,
tmp_uri.status().ToString(), *canonical_target,
tmp_uri2.status().ToString())
.c_str());
LOG(ERROR) << "Error parsing URI(s). '" << target
<< "':" << tmp_uri.status() << "; '" << *canonical_target
<< "':" << tmp_uri2.status();
return nullptr;
}
gpr_log(GPR_ERROR, "Don't know how to resolve '%s' or '%s'.",
std::string(target).c_str(), canonical_target->c_str());
LOG(ERROR) << "Don't know how to resolve '" << target << "' or '"
<< *canonical_target << "'.";
return nullptr;
}

View File

@ -19,11 +19,11 @@
#include <string>
#include <utility>
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/address_utils/parse_address.h"
@ -76,8 +76,8 @@ bool ParseUri(const URI& uri,
bool parse(const URI& uri, grpc_resolved_address* dst),
EndpointAddressesList* addresses) {
if (!uri.authority().empty()) {
gpr_log(GPR_ERROR, "authority-based URIs not supported by the %s scheme",
uri.scheme().c_str());
LOG(ERROR) << "authority-based URIs not supported by the " << uri.scheme()
<< " scheme";
return false;
}
// Construct addresses.

View File

@ -20,9 +20,8 @@
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
namespace grpc_core {
@ -35,10 +34,8 @@ void ServiceConfigParser::Builder::RegisterParser(
std::unique_ptr<Parser> parser) {
for (const auto& registered_parser : registered_parsers_) {
if (registered_parser->name() == parser->name()) {
gpr_log(GPR_ERROR, "%s",
absl::StrCat("Parser with name '", parser->name(),
"' already registered")
.c_str());
LOG(ERROR) << "Parser with name '" << parser->name()
<< "' already registered";
// We'll otherwise crash later.
abort();
}

View File

@ -16,7 +16,9 @@
//
//
#include "src/core/ext/gcp/metadata_query.h"
#include <grpc/support/port_platform.h>
#include "src/core/util/gcp_metadata_query.h"
#include <string.h>
@ -34,7 +36,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -47,29 +48,29 @@ namespace grpc_core {
TraceFlag grpc_metadata_query_trace(false, "metadata_query");
constexpr const char MetadataQuery::kZoneAttribute[];
constexpr const char MetadataQuery::kClusterNameAttribute[];
constexpr const char MetadataQuery::kRegionAttribute[];
constexpr const char MetadataQuery::kInstanceIdAttribute[];
constexpr const char MetadataQuery::kIPv6Attribute[];
constexpr const char GcpMetadataQuery::kZoneAttribute[];
constexpr const char GcpMetadataQuery::kClusterNameAttribute[];
constexpr const char GcpMetadataQuery::kRegionAttribute[];
constexpr const char GcpMetadataQuery::kInstanceIdAttribute[];
constexpr const char GcpMetadataQuery::kIPv6Attribute[];
MetadataQuery::MetadataQuery(
GcpMetadataQuery::GcpMetadataQuery(
std::string attribute, grpc_polling_entity* pollent,
absl::AnyInvocable<void(std::string /* attribute */,
absl::StatusOr<std::string> /* result */)>
callback,
Duration timeout)
: MetadataQuery("metadata.google.internal.", std::move(attribute), pollent,
std::move(callback), timeout) {}
: GcpMetadataQuery("metadata.google.internal.", std::move(attribute),
pollent, std::move(callback), timeout) {}
MetadataQuery::MetadataQuery(
GcpMetadataQuery::GcpMetadataQuery(
std::string metadata_server_name, std::string attribute,
grpc_polling_entity* pollent,
absl::AnyInvocable<void(std::string /* attribute */,
absl::StatusOr<std::string> /* result */)>
callback,
Duration timeout)
: InternallyRefCounted<MetadataQuery>(nullptr, 2),
: InternallyRefCounted<GcpMetadataQuery>(nullptr, 2),
attribute_(std::move(attribute)),
callback_(std::move(callback)) {
GRPC_CLOSURE_INIT(&on_done_, OnDone, this, nullptr);
@ -90,15 +91,17 @@ MetadataQuery::MetadataQuery(
http_request_->Start();
}
MetadataQuery::~MetadataQuery() { grpc_http_response_destroy(&response_); }
GcpMetadataQuery::~GcpMetadataQuery() {
grpc_http_response_destroy(&response_);
}
void MetadataQuery::Orphan() {
void GcpMetadataQuery::Orphan() {
http_request_.reset();
Unref();
}
void MetadataQuery::OnDone(void* arg, grpc_error_handle error) {
auto* self = static_cast<MetadataQuery*>(arg);
void GcpMetadataQuery::OnDone(void* arg, grpc_error_handle error) {
auto* self = static_cast<GcpMetadataQuery*>(arg);
if (GRPC_TRACE_FLAG_ENABLED(grpc_metadata_query_trace)) {
gpr_log(GPR_INFO, "MetadataServer Query for %s: HTTP status: %d, error: %s",
self->attribute_.c_str(), self->response_.status,

View File

@ -14,16 +14,16 @@
// limitations under the License.
//
#ifndef GRPC_SRC_CORE_EXT_GCP_METADATA_QUERY_H
#define GRPC_SRC_CORE_EXT_GCP_METADATA_QUERY_H
#ifndef GRPC_SRC_CORE_UTIL_GCP_METADATA_QUERY_H
#define GRPC_SRC_CORE_UTIL_GCP_METADATA_QUERY_H
#include <grpc/support/port_platform.h>
#include <string>
#include "absl/functional/any_invocable.h"
#include "absl/status/statusor.h"
#include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
@ -36,7 +36,7 @@ namespace grpc_core {
// Fetches the value of an attribute from the MetadataServer on a GCP
// environment.
class MetadataQuery : public InternallyRefCounted<MetadataQuery> {
class GcpMetadataQuery : public InternallyRefCounted<GcpMetadataQuery> {
public:
static constexpr const char kZoneAttribute[] =
"/computeMetadata/v1/instance/zone";
@ -49,7 +49,7 @@ class MetadataQuery : public InternallyRefCounted<MetadataQuery> {
static constexpr const char kIPv6Attribute[] =
"/computeMetadata/v1/instance/network-interfaces/0/ipv6s";
MetadataQuery(
GcpMetadataQuery(
std::string attribute, grpc_polling_entity* pollent,
absl::AnyInvocable<void(std::string /* attribute */,
absl::StatusOr<std::string> /* result */)>
@ -58,7 +58,7 @@ class MetadataQuery : public InternallyRefCounted<MetadataQuery> {
// Alternative ctor allows overriding the metadata server address, mainly
// to inject fakes in tests
MetadataQuery(
GcpMetadataQuery(
std::string metadata_server_name, std::string attribute,
grpc_polling_entity* pollent,
absl::AnyInvocable<void(std::string /* attribute */,
@ -66,7 +66,7 @@ class MetadataQuery : public InternallyRefCounted<MetadataQuery> {
callback,
Duration timeout);
~MetadataQuery() override;
~GcpMetadataQuery() override;
void Orphan() override;
@ -84,4 +84,4 @@ class MetadataQuery : public InternallyRefCounted<MetadataQuery> {
} // namespace grpc_core
#endif // GRPC_SRC_CORE_EXT_GCP_METADATA_QUERY_H
#endif // GRPC_SRC_CORE_UTIL_GCP_METADATA_QUERY_H

View File

@ -18,10 +18,10 @@
#include "src/core/xds/grpc/certificate_provider_store.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/config/core_configuration.h"
@ -131,8 +131,8 @@ CertificateProviderStore::CreateCertificateProviderLocked(
// This should never happen since an entry is only inserted in the
// plugin_config_map_ if the corresponding factory was found when parsing
// the xDS bootstrap file.
gpr_log(GPR_ERROR, "Certificate provider factory %s not found",
plugin_config_it->second.plugin_name.c_str());
LOG(ERROR) << "Certificate provider factory "
<< plugin_config_it->second.plugin_name << " not found";
return nullptr;
}
return MakeRefCounted<CertificateProviderWrapper>(

View File

@ -23,10 +23,10 @@
#include <memory>
#include <vector>
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -115,8 +115,8 @@ RefCountedPtr<grpc_tls_certificate_provider>
FileWatcherCertificateProviderFactory::CreateCertificateProvider(
RefCountedPtr<CertificateProviderFactory::Config> config) {
if (config->name() != name()) {
gpr_log(GPR_ERROR, "Wrong config type Actual:%s vs Expected:%s",
std::string(config->name()).c_str(), std::string(name()).c_str());
LOG(ERROR) << "Wrong config type Actual:" << config->name()
<< " vs Expected:" << name();
return nullptr;
}
auto* file_watcher_config =

View File

@ -33,7 +33,6 @@
#include <grpc/support/sync.h>
#include <grpcpp/impl/grpc_library.h>
#include "src/core/ext/gcp/metadata_query.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/crash.h"
@ -49,6 +48,7 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/util/gcp_metadata_query.h"
namespace grpc {
namespace internal {
@ -202,18 +202,18 @@ class EnvironmentAutoDetectHelper
resource_.labels.emplace("namespace_name", GetNamespaceName());
resource_.labels.emplace("pod_name", GetPodName());
resource_.labels.emplace("container_name", GetContainerName());
attributes_to_fetch_.emplace(grpc_core::MetadataQuery::kZoneAttribute,
attributes_to_fetch_.emplace(grpc_core::GcpMetadataQuery::kZoneAttribute,
"location");
attributes_to_fetch_.emplace(
grpc_core::MetadataQuery::kClusterNameAttribute, "cluster_name");
grpc_core::GcpMetadataQuery::kClusterNameAttribute, "cluster_name");
}
// Cloud Functions
else if (grpc_core::GetEnv("FUNCTION_NAME").has_value() ||
grpc_core::GetEnv("FUNCTION_TARGET").has_value()) {
resource_.resource_type = "cloud_function";
resource_.labels.emplace("function_name", GetFunctionName());
attributes_to_fetch_.emplace(grpc_core::MetadataQuery::kRegionAttribute,
"region");
attributes_to_fetch_.emplace(
grpc_core::GcpMetadataQuery::kRegionAttribute, "region");
}
// Cloud Run
else if (grpc_core::GetEnv("K_CONFIGURATION").has_value()) {
@ -221,15 +221,15 @@ class EnvironmentAutoDetectHelper
resource_.labels.emplace("revision_name", GetRevisionName());
resource_.labels.emplace("service_name", GetServiceName());
resource_.labels.emplace("configuration_name", GetConfiguratioName());
attributes_to_fetch_.emplace(grpc_core::MetadataQuery::kRegionAttribute,
"location");
attributes_to_fetch_.emplace(
grpc_core::GcpMetadataQuery::kRegionAttribute, "location");
}
// App Engine
else if (grpc_core::GetEnv("GAE_SERVICE").has_value()) {
resource_.resource_type = "gae_app";
resource_.labels.emplace("module_id", GetModuleId());
resource_.labels.emplace("version_id", GetVersionId());
attributes_to_fetch_.emplace(grpc_core::MetadataQuery::kZoneAttribute,
attributes_to_fetch_.emplace(grpc_core::GcpMetadataQuery::kZoneAttribute,
"zone");
}
// Assume GCE
@ -237,8 +237,8 @@ class EnvironmentAutoDetectHelper
assuming_gce_ = true;
resource_.resource_type = "gce_instance";
attributes_to_fetch_.emplace(
grpc_core::MetadataQuery::kInstanceIdAttribute, "instance_id");
attributes_to_fetch_.emplace(grpc_core::MetadataQuery::kZoneAttribute,
grpc_core::GcpMetadataQuery::kInstanceIdAttribute, "instance_id");
attributes_to_fetch_.emplace(grpc_core::GcpMetadataQuery::kZoneAttribute,
"zone");
}
FetchMetadataServerAttributesAsynchronouslyLocked();
@ -248,7 +248,7 @@ class EnvironmentAutoDetectHelper
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
CHECK(!attributes_to_fetch_.empty());
for (auto& element : attributes_to_fetch_) {
queries_.push_back(grpc_core::MakeOrphanable<grpc_core::MetadataQuery>(
queries_.push_back(grpc_core::MakeOrphanable<grpc_core::GcpMetadataQuery>(
element.first, &pollent_,
[this](std::string attribute, absl::StatusOr<std::string> result) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_environment_autodetect_trace)) {
@ -317,7 +317,7 @@ class EnvironmentAutoDetectHelper
absl::flat_hash_map<std::string /* metadata_server_attribute */,
std::string /* resource_attribute */>
attributes_to_fetch_ ABSL_GUARDED_BY(mu_);
std::vector<grpc_core::OrphanablePtr<grpc_core::MetadataQuery>> queries_
std::vector<grpc_core::OrphanablePtr<grpc_core::GcpMetadataQuery>> queries_
ABSL_GUARDED_BY(mu_);
EnvironmentAutoDetect::ResourceType resource_ ABSL_GUARDED_BY(mu_);
// This would be true if we are assuming the resource to be GCE. In this case,

View File

@ -52,7 +52,6 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/rbac/rbac_service_config_parser.cc',
'src/core/ext/filters/stateful_session/stateful_session_filter.cc',
'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc',
'src/core/ext/gcp/metadata_query.cc',
'src/core/ext/transport/chttp2/alpn/alpn.cc',
'src/core/ext/transport/chttp2/client/chttp2_connector.cc',
'src/core/ext/transport/chttp2/server/chttp2_server.cc',
@ -807,6 +806,7 @@ CORE_SOURCE_FILES = [
'src/core/util/alloc.cc',
'src/core/util/android/log.cc',
'src/core/util/atm.cc',
'src/core/util/gcp_metadata_query.cc',
'src/core/util/http_client/format_request.cc',
'src/core/util/http_client/httpcli.cc',
'src/core/util/http_client/httpcli_security_connector.cc',

View File

@ -1160,8 +1160,6 @@ src/core/ext/filters/stateful_session/stateful_session_filter.cc \
src/core/ext/filters/stateful_session/stateful_session_filter.h \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h \
src/core/ext/gcp/metadata_query.cc \
src/core/ext/gcp/metadata_query.h \
src/core/ext/transport/binder/client/binder_connector.cc \
src/core/ext/transport/binder/client/binder_connector.h \
src/core/ext/transport/binder/client/channel_create.cc \
@ -2918,6 +2916,8 @@ src/core/util/alloc.cc \
src/core/util/alloc.h \
src/core/util/android/log.cc \
src/core/util/atm.cc \
src/core/util/gcp_metadata_query.cc \
src/core/util/gcp_metadata_query.h \
src/core/util/http_client/format_request.cc \
src/core/util/http_client/format_request.h \
src/core/util/http_client/httpcli.cc \

View File

@ -964,8 +964,6 @@ src/core/ext/filters/stateful_session/stateful_session_filter.cc \
src/core/ext/filters/stateful_session/stateful_session_filter.h \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \
src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h \
src/core/ext/gcp/metadata_query.cc \
src/core/ext/gcp/metadata_query.h \
src/core/ext/transport/README.md \
src/core/ext/transport/binder/README.md \
src/core/ext/transport/chttp2/README.md \
@ -2700,6 +2698,8 @@ src/core/util/alloc.cc \
src/core/util/alloc.h \
src/core/util/android/log.cc \
src/core/util/atm.cc \
src/core/util/gcp_metadata_query.cc \
src/core/util/gcp_metadata_query.h \
src/core/util/http_client/format_request.cc \
src/core/util/http_client/format_request.h \
src/core/util/http_client/httpcli.cc \