Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into huffy
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 27, 2025
2 parents 1890cd7 + 37f5195 commit 623f4d9
Show file tree
Hide file tree
Showing 976 changed files with 1,304 additions and 5,839 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ iwyu_build/
# fuzzer logs
fuzz-*.log

# bazel module files (MODULE.bazel will need to be removed here)
MODULE.bazel
# bazel module files
third_party/**/MODULE.bazel
MODULE.bazel.lock
91 changes: 91 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2025 the gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

module(
name = "grpc",
version = "1.71.0-dev",
compatibility_level = 1,
repo_name = "com_github_grpc_grpc",
)

bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl")
bazel_dep(name = "apple_support", version = "1.17.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "boringssl", version = "0.20241024.0") # mistmatched 20241211
bazel_dep(name = "c-ares", version = "1.15.0", repo_name = "com_github_cares_cares") # mistmatched 1.19.1
bazel_dep(name = "envoy_api", version = "0.0.0-20241214-918efc9") # mistmatched 20250106
bazel_dep(name = "google_benchmark", version = "1.9.0", repo_name = "com_github_google_benchmark")
bazel_dep(name = "googleapis", version = "0.0.0-20240819-fe8ba054a", repo_name = "com_google_googleapis")
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest")
bazel_dep(name = "opencensus-cpp", version = "0.0.0-20230502-50eb5de", repo_name = "io_opencensus_cpp")
bazel_dep(name = "opentelemetry-cpp", version = "1.16.0", repo_name = "io_opentelemetry_cpp") # mistmached 1.18.0
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
bazel_dep(name = "protoc-gen-validate", version = "1.0.4.bcr.2", repo_name = "com_envoyproxy_protoc_gen_validate")
bazel_dep(name = "re2", version = "2024-07-02", repo_name = "com_googlesource_code_re2") # mistmached 2022-04-01
bazel_dep(name = "rules_apple", version = "3.16.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_java", version = "8.7.0")
bazel_dep(name = "rules_proto", version = "7.0.2")
bazel_dep(name = "xds", version = "0.0.0-20240423-555b57e", repo_name = "com_github_cncf_xds") # mismatched 20231116
bazel_dep(name = "zlib", version = "1.3.1.bcr.3")

grpc_repo_deps_ext = use_extension("//bazel:grpc_deps.bzl", "grpc_repo_deps_ext")
use_repo(
grpc_repo_deps_ext,
"google_cloud_cpp",
)

switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages(
cc = True,
grpc = True,
python = True,
)

bazel_dep(name = "rules_python", version = "0.37.1")

PYTHON_VERSIONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
]

python = use_extension("@rules_python//python/extensions:python.bzl", "python")

[
python.toolchain(
is_default = python_version == PYTHON_VERSIONS[-1],
python_version = python_version,
)
for python_version in PYTHON_VERSIONS
]

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

[
pip.parse(
hub_name = "grpc_python_dependencies",
python_version = python_version,
requirements_lock = "//:requirements.bazel.txt",
)
for python_version in PYTHON_VERSIONS
]

use_repo(pip, "grpc_python_dependencies")

bazel_dep(name = "cython", version = "3.0.11-1")
25 changes: 15 additions & 10 deletions bazel/grpc_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,7 @@ def grpc_deps():
],
)

if "google_cloud_cpp" not in native.existing_rules():
http_archive(
name = "google_cloud_cpp",
sha256 = "e53ba3799c052d97acac9a6a6b27af24ce822dbde7bfde973bac9e5da714e6b2",
strip_prefix = "google-cloud-cpp-2.33.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.33.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.33.0.tar.gz",
],
)
grpc_module_deps()

grpc_python_deps()

Expand Down Expand Up @@ -448,3 +439,17 @@ def grpc_test_only_deps():
strip_prefix = "libprotobuf-mutator-1f95f8083066f5b38fd2db172e7e7f9aa7c49d2d",
build_file = "@com_github_grpc_grpc//third_party:libprotobuf_mutator.BUILD",
)

def grpc_module_deps():
if "google_cloud_cpp" not in native.existing_rules():
http_archive(
name = "google_cloud_cpp",
sha256 = "e53ba3799c052d97acac9a6a6b27af24ce822dbde7bfde973bac9e5da714e6b2",
strip_prefix = "google-cloud-cpp-2.33.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.33.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.33.0.tar.gz",
],
)

grpc_repo_deps_ext = module_extension(implementation = lambda ctx: grpc_module_deps())
1 change: 1 addition & 0 deletions doc/trace_flags.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/core/ext/filters/message_size/message_size_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ServerMetadataHandle CheckPayload(const Message& msg,
<< (is_send ? "send" : "recv") << " len:" << msg.payload()->Length()
<< " max:" << *max_length;
if (msg.payload()->Length() <= *max_length) return nullptr;
return ServerMetadataFromStatus(
return CancelledServerMetadataFromStatus(
GRPC_STATUS_RESOURCE_EXHAUSTED,
absl::StrFormat("%s: %s message larger than max (%u vs. %d)",
is_client ? "CLIENT" : "SERVER",
Expand All @@ -158,8 +158,9 @@ ServerMetadataHandle CheckPayload(const Message& msg,
}
} // namespace

ClientMessageSizeFilter::Call::Call(ClientMessageSizeFilter* filter)
: limits_(filter->parsed_config_) {
void ClientMessageSizeFilter::Call::OnClientInitialMetadata(
ClientMetadata&, ClientMessageSizeFilter* filter) {
limits_ = filter->parsed_config_;
// Get max sizes from channel data, then merge in per-method config values.
// Note: Per-method config is only available on the client, so we
// apply the max request size to the send limit and the max response
Expand Down
5 changes: 2 additions & 3 deletions src/core/ext/filters/message_size/message_size_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ class ClientMessageSizeFilter final

class Call {
public:
explicit Call(ClientMessageSizeFilter* filter);

static inline const NoInterceptor OnClientInitialMetadata;
void OnClientInitialMetadata(ClientMetadata&,
ClientMessageSizeFilter* filter);
static inline const NoInterceptor OnServerInitialMetadata;
static inline const NoInterceptor OnServerTrailingMetadata;
static inline const NoInterceptor OnFinalize;
Expand Down
9 changes: 9 additions & 0 deletions src/core/ext/transport/chaotic_good/client_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ uint32_t ChaoticGoodClientTransport::MakeStream(CallHandler call_handler) {
const bool on_done_added =
call_handler.OnDone([self = RefAsSubclass<ChaoticGoodClientTransport>(),
stream_id](bool cancelled) {
GRPC_TRACE_LOG(chaotic_good, INFO)
<< "CHAOTIC_GOOD: Client call " << self.get() << " id=" << stream_id
<< " done: cancelled=" << cancelled;
if (cancelled) {
self->outgoing_frames_.MakeSender().UnbufferedImmediateSend(
CancelFrame{stream_id});
Expand Down Expand Up @@ -318,6 +321,12 @@ auto ChaoticGoodClientTransport::CallOutboundLoop(uint32_t stream_id,
[send_fragment]() mutable {
ClientEndOfStream frame;
return send_fragment(std::move(frame));
},
[call_handler]() mutable {
return Map(call_handler.WasCancelled(), [](bool cancelled) {
if (cancelled) return absl::CancelledError();
return absl::OkStatus();
});
}));
}

Expand Down
23 changes: 18 additions & 5 deletions src/core/ext/transport/chttp2/server/chttp2_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,11 @@ NewChttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
RefCountedPtr<ActiveConnection> connection_ref, grpc_tcp_server* tcp_server,
grpc_pollset* accepting_pollset, AcceptorPtr acceptor,
const ChannelArgs& args, OrphanablePtr<grpc_endpoint> endpoint)
: connection_(std::move(connection_ref)),
: InternallyRefCounted(
GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener::ActiveConnection::HandshakingState"
: nullptr),
connection_(std::move(connection_ref)),
tcp_server_(tcp_server),
accepting_pollset_(accepting_pollset),
acceptor_(std::move(acceptor)),
Expand Down Expand Up @@ -1128,7 +1132,10 @@ NewChttp2ServerListener::ActiveConnection::ActiveConnection(
grpc_tcp_server* tcp_server, grpc_pollset* accepting_pollset,
AcceptorPtr acceptor, const ChannelArgs& args, MemoryOwner memory_owner,
OrphanablePtr<grpc_endpoint> endpoint)
: listener_state_(std::move(listener_state)),
: LogicalConnection(GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener::ActiveConnection"
: nullptr),
listener_state_(std::move(listener_state)),
work_serializer_(
args.GetObjectRef<grpc_event_engine::experimental::EventEngine>()),
state_(memory_owner.MakeOrphanable<HandshakingState>(
Expand Down Expand Up @@ -1207,8 +1214,10 @@ void NewChttp2ServerListener::ActiveConnection::SendGoAwayImplLocked() {
// Send a GOAWAY if the transport exists
if (transport != nullptr) {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->goaway_error =
GRPC_ERROR_CREATE("Server is stopping to serve requests.");
// Set an HTTP2 error of NO_ERROR to do graceful GOAWAYs.
op->goaway_error = grpc_error_set_int(
GRPC_ERROR_CREATE("Server is stopping to serve requests."),
StatusIntProperty::kHttp2Error, GRPC_HTTP2_NO_ERROR);
transport->PerformOp(op);
}
});
Expand Down Expand Up @@ -1317,7 +1326,11 @@ NewChttp2ServerListener* NewChttp2ServerListener::CreateForPassiveListener(
NewChttp2ServerListener::NewChttp2ServerListener(
const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener)
: args_(args), passive_listener_(std::move(passive_listener)) {
: ListenerInterface(GRPC_TRACE_FLAG_ENABLED(chttp2_server_refcount)
? "NewChttp2ServerListener"
: nullptr),
args_(args),
passive_listener_(std::move(passive_listener)) {
GRPC_CLOSURE_INIT(&tcp_server_shutdown_complete_, TcpServerShutdownComplete,
this, grpc_schedule_on_exec_ctx);
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/lib/debug/trace_flags.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/lib/debug/trace_flags.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/core/lib/debug/trace_flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ chttp2_hpack_parser:
chttp2_new_stream:
default: false
description: HTTP/2 incoming stream creation.
chttp2_server_refcount:
debug_only: true
default: false
description: Refcounting in Chttp2 Server.
client_channel:
default: false
description: Client channel control plane activity, including resolver and load balancing policy interaction.
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/experiments/experiments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
test_tags: []
- name: call_tracer_in_transport
description: Transport directly passes byte counts to CallTracer.
expiry: 2025/02/01
expiry: 2025/06/01
owner: [email protected]
test_tags: []
- name: callv3_client_auth_filter
Expand Down
51 changes: 39 additions & 12 deletions src/core/lib/promise/try_seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,45 @@ namespace grpc_core {

namespace promise_detail {

// TrySeq Promise combinator.
//
// Input :
// 1. The TrySeq combinator needs minimum one promise as input.
// 2. The first input to TrySeq combinator is a promise.
// 3. The remaining inputs to TrySeq combinator are Promise Factories (functors
// that return a promise). The input type of the Nth functor should be the
// return value of the (N-1)th promise.
// 4. Functors can return promises with return type any of the following :
// 1. StatusOr<> to signal that a value is fed forward, or Status to
// indicate only success/failure. In the case of returning Status, the
// next functor in the chain takes no arguments.
// 2. StatusFlag and ValueOrStatus can be return types if rich error
// information is not necessar. In this case the next functor in the chain
// takes no arguments.
//
// Return :
// Polling the TrySeq Promise combinator returns Poll<StatusOr<T>> where T is
// the type returned by the last promise in the list of input promises.
//
// Polling the TrySeq combinator works in the following way :
// Run the first promise. If it returns Pending{}, nothing else is executed.
// If the first promise returns a value, pass this result to the second functor,
// and run the returned promise. If it returns Pending{}, nothing else is
// executed. If it returns a value, pass this result to the third functor, and
// run the returned promise. etc. Return the final value.
//
// If any of the promises in the TrySeq chain returns a failure status, TrySeq
// will NOT proceed with the execution of the remaining promises. If you want
// the execution to continue when a failure status is received, use the Seq
// combinator instead.
//
// Promises in the TrySeq combinator are run in order, serially and on the same
// thread.
//
// Example :
// The unit tests (esp ThreeTypedPendingThens) in try_seq_test.cc provide all
// possible permutations of how TrySeq combinator can be used.

template <typename T, typename Ignored = void>
struct TrySeqTraitsWithSfinae {
using UnwrappedType = T;
Expand Down Expand Up @@ -256,18 +295,6 @@ struct TrySeqContainerResultTraits {

} // namespace promise_detail

// Try a sequence of operations.
// * Run the first functor as a promise.
// * Feed its success result into the second functor to create a promise,
// then run that.
// * ...
// * Feed the second-final success result into the final functor to create a
// promise, then run that, with the overall success result being that
// promises success result.
// If any step fails, fail everything.
// Functors can return StatusOr<> to signal that a value is fed forward, or
// Status to indicate only success/failure. In the case of returning Status,
// the construction functors take no arguments.
template <typename F>
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline F TrySeq(F functor) {
return functor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ absl::Status ValidateRootCertificates(absl::string_view root_certificates) {
absl::StatusOr<std::vector<X509*>> parsed_roots =
ParsePemCertificateChain(root_certificates);
if (!parsed_roots.ok()) {
return parsed_roots.status();
return absl::Status(
parsed_roots.status().code(),
absl::StrCat("Failed to parse root certificates as PEM: ",
parsed_roots.status().message()));
}
for (X509* x509 : *parsed_roots) {
X509_free(x509);
Expand All @@ -65,7 +68,10 @@ absl::Status ValidatePemKeyCertPair(absl::string_view cert_chain,
absl::StatusOr<std::vector<X509*>> parsed_certs =
ParsePemCertificateChain(cert_chain);
if (!parsed_certs.ok()) {
return parsed_certs.status();
return absl::Status(
parsed_certs.status().code(),
absl::StrCat("Failed to parse certificate chain as PEM: ",
parsed_certs.status().message()));
}
for (X509* x509 : *parsed_certs) {
X509_free(x509);
Expand All @@ -74,7 +80,9 @@ absl::Status ValidatePemKeyCertPair(absl::string_view cert_chain,
absl::StatusOr<EVP_PKEY*> parsed_private_key =
ParsePemPrivateKey(private_key);
if (!parsed_private_key.ok()) {
return parsed_private_key.status();
return absl::Status(parsed_private_key.status().code(),
absl::StrCat("Failed to parse private key as PEM: ",
parsed_private_key.status().message()));
}
EVP_PKEY_free(*parsed_private_key);
return absl::OkStatus();
Expand Down
Loading

0 comments on commit 623f4d9

Please sign in to comment.