From 64b7fce68c4e450f07b3b78c8774f1d724984e55 Mon Sep 17 00:00:00 2001 From: Alisha Nanda Date: Mon, 7 Oct 2024 10:16:48 -0700 Subject: [PATCH 01/22] Add new function to EventEngineSupportsFdExtension query extension that takes in a configured and bound but unconnected fd, connects to the given remote peer, and returns a resulting EventEngine::Endpoint. PiperOrigin-RevId: 683229732 --- .../lib/event_engine/extensions/supports_fd.h | 17 +++++++ .../event_engine/posix_engine/posix_engine.cc | 51 ++++++++++++------- .../event_engine/posix_engine/posix_engine.h | 15 +++--- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/src/core/lib/event_engine/extensions/supports_fd.h b/src/core/lib/event_engine/extensions/supports_fd.h index c7a1bfdcd4fcb..070bce175de2b 100644 --- a/src/core/lib/event_engine/extensions/supports_fd.h +++ b/src/core/lib/event_engine/extensions/supports_fd.h @@ -119,6 +119,23 @@ class EventEngineSupportsFdExtension { virtual std::unique_ptr CreateEndpointFromFd( int fd, const EndpointConfig& config) = 0; + /// Creates an EventEngine::Endpoint from a file descriptor that is configured + /// and bound locally but not yet connected to a remote peer. Returns a + /// connection handle to cancel the connection attempt if needed. Created + /// endpoint will be returned through `on_connect` callback. + /// \a fd - The socket file descriptor. + /// \a on_connect - The callback to invoke once fd is connected to peer. + /// \a addr - The remote peer to connect to. This should be the mapped peer + /// address returned when creating a new socket. + /// \a config - Additional configuration to be applied to the endpoint. + /// \a memory_allocator - The endpoint may use the provided memory allocator + /// to track memory allocations. + /// \a timeout - The timeout to use for the connection attempt. + virtual EventEngine::ConnectionHandle CreateEndpointFromUnconnectedFd( + int fd, EventEngine::OnConnectCallback on_connect, + const EventEngine::ResolvedAddress& addr, const EndpointConfig& config, + MemoryAllocator memory_allocator, EventEngine::Duration timeout) = 0; + /// Called when the posix listener has accepted a new client connection. /// \a listener_fd - The listening socket fd that accepted the new client /// connection. diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc index f2275975b0d37..1c7f6df10b1b9 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -238,14 +238,16 @@ void AsyncConnect::OnWritable(absl::Status status) } } -EventEngine::ConnectionHandle PosixEventEngine::ConnectInternal( - PosixSocketWrapper sock, OnConnectCallback on_connect, ResolvedAddress addr, - MemoryAllocator&& allocator, const PosixTcpOptions& options, - Duration timeout) { +EventEngine::ConnectionHandle +PosixEventEngine::CreateEndpointFromUnconnectedFdInternal( + int fd, EventEngine::OnConnectCallback on_connect, + const EventEngine::ResolvedAddress& addr, + const PosixTcpOptions& tcp_options, MemoryAllocator memory_allocator, + EventEngine::Duration timeout) { int err; int connect_errno; do { - err = connect(sock.Fd(), addr.address(), addr.size()); + err = connect(fd, addr.address(), addr.size()); } while (err < 0 && errno == EINTR); connect_errno = (err < 0) ? errno : 0; @@ -261,16 +263,15 @@ EventEngine::ConnectionHandle PosixEventEngine::ConnectInternal( std::string name = absl::StrCat("tcp-client:", addr_uri.value()); PosixEventPoller* poller = poller_manager_->Poller(); EventHandle* handle = - poller->CreateHandle(sock.Fd(), name, poller->CanTrackErrors()); + poller->CreateHandle(fd, name, poller->CanTrackErrors()); if (connect_errno == 0) { - // Connection already succeded. Return 0 to discourage any cancellation + // Connection already succeeded. Return 0 to discourage any cancellation // attempts. Run([on_connect = std::move(on_connect), - ep = CreatePosixEndpoint(handle, nullptr, shared_from_this(), - std::move(allocator), options)]() mutable { - on_connect(std::move(ep)); - }); + ep = CreatePosixEndpoint( + handle, nullptr, shared_from_this(), std::move(memory_allocator), + tcp_options)]() mutable { on_connect(std::move(ep)); }); return EventEngine::ConnectionHandle::kInvalid; } if (connect_errno != EWOULDBLOCK && connect_errno != EINPROGRESS) { @@ -288,9 +289,10 @@ EventEngine::ConnectionHandle PosixEventEngine::ConnectInternal( // Connection is still in progress. int64_t connection_id = last_connection_id_.fetch_add(1, std::memory_order_acq_rel); - AsyncConnect* ac = new AsyncConnect( - std::move(on_connect), shared_from_this(), executor_.get(), handle, - std::move(allocator), options, addr_uri.value(), connection_id); + AsyncConnect* ac = + new AsyncConnect(std::move(on_connect), shared_from_this(), + executor_.get(), handle, std::move(memory_allocator), + tcp_options, addr_uri.value(), connection_id); int shard_number = connection_id % connection_shards_.size(); struct ConnectionShard* shard = &connection_shards_[shard_number]; { @@ -635,14 +637,29 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect( status = socket.status()]() mutable { on_connect(status); }); return EventEngine::ConnectionHandle::kInvalid; } - return ConnectInternal((*socket).sock, std::move(on_connect), - (*socket).mapped_target_addr, - std::move(memory_allocator), options, timeout); + return CreateEndpointFromUnconnectedFdInternal( + (*socket).sock.Fd(), std::move(on_connect), (*socket).mapped_target_addr, + options, std::move(memory_allocator), timeout); #else // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING grpc_core::Crash("EventEngine::Connect is not supported on this platform"); #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING } +EventEngine::ConnectionHandle PosixEventEngine::CreateEndpointFromUnconnectedFd( + int fd, EventEngine::OnConnectCallback on_connect, + const EventEngine::ResolvedAddress& addr, const EndpointConfig& config, + MemoryAllocator memory_allocator, EventEngine::Duration timeout) { +#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING + return CreateEndpointFromUnconnectedFdInternal( + fd, std::move(on_connect), addr, TcpOptionsFromEndpointConfig(config), + std::move(memory_allocator), timeout); +#else // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING + grpc_core::Crash( + "EventEngine::CreateEndpointFromUnconnectedFd is not supported on this " + "platform"); +#endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING +} + std::unique_ptr PosixEventEngine::CreatePosixEndpointFromFd(int fd, const EndpointConfig& config, diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.h b/src/core/lib/event_engine/posix_engine/posix_engine.h index 82be0bdd0e5a2..63a142a11f281 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -174,6 +174,11 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, std::unique_ptr CreateEndpointFromFd( int fd, const EndpointConfig& config) override; + ConnectionHandle CreateEndpointFromUnconnectedFd( + int fd, EventEngine::OnConnectCallback on_connect, + const EventEngine::ResolvedAddress& addr, const EndpointConfig& config, + MemoryAllocator memory_allocator, EventEngine::Duration timeout) override; + absl::StatusOr> CreateListener( Listener::AcceptCallback on_accept, absl::AnyInvocable on_shutdown, @@ -235,12 +240,10 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, static void PollerWorkInternal( std::shared_ptr poller_manager); - ConnectionHandle ConnectInternal( - grpc_event_engine::experimental::PosixSocketWrapper sock, - OnConnectCallback on_connect, ResolvedAddress addr, - MemoryAllocator&& allocator, - const grpc_event_engine::experimental::PosixTcpOptions& options, - Duration timeout); + ConnectionHandle CreateEndpointFromUnconnectedFdInternal( + int fd, EventEngine::OnConnectCallback on_connect, + const EventEngine::ResolvedAddress& addr, const PosixTcpOptions& options, + MemoryAllocator memory_allocator, EventEngine::Duration timeout); void OnConnectFinishInternal(int connection_handle); From e6ad69e1dd7de6336e9521fad0259bc5be2ee8f2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 7 Oct 2024 11:18:58 -0700 Subject: [PATCH 02/22] Remove `work_serializer_clears_time_cache` experiment (#37851) This was put in as a temporary kludge to carry us until `work_serializer_dispatch` was ready, however since #37637 this is a no-op for all known use cases (and I think it's time for `work_serializer_dispatch` to stick). Closes #37851 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37851 from ctiller:tc 8ae59415bda496143240b76be1a126436ecec397 PiperOrigin-RevId: 683255110 --- bazel/experiments.bzl | 1 - src/core/lib/experiments/experiments.cc | 24 ----------------------- src/core/lib/experiments/experiments.h | 11 ----------- src/core/lib/experiments/experiments.yaml | 6 ------ src/core/util/work_serializer.cc | 3 --- 5 files changed, 45 deletions(-) diff --git a/bazel/experiments.bzl b/bazel/experiments.bzl index 830d4a076d296..5ea1cd99f3708 100644 --- a/bazel/experiments.bzl +++ b/bazel/experiments.bzl @@ -38,7 +38,6 @@ EXPERIMENT_ENABLES = { "time_caching_in_party": "time_caching_in_party", "trace_record_callops": "trace_record_callops", "unconstrained_max_quota_buffer_size": "unconstrained_max_quota_buffer_size", - "work_serializer_clears_time_cache": "work_serializer_clears_time_cache", "work_serializer_dispatch": "work_serializer_dispatch", } diff --git a/src/core/lib/experiments/experiments.cc b/src/core/lib/experiments/experiments.cc index 8464f0756a088..8c9675e0dd255 100644 --- a/src/core/lib/experiments/experiments.cc +++ b/src/core/lib/experiments/experiments.cc @@ -94,10 +94,6 @@ const char* const description_unconstrained_max_quota_buffer_size = "Discard the cap on the max free pool size for one memory allocator"; const char* const additional_constraints_unconstrained_max_quota_buffer_size = "{}"; -const char* const description_work_serializer_clears_time_cache = - "Have the work serializer clear the time cache when it dispatches work."; -const char* const additional_constraints_work_serializer_clears_time_cache = - "{}"; const char* const description_work_serializer_dispatch = "Have the work serializer dispatch work to event engine for every " "callback, instead of running things inline in the first thread that " @@ -159,10 +155,6 @@ const ExperimentMetadata g_experiment_metadata[] = { description_unconstrained_max_quota_buffer_size, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, false, true}, - {"work_serializer_clears_time_cache", - description_work_serializer_clears_time_cache, - additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, - true}, {"work_serializer_dispatch", description_work_serializer_dispatch, additional_constraints_work_serializer_dispatch, nullptr, 0, false, true}, }; @@ -243,10 +235,6 @@ const char* const description_unconstrained_max_quota_buffer_size = "Discard the cap on the max free pool size for one memory allocator"; const char* const additional_constraints_unconstrained_max_quota_buffer_size = "{}"; -const char* const description_work_serializer_clears_time_cache = - "Have the work serializer clear the time cache when it dispatches work."; -const char* const additional_constraints_work_serializer_clears_time_cache = - "{}"; const char* const description_work_serializer_dispatch = "Have the work serializer dispatch work to event engine for every " "callback, instead of running things inline in the first thread that " @@ -308,10 +296,6 @@ const ExperimentMetadata g_experiment_metadata[] = { description_unconstrained_max_quota_buffer_size, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, false, true}, - {"work_serializer_clears_time_cache", - description_work_serializer_clears_time_cache, - additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, - true}, {"work_serializer_dispatch", description_work_serializer_dispatch, additional_constraints_work_serializer_dispatch, nullptr, 0, false, true}, }; @@ -392,10 +376,6 @@ const char* const description_unconstrained_max_quota_buffer_size = "Discard the cap on the max free pool size for one memory allocator"; const char* const additional_constraints_unconstrained_max_quota_buffer_size = "{}"; -const char* const description_work_serializer_clears_time_cache = - "Have the work serializer clear the time cache when it dispatches work."; -const char* const additional_constraints_work_serializer_clears_time_cache = - "{}"; const char* const description_work_serializer_dispatch = "Have the work serializer dispatch work to event engine for every " "callback, instead of running things inline in the first thread that " @@ -457,10 +437,6 @@ const ExperimentMetadata g_experiment_metadata[] = { description_unconstrained_max_quota_buffer_size, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, false, true}, - {"work_serializer_clears_time_cache", - description_work_serializer_clears_time_cache, - additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, - true}, {"work_serializer_dispatch", description_work_serializer_dispatch, additional_constraints_work_serializer_dispatch, nullptr, 0, true, true}, }; diff --git a/src/core/lib/experiments/experiments.h b/src/core/lib/experiments/experiments.h index 8aa59e12f9b45..afc86b9ce5118 100644 --- a/src/core/lib/experiments/experiments.h +++ b/src/core/lib/experiments/experiments.h @@ -84,8 +84,6 @@ inline bool IsTimeCachingInPartyEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS inline bool IsTraceRecordCallopsEnabled() { return true; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE -inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } inline bool IsWorkSerializerDispatchEnabled() { return false; } #elif defined(GPR_WINDOWS) @@ -119,8 +117,6 @@ inline bool IsTimeCachingInPartyEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS inline bool IsTraceRecordCallopsEnabled() { return true; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE -inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } inline bool IsWorkSerializerDispatchEnabled() { return false; } #else @@ -153,8 +149,6 @@ inline bool IsTimeCachingInPartyEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS inline bool IsTraceRecordCallopsEnabled() { return true; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } -#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE -inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_DISPATCH inline bool IsWorkSerializerDispatchEnabled() { return true; } #endif @@ -182,7 +176,6 @@ enum ExperimentIds { kExperimentIdTimeCachingInParty, kExperimentIdTraceRecordCallops, kExperimentIdUnconstrainedMaxQuotaBufferSize, - kExperimentIdWorkSerializerClearsTimeCache, kExperimentIdWorkSerializerDispatch, kNumExperiments }; @@ -270,10 +263,6 @@ inline bool IsTraceRecordCallopsEnabled() { inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return IsExperimentEnabled(); } -#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE -inline bool IsWorkSerializerClearsTimeCacheEnabled() { - return IsExperimentEnabled(); -} #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_DISPATCH inline bool IsWorkSerializerDispatchEnabled() { return IsExperimentEnabled(); diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index ff4bf3869d438..a8f2105f7a519 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -165,12 +165,6 @@ expiry: 2024/09/09 owner: ctiller@google.com test_tags: [resource_quota_test] -- name: work_serializer_clears_time_cache - description: - Have the work serializer clear the time cache when it dispatches work. - expiry: 2024/10/01 - owner: ctiller@google.com - test_tags: [] - name: work_serializer_dispatch description: Have the work serializer dispatch work to event engine for every callback, diff --git a/src/core/util/work_serializer.cc b/src/core/util/work_serializer.cc index c9e0b1d9f4511..38ee82303a27f 100644 --- a/src/core/util/work_serializer.cc +++ b/src/core/util/work_serializer.cc @@ -243,9 +243,6 @@ void WorkSerializer::LegacyWorkSerializer::DrainQueueOwned() { } // There is at least one callback on the queue. Pop the callback from the // queue and execute it. - if (IsWorkSerializerClearsTimeCacheEnabled() && ExecCtx::Get() != nullptr) { - ExecCtx::Get()->InvalidateNow(); - } CallbackWrapper* cb_wrapper = nullptr; bool empty_unused; while ((cb_wrapper = reinterpret_cast( From 204dc57345bb25325c11a5539d1448a0a08cb91f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 7 Oct 2024 15:35:29 -0700 Subject: [PATCH 03/22] [experiments] Push out the expiry of some WIP experiments (#37850) Closes #37850 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37850 from ctiller:fmt aa31cf9d7d8156ab61fbec2e0ca2272af1415e81 PiperOrigin-RevId: 683349868 --- src/core/lib/experiments/experiments.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index a8f2105f7a519..7362efde841d7 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -109,7 +109,7 @@ - name: multiping description: Allow more than one ping to be in flight at a time by default. - expiry: 2024/09/15 + expiry: 2025/03/03 owner: ctiller@google.com test_tags: [flow_control_test] - name: pick_first_new @@ -120,7 +120,7 @@ - name: promise_based_inproc_transport description: Use promises for the in-process transport. - expiry: 2024/09/15 + expiry: 2025/03/03 owner: ctiller@google.com test_tags: [] allow_in_fuzzing_config: false # experiment currently crashes if enabled @@ -162,7 +162,7 @@ test_tags: [] - name: unconstrained_max_quota_buffer_size description: Discard the cap on the max free pool size for one memory allocator - expiry: 2024/09/09 + expiry: 2025/03/03 owner: ctiller@google.com test_tags: [resource_quota_test] - name: work_serializer_dispatch From 2e0eea1e643900f5e79bbbdb6044ee411a5924f2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 8 Oct 2024 08:21:31 -0700 Subject: [PATCH 04/22] [tests] restrict visibility of our internal test-only copy of the xDS protos We really should not have our own copy of these protos in the first place, but there's some tech debt here that hasn't been cleaned up yet. Until we do that, we should at least ensure that this tech debt doesn't spread by having more code depend on them. PiperOrigin-RevId: 683631165 --- bazel/grpc_build_system.bzl | 2 +- src/proto/grpc/testing/xds/v3/BUILD | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 50bd830ef21b3..a90113e2f2959 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -725,7 +725,7 @@ def grpc_package(name, visibility = "private", features = []): features: The features to enable. """ if visibility == "tests": - visibility = ["//test:__subpackages__"] + visibility = ["//test:__subpackages__", "//src/proto/grpc/testing:__subpackages__"] elif visibility == "public": visibility = ["//visibility:public"] elif visibility == "private": diff --git a/src/proto/grpc/testing/xds/v3/BUILD b/src/proto/grpc/testing/xds/v3/BUILD index 15b8e0796c0a9..cc04d3d20fa8b 100644 --- a/src/proto/grpc/testing/xds/v3/BUILD +++ b/src/proto/grpc/testing/xds/v3/BUILD @@ -23,7 +23,7 @@ exports_files([ grpc_package( name = "xds_v3", - visibility = "public", + visibility = "tests", ) grpc_proto_library( @@ -331,6 +331,8 @@ grpc_proto_library( srcs = [ "csds.proto", ], + # Needs to be visible to //:grpcpp_csds + visibility = ["//:__subpackages__"], well_known_protos = True, deps = [ "base_proto", From d56d89f6911e2e85c04d119dbeae44a52831321e Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Tue, 8 Oct 2024 09:09:59 -0700 Subject: [PATCH 05/22] [EventEngine] Remove invalid IOCP closed socket test (#37864) The [CreateIoCompletionPort ](https://learn.microsoft.com/en-us/windows/win32/fileio/createiocompletionport) API specifies that the handle must either be open, or explicitly the `INVALID_HANDLE_VALUE` value. Testing the API with a closed socket is apparently UB. Closes #37864 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37864 from drfloob:rm-iocp-ub-test 514e89989988456b94ddee1a3f2582c1f9885bf0 PiperOrigin-RevId: 683647143 --- test/core/event_engine/windows/iocp_test.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/core/event_engine/windows/iocp_test.cc b/test/core/event_engine/windows/iocp_test.cc index 9e798ff7e212e..2eaaccdc49474 100644 --- a/test/core/event_engine/windows/iocp_test.cc +++ b/test/core/event_engine/windows/iocp_test.cc @@ -250,16 +250,6 @@ TEST_F(IOCPTest, KickThenShutdownCasusesNextWorkerToBeKicked) { thread_pool->Quiesce(); } -TEST_F(IOCPTest, CrashOnWatchingAClosedSocket) { - auto thread_pool = grpc_event_engine::experimental::MakeThreadPool(8); - IOCP iocp(thread_pool.get()); - SOCKET sockpair[2]; - CreateSockpair(sockpair, iocp.GetDefaultSocketFlags()); - closesocket(sockpair[0]); - ASSERT_DEATH({ auto wrapped_client_socket = iocp.Watch(sockpair[0]); }, ""); - thread_pool->Quiesce(); -} - TEST_F(IOCPTest, StressTestThousandsOfSockets) { // Start 10 threads, each with their own IOCP // On each thread, create 50 socket pairs (100 sockets) and have them exchange From 49d63f686aa983c33e04723bbd0095ce8aec1b94 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Tue, 8 Oct 2024 11:07:55 -0700 Subject: [PATCH 06/22] Delete Binder test artifacts and examples (#37862) With the CL-first approach, the docker test configs for Binder need to be deleted before the Binder code and tests themselves can be deleted in the next step. Sanity checks fail otherwise. Closes #37862 PiperOrigin-RevId: 683691175 --- .../binder/java/io/grpc/binder/cpp/README.md | 24 ----- .../cpp/exampleclient/AndroidManifest.xml | 25 ------ .../io/grpc/binder/cpp/exampleclient/BUILD | 51 ----------- .../cpp/exampleclient/ButtonPressHandler.java | 15 ---- .../cpp/exampleclient/MainActivity.java | 26 ------ .../grpc/binder/cpp/exampleclient/native.cc | 72 --------------- .../res/layout/activity_main.xml | 24 ----- .../cpp/exampleclient/res/values/strings.xml | 5 -- .../cpp/exampleserver/AndroidManifest.xml | 21 ----- .../AndroidManifest_endpoint.xml | 10 --- .../io/grpc/binder/cpp/exampleserver/BUILD | 61 ------------- .../cpp/exampleserver/ButtonPressHandler.java | 13 --- .../ExportedEndpointService.java | 26 ------ .../cpp/exampleserver/MainActivity.java | 27 ------ .../grpc/binder/cpp/exampleserver/native.cc | 82 ----------------- .../res/layout/activity_main.xml | 24 ----- .../cpp/exampleserver/res/values/strings.xml | 5 -- .../binder_transport_apk/Dockerfile.template | 49 ----------- .../bazel/test_single_bazel_version.sh | 3 - .../dockerimage_current_versions.bzl | 1 - tools/bazelify_tests/test/strict_tests.bzl | 2 +- .../clang_format_all_the_things.sh | 2 +- .../test/binder_transport_apk.current_version | 1 - .../test/binder_transport_apk/Dockerfile | 87 ------------------- .../linux/grpc_bazel_build_in_docker.sh | 2 - .../linux/grpc_binder_transport_apk.cfg | 30 ------- .../linux/grpc_binder_transport_apk.sh | 27 ------ 27 files changed, 2 insertions(+), 713 deletions(-) delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/README.md delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/AndroidManifest.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/BUILD delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/ButtonPressHandler.java delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/MainActivity.java delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/native.cc delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/res/layout/activity_main.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleclient/res/values/strings.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/AndroidManifest.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/AndroidManifest_endpoint.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/BUILD delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/ButtonPressHandler.java delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/ExportedEndpointService.java delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/MainActivity.java delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/native.cc delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/res/layout/activity_main.xml delete mode 100644 examples/android/binder/java/io/grpc/binder/cpp/exampleserver/res/values/strings.xml delete mode 100644 templates/tools/dockerfile/test/binder_transport_apk/Dockerfile.template delete mode 100644 tools/dockerfile/test/binder_transport_apk.current_version delete mode 100644 tools/dockerfile/test/binder_transport_apk/Dockerfile delete mode 100644 tools/internal_ci/linux/grpc_binder_transport_apk.cfg delete mode 100755 tools/internal_ci/linux/grpc_binder_transport_apk.sh diff --git a/examples/android/binder/java/io/grpc/binder/cpp/README.md b/examples/android/binder/java/io/grpc/binder/cpp/README.md deleted file mode 100644 index 8a9ba6ec26f7f..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# gRPC-core BinderTransport example apps - -## Build Instruction - -1. Install Android SDK and NDK. Only NDK version >= 25 is supported. We tested against SDK Platform `33` and NDK `26.2.11394342`. -2. Make sure Bazel is at least `7.0`. Use `export OVERRIDE_BAZEL_VERSION=7.3.1` to selected a supported version listed in `bazel/supported_versions.txt` if necessary. -3. Point environment variables to install locations of SDK and NDK - ``` - export ANDROID_HOME=$HOME/android-sdk - export ANDROID_NDK_HOME=$HOME/android-sdk/ndk/26.2.11394342 - ``` -4. To build a fat APK that supports `x86_64`, `armv7`, and `arm64`: - ``` - bazel build \ - --extra_toolchains=@androidndk//:all \ - --android_platforms=//bazel/platforms/android:x86_64,//bazel/platforms/android:armeabi-v7a,//bazel/platforms/android:arm64-v8a \ - --copt=-Wno-unknown-warning-option \ - //examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app \ - //examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app - ``` -5. `adb install - bazel-bin/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/app.apk` -6. `adb install - bazel-bin/examples/android/binder/java/io/grpc/binder/cpp/exampleserver/app.apk` diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/AndroidManifest.xml b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/AndroidManifest.xml deleted file mode 100644 index 8dea1553faf1c..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/BUILD b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/BUILD deleted file mode 100644 index 8b11ebb383a4b..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/BUILD +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2021 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. - -cc_library( - name = "jni_lib", - srcs = ["native.cc"], - linkopts = [ - "-ldl", - "-llog", - "-lm", - "-Wl,--no-undefined", - ], - deps = [ - "//:grpc++", - "//examples/protos:helloworld_cc_grpc", - ], - alwayslink = True, -) - -android_library( - name = "activity", - srcs = [ - "ButtonPressHandler.java", - "MainActivity.java", - ], - manifest = "AndroidManifest.xml", - resource_files = glob(["res/**"]), - deps = [ - ":jni_lib", - "@binder_transport_android_helper//io/grpc/binder/cpp:connection_helper", - ], -) - -android_binary( - name = "app", - manifest = "AndroidManifest.xml", - deps = [ - ":activity", - ], -) diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/ButtonPressHandler.java b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/ButtonPressHandler.java deleted file mode 100644 index ed9d11a404bd9..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/ButtonPressHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.grpc.binder.cpp.exampleclient; - -import android.app.Application; - -public class ButtonPressHandler { - static { - System.loadLibrary("app"); - } - - public native String native_entry(Application application); - - public String onPressed(Application application) { - return native_entry(application); - } -} diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/MainActivity.java b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/MainActivity.java deleted file mode 100644 index 3cbf70d1e651f..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/MainActivity.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.grpc.binder.cpp.exampleclient; - -import android.app.Activity; -import android.os.Bundle; -import android.util.Log; -import android.widget.Button; -import android.widget.TextView; - -/** Main class for the example app. */ -public class MainActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Log.v("Example", "hello, world"); - - setContentView(R.layout.activity_main); - - Button clickMeButton = findViewById(R.id.clickMeButton); - TextView exampleTextView = findViewById(R.id.exampleTextView); - - ButtonPressHandler h = new ButtonPressHandler(); - - clickMeButton.setOnClickListener( - v -> exampleTextView.setText(h.onPressed(getApplication()))); - } -} diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/native.cc b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/native.cc deleted file mode 100644 index 3cb8637eb6988..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/native.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2021 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. - -#include -#include -#include -#include - -#include "examples/protos/helloworld.grpc.pb.h" -#include "examples/protos/helloworld.pb.h" - -extern "C" JNIEXPORT jstring JNICALL -Java_io_grpc_binder_cpp_exampleclient_ButtonPressHandler_native_1entry( - JNIEnv* env, jobject /*this*/, jobject application) { - // Lower the gRPC logging level, here it is just for demo and debugging - // purpose. - setenv("GRPC_VERBOSITY", "INFO", true); - if (grpc::experimental::InitializeBinderChannelJavaClass(env)) { - __android_log_print(ANDROID_LOG_INFO, "DemoClient", - "InitializeBinderChannelJavaClass succeed"); - } else { - __android_log_print(ANDROID_LOG_INFO, "DemoClient", - "InitializeBinderChannelJavaClass failed"); - } - static bool first = true; - static std::shared_ptr channel; - if (first) { - first = false; - JavaVM* jvm; - { - jint result = env->GetJavaVM(&jvm); - assert(result == 0); - } - grpc::ChannelArguments ch_args; - // This is not required since "grpc.io.action.BIND" is already the default. - ch_args.SetString("grpc.binder.custom_android_intent_action_name", - "grpc.io.action.BIND"); - channel = grpc::experimental::CreateCustomBinderChannel( - env, application, "io.grpc.binder.cpp.exampleserver", - "io.grpc.binder.cpp.exampleserver.ExportedEndpointService", - std::make_shared< - grpc::experimental::binder::SameSignatureSecurityPolicy>( - jvm, application), - ch_args); - return env->NewStringUTF("Clicked 1 time, channel created"); - } else { - auto stub = helloworld::Greeter::NewStub(channel); - grpc::ClientContext context; - helloworld::HelloRequest request; - helloworld::HelloReply response; - request.set_name("BinderTransportClient"); - grpc::Status status = stub->SayHello(&context, request, &response); - if (status.ok()) { - return env->NewStringUTF(response.message().c_str()); - } - return env->NewStringUTF( - std::string("Clicked more than 1 time. Status not ok " + - std::to_string(status.error_code())) - .c_str()); - } -} diff --git a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/res/layout/activity_main.xml b/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/res/layout/activity_main.xml deleted file mode 100644 index e866d8df89472..0000000000000 --- a/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/res/layout/activity_main.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - -