diff --git a/BUILD b/BUILD index cbae86852c6..2fbc31236b6 100644 --- a/BUILD +++ b/BUILD @@ -75,11 +75,11 @@ config_setting( python_config_settings() # This should be updated along with build_handwritten.yaml -g_stands_for = "giggle" +g_stands_for = "geeky" -core_version = "11.0.0" +core_version = "12.0.0" -version = "1.32.0-dev" +version = "1.33.0-dev" GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", @@ -251,7 +251,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/security/server_credentials.h", "include/grpcpp/security/tls_credentials_options.h", "include/grpcpp/server.h", - "include/grpcpp/server_impl.h", "include/grpcpp/server_builder.h", "include/grpcpp/server_context.h", "include/grpcpp/server_posix.h", @@ -1811,6 +1810,7 @@ grpc_cc_library( hdrs = [ "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", "src/core/ext/xds/xds_channel_args.h", + "src/core/lib/security/certificate_provider.h", "src/core/lib/security/context/security_context.h", "src/core/lib/security/credentials/alts/alts_credentials.h", "src/core/lib/security/credentials/composite/composite_credentials.h", @@ -1853,6 +1853,24 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_mock_cel", + hdrs = [ + "src/core/lib/security/authorization/mock_cel/activation.h", + "src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h", + "src/core/lib/security/authorization/mock_cel/cel_expression.h", + "src/core/lib/security/authorization/mock_cel/cel_value.h", + "src/core/lib/security/authorization/mock_cel/evaluator_core.h", + "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h", + "src/core/lib/security/authorization/mock_cel/statusor.h", + ], + language = "c++", + deps = [ + "google_api_upb", + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_authorization_engine", srcs = [ @@ -1862,8 +1880,6 @@ grpc_cc_library( hdrs = [ "src/core/lib/security/authorization/authorization_engine.h", "src/core/lib/security/authorization/evaluate_args.h", - "src/core/lib/security/authorization/mock_cel/activation.h", - "src/core/lib/security/authorization/mock_cel/cel_value.h", ], external_deps = [ "absl/container:flat_hash_set", @@ -1873,6 +1889,7 @@ grpc_cc_library( "envoy_ads_upb", "google_api_upb", "grpc_base", + "grpc_mock_cel", "grpc_secure", ], ) diff --git a/BUILD.gn b/BUILD.gn index 0e208a6936e..7040bd6cf35 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -793,7 +793,13 @@ config("grpc_config") { "src/core/lib/security/authorization/evaluate_args.cc", "src/core/lib/security/authorization/evaluate_args.h", "src/core/lib/security/authorization/mock_cel/activation.h", + "src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h", + "src/core/lib/security/authorization/mock_cel/cel_expression.h", "src/core/lib/security/authorization/mock_cel/cel_value.h", + "src/core/lib/security/authorization/mock_cel/evaluator_core.h", + "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h", + "src/core/lib/security/authorization/mock_cel/statusor.h", + "src/core/lib/security/certificate_provider.h", "src/core/lib/security/context/security_context.cc", "src/core/lib/security/context/security_context.h", "src/core/lib/security/credentials/alts/alts_credentials.cc", @@ -1195,7 +1201,6 @@ config("grpc_config") { "include/grpcpp/server.h", "include/grpcpp/server_builder.h", "include/grpcpp/server_context.h", - "include/grpcpp/server_impl.h", "include/grpcpp/server_posix.h", "include/grpcpp/support/async_stream.h", "include/grpcpp/support/async_stream_impl.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 413646625ac..bb5a86c81f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,12 +25,12 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.32.0-dev") -set(gRPC_CORE_VERSION "11.0.0") -set(gRPC_CORE_SOVERSION "11") -set(gRPC_CPP_VERSION "1.32.0-dev") +set(PACKAGE_VERSION "1.33.0-dev") +set(gRPC_CORE_VERSION "12.0.0") +set(gRPC_CORE_SOVERSION "12") +set(gRPC_CPP_VERSION "1.33.0-dev") set(gRPC_CPP_SOVERSION "1") -set(gRPC_CSHARP_VERSION "2.32.0-dev") +set(gRPC_CSHARP_VERSION "2.33.0-dev") set(gRPC_CSHARP_SOVERSION "2") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") @@ -2856,7 +2856,6 @@ foreach(_hdr include/grpcpp/server.h include/grpcpp/server_builder.h include/grpcpp/server_context.h - include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/support/async_stream.h include/grpcpp/support/async_stream_impl.h @@ -3540,7 +3539,6 @@ foreach(_hdr include/grpcpp/server.h include/grpcpp/server_builder.h include/grpcpp/server_context.h - include/grpcpp/server_impl.h include/grpcpp/server_posix.h include/grpcpp/support/async_stream.h include/grpcpp/support/async_stream_impl.h diff --git a/Makefile b/Makefile index 506a9a64558..d1dd429ab84 100644 --- a/Makefile +++ b/Makefile @@ -456,9 +456,9 @@ E = @echo Q = @ endif -CORE_VERSION = 11.0.0 -CPP_VERSION = 1.32.0-dev -CSHARP_VERSION = 2.32.0-dev +CORE_VERSION = 12.0.0 +CPP_VERSION = 1.33.0-dev +CSHARP_VERSION = 2.33.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -500,7 +500,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -11 +SHARED_VERSION_CORE = -12 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -2 else ifeq ($(SYSTEM),Darwin) @@ -1872,8 +1872,8 @@ $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.11 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.12 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif endif @@ -1997,8 +1997,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.11 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.12 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -2490,8 +2490,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.11 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.12 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -2549,8 +2549,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.11 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.12 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CORE).so endif endif @@ -2958,8 +2958,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.11 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.12 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif @@ -3189,7 +3189,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_context.h \ - include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream_impl.h \ @@ -3718,7 +3717,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_context.h \ - include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream_impl.h \ @@ -4303,8 +4301,8 @@ $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBUPB_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.11 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.11 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.12 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.12 $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so endif endif diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 61b20683754..ea13f3330c2 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -231,7 +231,7 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data **args ) -def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = []): +def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = [], features = []): copts = [] if language.upper() == "C": copts = ["-std=c99"] @@ -246,6 +246,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da copts = copts, linkopts = if_not_windows(["-pthread"]) + linkopts, tags = tags, + features = features, ) def grpc_generate_one_off_targets(): diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 60208170004..0cbb65254ee 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -654,7 +654,13 @@ libs: - src/core/lib/security/authorization/authorization_engine.h - src/core/lib/security/authorization/evaluate_args.h - src/core/lib/security/authorization/mock_cel/activation.h + - src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h + - src/core/lib/security/authorization/mock_cel/cel_expression.h - src/core/lib/security/authorization/mock_cel/cel_value.h + - src/core/lib/security/authorization/mock_cel/evaluator_core.h + - src/core/lib/security/authorization/mock_cel/flat_expr_builder.h + - src/core/lib/security/authorization/mock_cel/statusor.h + - src/core/lib/security/certificate_provider.h - src/core/lib/security/context/security_context.h - src/core/lib/security/credentials/alts/alts_credentials.h - src/core/lib/security/credentials/alts/check_gcp_environment.h @@ -2188,7 +2194,6 @@ libs: - include/grpcpp/server.h - include/grpcpp/server_builder.h - include/grpcpp/server_context.h - - include/grpcpp/server_impl.h - include/grpcpp/server_posix.h - include/grpcpp/support/async_stream.h - include/grpcpp/support/async_stream_impl.h @@ -2564,7 +2569,6 @@ libs: - include/grpcpp/server.h - include/grpcpp/server_builder.h - include/grpcpp/server_context.h - - include/grpcpp/server_impl.h - include/grpcpp/server_posix.h - include/grpcpp/support/async_stream.h - include/grpcpp/support/async_stream_impl.h diff --git a/build_config.rb b/build_config.rb index ff432bd3392..642399878ae 100644 --- a/build_config.rb +++ b/build_config.rb @@ -13,5 +13,5 @@ # limitations under the License. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-11.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-12.dll' end diff --git a/build_handwritten.yaml b/build_handwritten.yaml index 5c45f8e29a4..4a4263bc273 100644 --- a/build_handwritten.yaml +++ b/build_handwritten.yaml @@ -12,10 +12,10 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 11.0.0 + core_version: 12.0.0 csharp_major_version: 2 - g_stands_for: giggle - version: 1.32.0-dev + g_stands_for: geeky + version: 1.33.0-dev targets: - name: check_epollexclusive build: tool diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 069d4e5a609..c384913de20 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -31,4 +31,5 @@ - 1.29 'g' stands for ['gringotts'](https://github.com/grpc/grpc/tree/v1.29.x) - 1.30 'g' stands for ['gradius'](https://github.com/grpc/grpc/tree/v1.30.x) - 1.31 'g' stands for ['galore'](https://github.com/grpc/grpc/tree/v1.31.x) -- 1.32 'g' stands for ['giggle'](https://github.com/grpc/grpc/tree/master) +- 1.32 'g' stands for ['giggle'](https://github.com/grpc/grpc/tree/v1.32.x) +- 1.33 'g' stands for ['geeky'](https://github.com/grpc/grpc/tree/master) diff --git a/doc/xds-test-descriptions.md b/doc/xds-test-descriptions.md index c42583b2010..721b1e7414c 100644 --- a/doc/xds-test-descriptions.md +++ b/doc/xds-test-descriptions.md @@ -218,31 +218,6 @@ Test driver asserts: 1. All backends in the primary locality receive at least 1 RPC. 1. No backends in the secondary locality receive RPCs. -### new_instance_group_receives_traffic - -This test verifies that new instance groups added to a backend service in the -same zone receive traffic. - -Client parameters: - -1. --num_channels=1 -1. --qps=100 -1. --fail_on_failed_rpc=true - -Load balancer configuration: - -1. One MIG with two backends, using rate balancing mode. - -Test driver asserts: - -1. All backends receive at least one RPC. - -The test driver adds a new MIG with two backends in the same zone. - -Test driver asserts: - -1. All backends in each MIG receive at least one RPC. - ### remove_instance_group This test verifies that a remaining instance group can successfully serve RPCs @@ -321,3 +296,36 @@ Assert: 1. Once all backends receive at least one RPC, the following 1000 RPCs are distributed across the 2 backends as a: 20, b: 80. +### gentle_failover + +This test verifies that traffic is partially diverted to a secondary locality +when > 50% of the instances in the primary locality are unhealthy. + +Client parameters: + +1. --num_channels=1 +1. --qps=100 + +Load balancer configuration: + +1. The primary MIG with 3 backends in the same zone as the client +1. The secondary MIG with 2 backends in a different zone + +Test driver asserts: + +1. All backends in the primary locality receive at least 1 RPC. +1. No backends in the secondary locality receive RPCs. + +The test driver stops 2 of 3 backends in the primary locality. + +Test driver asserts: + +1. All backends in the secondary locality receive at least 1 RPC. +1. The remaining backend in the primary locality receives at least 1 RPC. + +The test driver resumes the backends in the primary locality. + +Test driver asserts: + +1. All backends in the primary locality receive at least 1 RPC. +1. No backends in the secondary locality receive RPCs. diff --git a/examples/android/helloworld/app/CMakeLists.txt b/examples/android/helloworld/app/CMakeLists.txt index f449a5ce2ea..160eb845d99 100644 --- a/examples/android/helloworld/app/CMakeLists.txt +++ b/examples/android/helloworld/app/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.4.1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +# https://github.com/abseil/abseil-cpp/issues/626 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DABSL_NO_XRAY_ATTRIBUTES=1") + set(helloworld_PROTOBUF_PROTOC_EXECUTABLE "/usr/local/bin/protoc" CACHE STRING "Protoc binary on host") set(helloworld_GRPC_CPP_PLUGIN_EXECUTABLE "/usr/local/bin/grpc_cpp_plugin" CACHE STRING "gRPC CPP plugin binary on host") diff --git a/examples/android/helloworld/build.gradle b/examples/android/helloworld/build.gradle index bd5f337f013..78591e3b824 100644 --- a/examples/android/helloworld/build.gradle +++ b/examples/android/helloworld/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/examples/android/helloworld/gradle/wrapper/gradle-wrapper.properties b/examples/android/helloworld/gradle/wrapper/gradle-wrapper.properties index 4c81831f533..ac3220ae044 100644 --- a/examples/android/helloworld/gradle/wrapper/gradle-wrapper.properties +++ b/examples/android/helloworld/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 22edccc0885..9bf5e7a790b 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - version = '1.32.0-dev' + version = '1.33.0-dev' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -163,7 +163,6 @@ Pod::Spec.new do |s| 'include/grpcpp/server.h', 'include/grpcpp/server_builder.h', 'include/grpcpp/server_context.h', - 'include/grpcpp/server_impl.h', 'include/grpcpp/server_posix.h', 'include/grpcpp/support/async_stream.h', 'include/grpcpp/support/async_stream_impl.h', @@ -516,7 +515,13 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', + 'src/core/lib/security/authorization/mock_cel/statusor.h', + 'src/core/lib/security/certificate_provider.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', @@ -1010,7 +1015,13 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', + 'src/core/lib/security/authorization/mock_cel/statusor.h', + 'src/core/lib/security/certificate_provider.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index bd418e8f858..efa2d132f29 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.32.0-dev' + version = '1.33.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' @@ -848,7 +848,13 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/evaluate_args.cc', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', + 'src/core/lib/security/authorization/mock_cel/statusor.h', + 'src/core/lib/security/certificate_provider.h', 'src/core/lib/security/context/security_context.cc', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.cc', @@ -1422,7 +1428,13 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', + 'src/core/lib/security/authorization/mock_cel/statusor.h', + 'src/core/lib/security/certificate_provider.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 705e5a850b4..bcc6ffe249c 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.32.0-dev' + version = '1.33.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 9b1eab1b4b9..83fff1d66f2 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.32.0-dev' + version = '1.33.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 1df3cce0057..70557e55134 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.32.0-dev' + version = '1.33.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/grpc.gemspec b/grpc.gemspec index 7d434c02d98..116cfc602b4 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -766,7 +766,13 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/authorization/evaluate_args.cc ) s.files += %w( src/core/lib/security/authorization/evaluate_args.h ) s.files += %w( src/core/lib/security/authorization/mock_cel/activation.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/cel_expression.h ) s.files += %w( src/core/lib/security/authorization/mock_cel/cel_value.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/evaluator_core.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/flat_expr_builder.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/statusor.h ) + s.files += %w( src/core/lib/security/certificate_provider.h ) s.files += %w( src/core/lib/security/context/security_context.cc ) s.files += %w( src/core/lib/security/context/security_context.h ) s.files += %w( src/core/lib/security/credentials/alts/alts_credentials.cc ) diff --git a/include/grpcpp/impl/codegen/async_generic_service.h b/include/grpcpp/impl/codegen/async_generic_service.h index 453c7917edb..56217c1e129 100644 --- a/include/grpcpp/impl/codegen/async_generic_service.h +++ b/include/grpcpp/impl/codegen/async_generic_service.h @@ -44,7 +44,7 @@ class GenericServerContext final : public ::grpc::ServerContext { const std::string& host() const { return host_; } private: - friend class grpc_impl::Server; + friend class grpc::Server; friend class grpc::ServerInterface; void Clear() { @@ -84,8 +84,8 @@ class AsyncGenericService final { ::grpc::ServerCompletionQueue* notification_cq, void* tag); private: - friend class grpc_impl::Server; - grpc_impl::Server* server_; + friend class grpc::Server; + grpc::Server* server_; }; #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL @@ -105,7 +105,7 @@ class GenericCallbackServerContext final const std::string& host() const { return host_; } private: - friend class ::grpc_impl::Server; + friend class ::grpc::Server; friend class ::grpc::ServerInterface; void Clear() { @@ -140,7 +140,7 @@ class CallbackGenericService { } private: - friend class ::grpc_impl::Server; + friend class grpc::Server; ::grpc_impl::internal::CallbackBidiHandler* Handler() { @@ -151,7 +151,7 @@ class CallbackGenericService { }); } - grpc_impl::Server* server_{nullptr}; + grpc::Server* server_{nullptr}; }; #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL diff --git a/include/grpcpp/impl/codegen/async_stream_impl.h b/include/grpcpp/impl/codegen/async_stream_impl.h index 093ccdc2fd2..bb1c2ef6fb3 100644 --- a/include/grpcpp/impl/codegen/async_stream_impl.h +++ b/include/grpcpp/impl/codegen/async_stream_impl.h @@ -1097,7 +1097,7 @@ class ServerAsyncReaderWriter final } private: - friend class ::grpc_impl::Server; + friend class ::grpc::Server; void BindCall(::grpc::internal::Call* call) override { call_ = *call; } diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h index d5970601ccf..4ed20411da6 100644 --- a/include/grpcpp/impl/codegen/completion_queue.h +++ b/include/grpcpp/impl/codegen/completion_queue.h @@ -46,7 +46,6 @@ struct grpc_completion_queue; namespace grpc_impl { -class Server; template class ClientReader; template @@ -77,6 +76,7 @@ namespace grpc { class Channel; class ChannelInterface; +class Server; class ServerBuilder; class ServerContextBase; class ServerInterface; @@ -252,7 +252,7 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { // Friends for access to server registration lists that enable checking and // logging on shutdown friend class ::grpc::ServerBuilder; - friend class ::grpc_impl::Server; + friend class ::grpc::Server; // Friend synchronous wrappers so that they can access Pluck(), which is // a semi-private API geared towards the synchronous implementation. @@ -382,14 +382,14 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { } } - void RegisterServer(const ::grpc_impl::Server* server) { + void RegisterServer(const ::grpc::Server* server) { (void)server; #ifndef NDEBUG grpc::internal::MutexLock l(&server_list_mutex_); server_list_.push_back(server); #endif } - void UnregisterServer(const ::grpc_impl::Server* server) { + void UnregisterServer(const ::grpc::Server* server) { (void)server; #ifndef NDEBUG grpc::internal::MutexLock l(&server_list_mutex_); @@ -412,7 +412,7 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen { // NDEBUG, instantiate it in all cases since otherwise the size will be // inconsistent. mutable grpc::internal::Mutex server_list_mutex_; - std::list + std::list server_list_ /* GUARDED_BY(server_list_mutex_) */; }; @@ -443,7 +443,7 @@ class ServerCompletionQueue : public CompletionQueue { grpc_cq_polling_type polling_type_; friend class ::grpc::ServerBuilder; - friend class ::grpc_impl::Server; + friend class ::grpc::Server; }; } // namespace grpc diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index 209adfee16b..001e57dc536 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -49,7 +49,6 @@ struct grpc_call; struct census_context; namespace grpc_impl { -class Server; template class ServerAsyncReader; template @@ -96,6 +95,7 @@ namespace grpc { class ClientContext; class CompletionQueue; class GenericServerContext; +class Server; class ServerInterface; // TODO(vjpai): Remove namespace experimental when de-experimentalized fully. @@ -342,7 +342,7 @@ class ServerContextBase { friend class ::grpc::testing::ServerContextTestSpouse; friend class ::grpc::testing::DefaultReactorTestPeer; friend class ::grpc::ServerInterface; - friend class ::grpc_impl::Server; + friend class ::grpc::Server; template friend class ::grpc_impl::ServerAsyncReader; template @@ -548,7 +548,7 @@ class ServerContext : public ServerContextBase { private: // Constructor for internal use by server only - friend class ::grpc_impl::Server; + friend class ::grpc::Server; ServerContext(gpr_timespec deadline, grpc_metadata_array* arr) : ServerContextBase(deadline, arr) {} diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h index 3d815ea32e5..b5b7ce73d64 100644 --- a/include/grpcpp/impl/codegen/service_type.h +++ b/include/grpcpp/impl/codegen/service_type.h @@ -268,7 +268,7 @@ class Service { return methods_[idx]->handler(); } - friend class grpc_impl::Server; + friend class Server; friend class ServerInterface; ServerInterface* server_; std::vector> methods_; diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index 189f491a37d..a86d0e35f07 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -29,12 +29,9 @@ struct grpc_server; -namespace grpc_impl { - -class Server; -} // namespace grpc_impl namespace grpc { +class Server; /// Options to create ServerCredentials with SSL struct SslServerCredentialsOptions { /// \warning Deprecated @@ -72,7 +69,7 @@ class ServerCredentials { const std::shared_ptr& processor) = 0; private: - friend class ::grpc_impl::Server; + friend class Server; /// Tries to bind \a server to the given \a addr (eg, localhost:1234, /// 192.168.1.1:31416, [::1]:27182, etc.) diff --git a/include/grpcpp/server.h b/include/grpcpp/server.h index 3de2aba0b59..38d9d404352 100644 --- a/include/grpcpp/server.h +++ b/include/grpcpp/server.h @@ -1,6 +1,6 @@ /* * - * Copyright 2019 gRPC authors. + * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,359 @@ #ifndef GRPCPP_SERVER_H #define GRPCPP_SERVER_H -#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct grpc_server; + +namespace grpc_impl { +class ServerContext; +class ServerInitializer; +} // namespace grpc_impl namespace grpc { +class AsyncGenericService; + +namespace internal { +class ExternalConnectionAcceptorImpl; +} // namespace internal + +/// Represents a gRPC server. +/// +/// Use a \a grpc::ServerBuilder to create, configure, and start +/// \a Server instances. +class Server : public ServerInterface, private GrpcLibraryCodegen { + public: + ~Server(); + + /// Block until the server shuts down. + /// + /// \warning The server must be either shutting down or some other thread must + /// call \a Shutdown for this function to ever return. + void Wait() override; + + /// Global callbacks are a set of hooks that are called when server + /// events occur. \a SetGlobalCallbacks method is used to register + /// the hooks with gRPC. Note that + /// the \a GlobalCallbacks instance will be shared among all + /// \a Server instances in an application and can be set exactly + /// once per application. + class GlobalCallbacks { + public: + virtual ~GlobalCallbacks() {} + /// Called before server is created. + virtual void UpdateArguments(ChannelArguments* /*args*/) {} + /// Called before application callback for each synchronous server request + virtual void PreSynchronousRequest(ServerContext* context) = 0; + /// Called after application callback for each synchronous server request + virtual void PostSynchronousRequest(ServerContext* context) = 0; + /// Called before server is started. + virtual void PreServerStart(Server* /*server*/) {} + /// Called after a server port is added. + virtual void AddPort(Server* /*server*/, const std::string& /*addr*/, + ServerCredentials* /*creds*/, int /*port*/) {} + }; + /// Set the global callback object. Can only be called once per application. + /// Does not take ownership of callbacks, and expects the pointed to object + /// to be alive until all server objects in the process have been destroyed. + /// The same \a GlobalCallbacks object will be used throughout the + /// application and is shared among all \a Server objects. + static void SetGlobalCallbacks(GlobalCallbacks* callbacks); + + /// Returns a \em raw pointer to the underlying \a grpc_server instance. + /// EXPERIMENTAL: for internal/test use only + grpc_server* c_server(); + + /// Returns the health check service. + HealthCheckServiceInterface* GetHealthCheckService() const { + return health_check_service_.get(); + } + + /// Establish a channel for in-process communication + std::shared_ptr InProcessChannel(const ChannelArguments& args); + + /// NOTE: class experimental_type is not part of the public API of this class. + /// TODO(yashykt): Integrate into public API when this is no longer + /// experimental. + class experimental_type { + public: + explicit experimental_type(Server* server) : server_(server) {} + + /// Establish a channel for in-process communication with client + /// interceptors + std::shared_ptr InProcessChannelWithInterceptors( + const ChannelArguments& args, + std::vector< + std::unique_ptr> + interceptor_creators); + + private: + Server* server_; + }; + + /// NOTE: The function experimental() is not stable public API. It is a view + /// to the experimental components of this class. It may be changed or removed + /// at any time. + experimental_type experimental() { return experimental_type(this); } + + protected: + /// Register a service. This call does not take ownership of the service. + /// The service must exist for the lifetime of the Server instance. + bool RegisterService(const std::string* host, Service* service) override; + + /// Try binding the server to the given \a addr endpoint + /// (port, and optionally including IP address to bind to). + /// + /// It can be invoked multiple times. Should be used before + /// starting the server. + /// + /// \param addr The address to try to bind to the server (eg, localhost:1234, + /// 192.168.1.1:31416, [::1]:27182, etc.). + /// \param creds The credentials associated with the server. + /// + /// \return bound port number on success, 0 on failure. + /// + /// \warning It is an error to call this method on an already started server. + int AddListeningPort(const std::string& addr, + ServerCredentials* creds) override; + + /// NOTE: This is *NOT* a public API. The server constructors are supposed to + /// be used by \a ServerBuilder class only. The constructor will be made + /// 'private' very soon. + /// + /// Server constructors. To be used by \a ServerBuilder only. + /// + /// \param args The channel args + /// + /// \param sync_server_cqs The completion queues to use if the server is a + /// synchronous server (or a hybrid server). The server polls for new RPCs on + /// these queues + /// + /// \param min_pollers The minimum number of polling threads per server + /// completion queue (in param sync_server_cqs) to use for listening to + /// incoming requests (used only in case of sync server) + /// + /// \param max_pollers The maximum number of polling threads per server + /// completion queue (in param sync_server_cqs) to use for listening to + /// incoming requests (used only in case of sync server) + /// + /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on + /// server completion queues passed via sync_server_cqs param. + Server(ChannelArguments* args, + std::shared_ptr>> + sync_server_cqs, + int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::vector> + acceptors, + grpc_resource_quota* server_rq = nullptr, + std::vector< + std::unique_ptr> + interceptor_creators = std::vector>()); + + /// Start the server. + /// + /// \param cqs Completion queues for handling asynchronous services. The + /// caller is required to keep all completion queues live until the server is + /// destroyed. + /// \param num_cqs How many completion queues does \a cqs hold. + void Start(ServerCompletionQueue** cqs, size_t num_cqs) override; + + grpc_server* server() override { return server_; } + + protected: + /// NOTE: This method is not part of the public API for this class. + void set_health_check_service( + std::unique_ptr service) { + health_check_service_ = std::move(service); + } + + /// NOTE: This method is not part of the public API for this class. + bool health_check_service_disabled() const { + return health_check_service_disabled_; + } + + private: + std::vector>* + interceptor_creators() override { + return &interceptor_creators_; + } + + friend class AsyncGenericService; + friend class ServerBuilder; + friend class grpc_impl::ServerInitializer; + + class SyncRequest; + class CallbackRequestBase; + template + class CallbackRequest; + class UnimplementedAsyncRequest; + class UnimplementedAsyncResponse; + + /// SyncRequestThreadManager is an implementation of ThreadManager. This class + /// is responsible for polling for incoming RPCs and calling the RPC handlers. + /// This is only used in case of a Sync server (i.e a server exposing a sync + /// interface) + class SyncRequestThreadManager; + + /// Register a generic service. This call does not take ownership of the + /// service. The service must exist for the lifetime of the Server instance. + void RegisterAsyncGenericService(AsyncGenericService* service) override; + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + /// Register a callback-based generic service. This call does not take + /// ownership of theservice. The service must exist for the lifetime of the + /// Server instance. + void RegisterCallbackGenericService(CallbackGenericService* service) override; +#else + /// NOTE: class experimental_registration_type is not part of the public API + /// of this class + /// TODO(vjpai): Move these contents to the public API of Server when + /// they are no longer experimental + class experimental_registration_type final + : public experimental_registration_interface { + public: + explicit experimental_registration_type(Server* server) : server_(server) {} + void RegisterCallbackGenericService( + experimental::CallbackGenericService* service) override { + server_->RegisterCallbackGenericService(service); + } + + private: + Server* server_; + }; + + /// TODO(vjpai): Mark this override when experimental type above is deleted + void RegisterCallbackGenericService( + experimental::CallbackGenericService* service); + + /// NOTE: The function experimental_registration() is not stable public API. + /// It is a view to the experimental components of this class. It may be + /// changed or removed at any time. + experimental_registration_interface* experimental_registration() override { + return &experimental_registration_; + } +#endif + + void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) override; + + void ShutdownInternal(gpr_timespec deadline) override; + + int max_receive_message_size() const override { + return max_receive_message_size_; + } + + CompletionQueue* CallbackCQ() override; + + grpc_impl::ServerInitializer* initializer(); + + // Functions to manage the server shutdown ref count. Things that increase + // the ref count are the running state of the server (take a ref at start and + // drop it at shutdown) and each running callback RPC. + void Ref(); + void UnrefWithPossibleNotify() /* LOCKS_EXCLUDED(mu_) */; + void UnrefAndWaitLocked() /* EXCLUSIVE_LOCKS_REQUIRED(mu_) */; + + std::vector> + acceptors_; + + // A vector of interceptor factory objects. + // This should be destroyed after health_check_service_ and this requirement + // is satisfied by declaring interceptor_creators_ before + // health_check_service_. (C++ mandates that member objects be destroyed in + // the reverse order of initialization.) + std::vector> + interceptor_creators_; + + int max_receive_message_size_; + + /// The following completion queues are ONLY used in case of Sync API + /// i.e. if the server has any services with sync methods. The server uses + /// these completion queues to poll for new RPCs + std::shared_ptr>> + sync_server_cqs_; + + /// List of \a ThreadManager instances (one for each cq in + /// the \a sync_server_cqs) + std::vector> sync_req_mgrs_; + +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL + // For registering experimental callback generic service; remove when that + // method longer experimental + experimental_registration_type experimental_registration_{this}; +#endif + + // Server status + internal::Mutex mu_; + bool started_; + bool shutdown_; + bool shutdown_notified_; // Was notify called on the shutdown_cv_ + internal::CondVar shutdown_done_cv_; + bool shutdown_done_ = false; + std::atomic_int shutdown_refs_outstanding_{1}; + + internal::CondVar shutdown_cv_; + + std::shared_ptr global_callbacks_; + + std::vector services_; + bool has_async_generic_service_ = false; + bool has_callback_generic_service_ = false; + bool has_callback_methods_ = false; + + // Pointer to the wrapped grpc_server. + grpc_server* server_; + + std::unique_ptr server_initializer_; + + std::unique_ptr health_check_service_; + bool health_check_service_disabled_; + + // When appropriate, use a default callback generic service to handle + // unimplemented methods +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL + std::unique_ptr unimplemented_service_; +#else + std::unique_ptr unimplemented_service_; +#endif + + // A special handler for resource exhausted in sync case + std::unique_ptr resource_exhausted_handler_; + + // Handler for callback generic service, if any + std::unique_ptr generic_handler_; + + // callback_cq_ references the callbackable completion queue associated + // with this server (if any). It is set on the first call to CallbackCQ(). + // It is _not owned_ by the server; ownership belongs with its internal + // shutdown callback tag (invoked when the CQ is fully shutdown). + CompletionQueue* callback_cq_ /* GUARDED_BY(mu_) */ = nullptr; -typedef ::grpc_impl::Server Server; + // List of CQs passed in by user that must be Shutdown only after Server is + // Shutdown. Even though this is only used with NDEBUG, instantiate it in all + // cases since otherwise the size will be inconsistent. + std::vector cq_list_; +}; } // namespace grpc diff --git a/include/grpcpp/server_impl.h b/include/grpcpp/server_impl.h deleted file mode 100644 index 1aad1090beb..00000000000 --- a/include/grpcpp/server_impl.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - * - * Copyright 2015 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. - * - */ - -#ifndef GRPCPP_SERVER_IMPL_H -#define GRPCPP_SERVER_IMPL_H - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct grpc_server; - -namespace grpc { -class AsyncGenericService; -class ServerContext; - -namespace internal { -class ExternalConnectionAcceptorImpl; -} // namespace internal - -} // namespace grpc - -namespace grpc_impl { -class ServerInitializer; - -/// Represents a gRPC server. -/// -/// Use a \a grpc::ServerBuilder to create, configure, and start -/// \a Server instances. -class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { - public: - ~Server(); - - /// Block until the server shuts down. - /// - /// \warning The server must be either shutting down or some other thread must - /// call \a Shutdown for this function to ever return. - void Wait() override; - - /// Global callbacks are a set of hooks that are called when server - /// events occur. \a SetGlobalCallbacks method is used to register - /// the hooks with gRPC. Note that - /// the \a GlobalCallbacks instance will be shared among all - /// \a Server instances in an application and can be set exactly - /// once per application. - class GlobalCallbacks { - public: - virtual ~GlobalCallbacks() {} - /// Called before server is created. - virtual void UpdateArguments(grpc::ChannelArguments* /*args*/) {} - /// Called before application callback for each synchronous server request - virtual void PreSynchronousRequest(grpc::ServerContext* context) = 0; - /// Called after application callback for each synchronous server request - virtual void PostSynchronousRequest(grpc::ServerContext* context) = 0; - /// Called before server is started. - virtual void PreServerStart(Server* /*server*/) {} - /// Called after a server port is added. - virtual void AddPort(Server* /*server*/, const std::string& /*addr*/, - grpc::ServerCredentials* /*creds*/, int /*port*/) {} - }; - /// Set the global callback object. Can only be called once per application. - /// Does not take ownership of callbacks, and expects the pointed to object - /// to be alive until all server objects in the process have been destroyed. - /// The same \a GlobalCallbacks object will be used throughout the - /// application and is shared among all \a Server objects. - static void SetGlobalCallbacks(GlobalCallbacks* callbacks); - - /// Returns a \em raw pointer to the underlying \a grpc_server instance. - /// EXPERIMENTAL: for internal/test use only - grpc_server* c_server(); - - /// Returns the health check service. - grpc::HealthCheckServiceInterface* GetHealthCheckService() const { - return health_check_service_.get(); - } - - /// Establish a channel for in-process communication - std::shared_ptr InProcessChannel( - const grpc::ChannelArguments& args); - - /// NOTE: class experimental_type is not part of the public API of this class. - /// TODO(yashykt): Integrate into public API when this is no longer - /// experimental. - class experimental_type { - public: - explicit experimental_type(Server* server) : server_(server) {} - - /// Establish a channel for in-process communication with client - /// interceptors - std::shared_ptr InProcessChannelWithInterceptors( - const grpc::ChannelArguments& args, - std::vector> - interceptor_creators); - - private: - Server* server_; - }; - - /// NOTE: The function experimental() is not stable public API. It is a view - /// to the experimental components of this class. It may be changed or removed - /// at any time. - experimental_type experimental() { return experimental_type(this); } - - protected: - /// Register a service. This call does not take ownership of the service. - /// The service must exist for the lifetime of the Server instance. - bool RegisterService(const std::string* host, - grpc::Service* service) override; - - /// Try binding the server to the given \a addr endpoint - /// (port, and optionally including IP address to bind to). - /// - /// It can be invoked multiple times. Should be used before - /// starting the server. - /// - /// \param addr The address to try to bind to the server (eg, localhost:1234, - /// 192.168.1.1:31416, [::1]:27182, etc.). - /// \param creds The credentials associated with the server. - /// - /// \return bound port number on success, 0 on failure. - /// - /// \warning It is an error to call this method on an already started server. - int AddListeningPort(const std::string& addr, - grpc::ServerCredentials* creds) override; - - /// NOTE: This is *NOT* a public API. The server constructors are supposed to - /// be used by \a ServerBuilder class only. The constructor will be made - /// 'private' very soon. - /// - /// Server constructors. To be used by \a ServerBuilder only. - /// - /// \param args The channel args - /// - /// \param sync_server_cqs The completion queues to use if the server is a - /// synchronous server (or a hybrid server). The server polls for new RPCs on - /// these queues - /// - /// \param min_pollers The minimum number of polling threads per server - /// completion queue (in param sync_server_cqs) to use for listening to - /// incoming requests (used only in case of sync server) - /// - /// \param max_pollers The maximum number of polling threads per server - /// completion queue (in param sync_server_cqs) to use for listening to - /// incoming requests (used only in case of sync server) - /// - /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on - /// server completion queues passed via sync_server_cqs param. - Server( - grpc::ChannelArguments* args, - std::shared_ptr>> - sync_server_cqs, - int min_pollers, int max_pollers, int sync_cq_timeout_msec, - std::vector< - std::shared_ptr> - acceptors, - grpc_resource_quota* server_rq = nullptr, - std::vector> - interceptor_creators = std::vector>()); - - /// Start the server. - /// - /// \param cqs Completion queues for handling asynchronous services. The - /// caller is required to keep all completion queues live until the server is - /// destroyed. - /// \param num_cqs How many completion queues does \a cqs hold. - void Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) override; - - grpc_server* server() override { return server_; } - - protected: - /// NOTE: This method is not part of the public API for this class. - void set_health_check_service( - std::unique_ptr service) { - health_check_service_ = std::move(service); - } - - /// NOTE: This method is not part of the public API for this class. - bool health_check_service_disabled() const { - return health_check_service_disabled_; - } - - private: - std::vector< - std::unique_ptr>* - interceptor_creators() override { - return &interceptor_creators_; - } - - friend class grpc::AsyncGenericService; - friend class grpc::ServerBuilder; - friend class grpc_impl::ServerInitializer; - - class SyncRequest; - class CallbackRequestBase; - template - class CallbackRequest; - class UnimplementedAsyncRequest; - class UnimplementedAsyncResponse; - - /// SyncRequestThreadManager is an implementation of ThreadManager. This class - /// is responsible for polling for incoming RPCs and calling the RPC handlers. - /// This is only used in case of a Sync server (i.e a server exposing a sync - /// interface) - class SyncRequestThreadManager; - - /// Register a generic service. This call does not take ownership of the - /// service. The service must exist for the lifetime of the Server instance. - void RegisterAsyncGenericService(grpc::AsyncGenericService* service) override; - -#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL - /// Register a callback-based generic service. This call does not take - /// ownership of theservice. The service must exist for the lifetime of the - /// Server instance. - void RegisterCallbackGenericService( - grpc::CallbackGenericService* service) override; -#else - /// NOTE: class experimental_registration_type is not part of the public API - /// of this class - /// TODO(vjpai): Move these contents to the public API of Server when - /// they are no longer experimental - class experimental_registration_type final - : public experimental_registration_interface { - public: - explicit experimental_registration_type(Server* server) : server_(server) {} - void RegisterCallbackGenericService( - grpc::experimental::CallbackGenericService* service) override { - server_->RegisterCallbackGenericService(service); - } - - private: - Server* server_; - }; - - /// TODO(vjpai): Mark this override when experimental type above is deleted - void RegisterCallbackGenericService( - grpc::experimental::CallbackGenericService* service); - - /// NOTE: The function experimental_registration() is not stable public API. - /// It is a view to the experimental components of this class. It may be - /// changed or removed at any time. - experimental_registration_interface* experimental_registration() override { - return &experimental_registration_; - } -#endif - - void PerformOpsOnCall(grpc::internal::CallOpSetInterface* ops, - grpc::internal::Call* call) override; - - void ShutdownInternal(gpr_timespec deadline) override; - - int max_receive_message_size() const override { - return max_receive_message_size_; - } - - grpc::CompletionQueue* CallbackCQ() override; - - grpc_impl::ServerInitializer* initializer(); - - // Functions to manage the server shutdown ref count. Things that increase - // the ref count are the running state of the server (take a ref at start and - // drop it at shutdown) and each running callback RPC. - void Ref(); - void UnrefWithPossibleNotify() /* LOCKS_EXCLUDED(mu_) */; - void UnrefAndWaitLocked() /* EXCLUSIVE_LOCKS_REQUIRED(mu_) */; - - std::vector> - acceptors_; - - // A vector of interceptor factory objects. - // This should be destroyed after health_check_service_ and this requirement - // is satisfied by declaring interceptor_creators_ before - // health_check_service_. (C++ mandates that member objects be destroyed in - // the reverse order of initialization.) - std::vector< - std::unique_ptr> - interceptor_creators_; - - int max_receive_message_size_; - - /// The following completion queues are ONLY used in case of Sync API - /// i.e. if the server has any services with sync methods. The server uses - /// these completion queues to poll for new RPCs - std::shared_ptr>> - sync_server_cqs_; - - /// List of \a ThreadManager instances (one for each cq in - /// the \a sync_server_cqs) - std::vector> sync_req_mgrs_; - -#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL - // For registering experimental callback generic service; remove when that - // method longer experimental - experimental_registration_type experimental_registration_{this}; -#endif - - // Server status - grpc::internal::Mutex mu_; - bool started_; - bool shutdown_; - bool shutdown_notified_; // Was notify called on the shutdown_cv_ - grpc::internal::CondVar shutdown_done_cv_; - bool shutdown_done_ = false; - std::atomic_int shutdown_refs_outstanding_{1}; - - grpc::internal::CondVar shutdown_cv_; - - std::shared_ptr global_callbacks_; - - std::vector services_; - bool has_async_generic_service_ = false; - bool has_callback_generic_service_ = false; - bool has_callback_methods_ = false; - - // Pointer to the wrapped grpc_server. - grpc_server* server_; - - std::unique_ptr server_initializer_; - - std::unique_ptr health_check_service_; - bool health_check_service_disabled_; - - // When appropriate, use a default callback generic service to handle - // unimplemented methods -#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL - std::unique_ptr unimplemented_service_; -#else - std::unique_ptr - unimplemented_service_; -#endif - - // A special handler for resource exhausted in sync case - std::unique_ptr resource_exhausted_handler_; - - // Handler for callback generic service, if any - std::unique_ptr generic_handler_; - - // callback_cq_ references the callbackable completion queue associated - // with this server (if any). It is set on the first call to CallbackCQ(). - // It is _not owned_ by the server; ownership belongs with its internal - // shutdown callback tag (invoked when the CQ is fully shutdown). - grpc::CompletionQueue* callback_cq_ /* GUARDED_BY(mu_) */ = nullptr; - - // List of CQs passed in by user that must be Shutdown only after Server is - // Shutdown. Even though this is only used with NDEBUG, instantiate it in all - // cases since otherwise the size will be inconsistent. - std::vector cq_list_; -}; - -} // namespace grpc_impl - -#endif // GRPCPP_SERVER_IMPL_H diff --git a/package.xml b/package.xml index ed80ad00315..66bcccb9f69 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2019-09-24 - 1.32.0dev - 1.32.0dev + 1.33.0dev + 1.33.0dev beta @@ -22,7 +22,7 @@ Apache 2.0 -- gRPC Core 1.32.0 update +- gRPC Core 1.33.0 update @@ -746,7 +746,13 @@ + + + + + + diff --git a/setup.py b/setup.py index 20a6d76dbe0..18be2e17817 100644 --- a/setup.py +++ b/setup.py @@ -166,12 +166,22 @@ def check_linker_need_libatomic(): """Test if linker on system needs libatomic.""" code_test = (b'#include \n' + b'int main() { return std::atomic{}; }') - cc_test = subprocess.Popen(['cc', '-x', 'c++', '-std=c++11', '-'], - stdin=PIPE, - stdout=PIPE, - stderr=PIPE) - cc_test.communicate(input=code_test) - return cc_test.returncode != 0 + cpp_test = subprocess.Popen(['c++', '-x', 'c++', '-std=c++11', '-'], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) + cpp_test.communicate(input=code_test) + if cpp_test.returncode == 0: + return False + # Double-check to see if -latomic actually can solve the problem. + # https://github.com/grpc/grpc/issues/22491 + cpp_test = subprocess.Popen( + ['c++', '-x', 'c++', '-std=c++11', '-latomic', '-'], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) + cpp_test.communicate(input=code_test) + return cpp_test.returncode == 0 # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are diff --git a/src/android/test/interop/app/CMakeLists.txt b/src/android/test/interop/app/CMakeLists.txt index e288dd63cec..53fbe594499 100644 --- a/src/android/test/interop/app/CMakeLists.txt +++ b/src/android/test/interop/app/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.4.1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +# https://github.com/abseil/abseil-cpp/issues/626 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DABSL_NO_XRAY_ATTRIBUTES=1") + set(PROTOBUF_PROTOC_EXECUTABLE "/usr/local/bin/protoc" CACHE STRING "Protoc binary on host") set(gRPC_CPP_PLUGIN_EXECUTABLE "/usr/local/bin/grpc_cpp_plugin" CACHE STRING "gRPC CPP plugin binary on host") diff --git a/src/android/test/interop/app/build.gradle b/src/android/test/interop/app/build.gradle index fb500a71c71..5bedc43c9ef 100644 --- a/src/android/test/interop/app/build.gradle +++ b/src/android/test/interop/app/build.gradle @@ -29,6 +29,9 @@ android { arguments '-DgRPC_CPP_PLUGIN_EXECUTABLE=' + grpc_cpp_plugin } } + ndk { + abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + } } buildTypes { debug { diff --git a/src/android/test/interop/build.gradle b/src/android/test/interop/build.gradle index bd5f337f013..78591e3b824 100644 --- a/src/android/test/interop/build.gradle +++ b/src/android/test/interop/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/src/android/test/interop/gradle/wrapper/gradle-wrapper.properties b/src/android/test/interop/gradle/wrapper/gradle-wrapper.properties index 4c81831f533..ac3220ae044 100644 --- a/src/android/test/interop/gradle/wrapper/gradle-wrapper.properties +++ b/src/android/test/interop/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 8c8ea5e090f..3ec554b5837 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -325,13 +325,76 @@ std::vector GetUsedMessages( void GenerateMarshallerFields(Printer* out, const ServiceDescriptor* service) { std::vector used_messages = GetUsedMessages(service); + if (used_messages.size() != 0) { + // Generate static helper methods for serialization/deserialization + out->Print( + "static void __Helper_SerializeMessage(" + "global::Google.Protobuf.IMessage message, " + "grpc::SerializationContext context)\n" + "{\n"); + out->Indent(); + out->Print( + "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" + "if (message is global::Google.Protobuf.IBufferMessage)\n" + "{\n"); + out->Indent(); + out->Print( + "context.SetPayloadLength(message.CalculateSize());\n" + "global::Google.Protobuf.MessageExtensions.WriteTo(message, " + "context.GetBufferWriter());\n" + "context.Complete();\n" + "return;\n"); + out->Outdent(); + out->Print( + "}\n" + "#endif\n"); + out->Print( + "context.Complete(" + "global::Google.Protobuf.MessageExtensions.ToByteArray(message));\n"); + out->Outdent(); + out->Print("}\n\n"); + + out->Print( + "static class __Helper_MessageCache\n" + "{\n"); + out->Indent(); + out->Print( + "public static readonly bool IsBufferMessage = " + "global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(" + "global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T));" + "\n"); + out->Outdent(); + out->Print("}\n\n"); + + out->Print( + "static T __Helper_DeserializeMessage(" + "grpc::DeserializationContext context, " + "global::Google.Protobuf.MessageParser parser) " + "where T : global::Google.Protobuf.IMessage\n" + "{\n"); + out->Indent(); + out->Print( + "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" + "if (__Helper_MessageCache.IsBufferMessage)\n" + "{\n"); + out->Indent(); + out->Print( + "return parser.ParseFrom(context.PayloadAsReadOnlySequence());\n"); + out->Outdent(); + out->Print( + "}\n" + "#endif\n"); + out->Print("return parser.ParseFrom(context.PayloadAsNewBuffer());\n"); + out->Outdent(); + out->Print("}\n\n"); + } + for (size_t i = 0; i < used_messages.size(); i++) { const Descriptor* message = used_messages[i]; out->Print( "static readonly grpc::Marshaller<$type$> $fieldname$ = " - "grpc::Marshallers.Create((arg) => " - "global::Google.Protobuf.MessageExtensions.ToByteArray(arg), " - "$type$.Parser.ParseFrom);\n", + "grpc::Marshallers.Create(__Helper_SerializeMessage, " + "context => __Helper_DeserializeMessage(context, $type$.Parser));\n", "fieldname", GetMarshallerFieldName(message), "type", GetClassName(message)); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 5dfb43146d9..005d913fb2c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -801,7 +801,7 @@ void GrpcLb::BalancerCallState::Orphan() { // lb_on_balancer_status_received_ will complete the cancellation and clean // up. Otherwise, we are here because grpclb_policy has to orphan a failed // call, then the following cancellation will be a no-op. - grpc_call_cancel(lb_call_, nullptr); + grpc_call_cancel_internal(lb_call_); if (client_load_report_timer_callback_pending_) { grpc_timer_cancel(&client_load_report_timer_); } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc index 883dcfa55ad..22de026aefa 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc @@ -58,7 +58,7 @@ constexpr char kXdsRouting[] = "xds_routing_experimental"; class XdsRoutingLbConfig : public LoadBalancingPolicy::Config { public: struct Route { - XdsApi::RdsUpdate::RdsRoute::Matchers matchers; + XdsApi::Route::Matchers matchers; std::string action; }; using RouteTable = std::vector; @@ -112,7 +112,7 @@ class XdsRoutingLb : public LoadBalancingPolicy { class RoutePicker : public SubchannelPicker { public: struct Route { - const XdsApi::RdsUpdate::RdsRoute::Matchers* matchers; + const XdsApi::Route::Matchers* matchers; RefCountedPtr picker; }; @@ -128,7 +128,7 @@ class XdsRoutingLb : public LoadBalancingPolicy { private: RouteTable route_table_; // Take a reference to config so that we can use - // XdsApi::RdsUpdate::RdsRoute::Matchers from it. + // XdsApi::Route::Matchers from it. RefCountedPtr config_; }; @@ -222,18 +222,14 @@ class XdsRoutingLb : public LoadBalancingPolicy { // XdsRoutingLb::RoutePicker // -bool PathMatch( - const absl::string_view& path, - const XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher& path_matcher) { +bool PathMatch(const absl::string_view& path, + const XdsApi::Route::Matchers::PathMatcher& path_matcher) { switch (path_matcher.type) { - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - PREFIX: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX: return absl::StartsWith(path, path_matcher.string_matcher); - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - PATH: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH: return path == path_matcher.string_matcher; - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - REGEX: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX: return RE2::FullMatch(path.data(), *path_matcher.regex_matcher); default: return false; @@ -262,7 +258,7 @@ absl::optional GetMetadataValue( } bool HeaderMatchHelper( - const XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher& header_matcher, + const XdsApi::Route::Matchers::HeaderMatcher& header_matcher, LoadBalancingPolicy::MetadataInterface* initial_metadata) { std::string concatenated_value; absl::optional value; @@ -279,8 +275,8 @@ bool HeaderMatchHelper( &concatenated_value); } if (!value.has_value()) { - if (header_matcher.type == XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PRESENT) { + if (header_matcher.type == + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PRESENT) { return !header_matcher.present_match; } else { // For all other header matcher types, we need the header value to @@ -289,25 +285,20 @@ bool HeaderMatchHelper( } } switch (header_matcher.type) { - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::EXACT: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::EXACT: return value.value() == header_matcher.string_matcher; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::REGEX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX: return RE2::FullMatch(value.value().data(), *header_matcher.regex_match); - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::RANGE: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE: int64_t int_value; if (!absl::SimpleAtoi(value.value(), &int_value)) { return false; } return int_value >= header_matcher.range_start && int_value < header_matcher.range_end; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::PREFIX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PREFIX: return absl::StartsWith(value.value(), header_matcher.string_matcher); - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::SUFFIX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::SUFFIX: return absl::EndsWith(value.value(), header_matcher.string_matcher); default: return false; @@ -315,8 +306,7 @@ bool HeaderMatchHelper( } bool HeadersMatch( - const std::vector& - header_matchers, + const std::vector& header_matchers, LoadBalancingPolicy::MetadataInterface* initial_metadata) { for (const auto& header_matcher : header_matchers) { bool match = HeaderMatchHelper(header_matcher, initial_metadata); @@ -865,8 +855,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { "field:prefix error: should be string")); } else { path_matcher_seen = true; - route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::PREFIX; + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX; route->matchers.path_matcher.string_matcher = it->second.string_value(); } } @@ -881,8 +871,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:path error: should be string")); } else { - route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::PATH; + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH; route->matchers.path_matcher.string_matcher = it->second.string_value(); } @@ -899,8 +889,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:regex error: should be string")); } else { - route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::REGEX; + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX; route->matchers.path_matcher.regex_matcher = absl::make_unique(it->second.string_value()); } @@ -925,8 +915,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { "value should be of type object")); } else { route->matchers.header_matchers.emplace_back(); - XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher& - header_matcher = route->matchers.header_matchers.back(); + XdsApi::Route::Matchers::HeaderMatcher& header_matcher = + route->matchers.header_matchers.back(); auto header_it = header_json.object_value().find("name"); if (header_it == header_json.object_value().end()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( @@ -960,8 +950,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:exact_match error: should be string")); } else { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::EXACT; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::EXACT; header_matcher.string_matcher = header_it->second.string_value(); } @@ -978,8 +968,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:regex_match error: should be string")); } else { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::REGEX; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::REGEX; header_matcher.regex_match = absl::make_unique(header_it->second.string_value()); } @@ -1025,8 +1015,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { "field:end missing")); } if (header_matcher.range_end > header_matcher.range_start) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::HeaderMatcher::HeaderMatcherType::RANGE; + header_matcher.type = XdsApi::Route::Matchers:: + HeaderMatcher::HeaderMatcherType::RANGE; } } } @@ -1040,12 +1030,12 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { } else { header_matcher_seen = true; if (header_it->second.type() == Json::Type::JSON_TRUE) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PRESENT; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::PRESENT; header_matcher.present_match = true; } else if (header_it->second.type() == Json::Type::JSON_FALSE) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PRESENT; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::PRESENT; header_matcher.present_match = false; } else { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( @@ -1065,8 +1055,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:prefix_match error: should be string")); } else { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PREFIX; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::PREFIX; header_matcher.string_matcher = header_it->second.string_value(); } @@ -1084,8 +1074,8 @@ class XdsRoutingLbFactory : public LoadBalancingPolicyFactory { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:suffix_match error: should be string")); } else { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::SUFFIX; + header_matcher.type = XdsApi::Route::Matchers::HeaderMatcher:: + HeaderMatcherType::SUFFIX; header_matcher.string_matcher = header_it->second.string_value(); } diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc index c0b93dc69ed..d522ce3a77a 100644 --- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc @@ -74,7 +74,7 @@ class XdsResolver : public Resolver { public: explicit ListenerWatcher(RefCountedPtr resolver) : resolver_(std::move(resolver)) {} - void OnListenerChanged(XdsApi::LdsUpdate listener_data) override; + void OnListenerChanged(std::vector routes) override; void OnError(grpc_error* error) override; void OnResourceDoesNotExist() override; @@ -92,15 +92,14 @@ class XdsResolver : public Resolver { // Returns the weighted_clusters action name to use from // weighted_cluster_index_map_ for a WeightedClusters route action. std::string WeightedClustersActionName( - const std::vector& - weighted_clusters); + const std::vector& weighted_clusters); // Updates weighted_cluster_index_map_ that will // determine the names of the WeightedCluster actions for the current update. - void UpdateWeightedClusterIndexMap(const XdsApi::RdsUpdate& rds_update); + void UpdateWeightedClusterIndexMap(const std::vector& routes); - // Create the service config generated by the RdsUpdate. - grpc_error* CreateServiceConfig(const XdsApi::RdsUpdate& rds_update, + // Create the service config generated by the list of routes. + grpc_error* CreateServiceConfig(const std::vector& routes, RefCountedPtr* service_config); std::string server_name_; @@ -131,15 +130,15 @@ class XdsResolver : public Resolver { // void XdsResolver::ListenerWatcher::OnListenerChanged( - XdsApi::LdsUpdate listener_data) { + std::vector routes) { if (resolver_->xds_client_ == nullptr) return; if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) { gpr_log(GPR_INFO, "[xds_resolver %p] received updated listener data", resolver_.get()); } Result result; - grpc_error* error = resolver_->CreateServiceConfig(*listener_data.rds_update, - &result.service_config); + grpc_error* error = + resolver_->CreateServiceConfig(routes, &result.service_config); if (error != GRPC_ERROR_NONE) { OnError(error); return; @@ -214,23 +213,20 @@ std::string CreateServiceConfigActionCluster(const std::string& cluster_name) { } std::string CreateServiceConfigRoute(const std::string& action_name, - const XdsApi::RdsUpdate::RdsRoute& route) { + const XdsApi::Route& route) { std::vector headers; for (const auto& header : route.matchers.header_matchers) { std::string header_matcher; switch (header.type) { - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::EXACT: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::EXACT: header_matcher = absl::StrFormat(" \"exact_match\": \"%s\"", header.string_matcher); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::REGEX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX: header_matcher = absl::StrFormat(" \"regex_match\": \"%s\"", header.regex_match->pattern()); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::RANGE: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE: header_matcher = absl::StrFormat( " \"range_match\":{\n" " \"start\":%d,\n" @@ -238,19 +234,16 @@ std::string CreateServiceConfigRoute(const std::string& action_name, " }", header.range_start, header.range_end); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::PRESENT: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PRESENT: header_matcher = absl::StrFormat(" \"present_match\": %s", header.present_match ? "true" : "false"); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::PREFIX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PREFIX: header_matcher = absl::StrFormat( " \"prefix_match\": \"%s\"", header.string_matcher); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher:: - HeaderMatcherType::SUFFIX: + case XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::SUFFIX: header_matcher = absl::StrFormat( " \"suffix_match\": \"%s\"", header.string_matcher); break; @@ -281,18 +274,15 @@ std::string CreateServiceConfigRoute(const std::string& action_name, } std::string path_match_str; switch (route.matchers.path_matcher.type) { - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - PREFIX: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX: path_match_str = absl::StrFormat( "\"prefix\": \"%s\",\n", route.matchers.path_matcher.string_matcher); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - PATH: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH: path_match_str = absl::StrFormat( "\"path\": \"%s\",\n", route.matchers.path_matcher.string_matcher); break; - case XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcherType:: - REGEX: + case XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX: path_match_str = absl::StrFormat("\"regex\": \"%s\",\n", route.matchers.path_matcher.regex_matcher->pattern()); @@ -316,7 +306,7 @@ std::string CreateServiceConfigRoute(const std::string& action_name, // Create the service config for one weighted cluster. std::string CreateServiceConfigActionWeightedCluster( const std::string& name, - const std::vector& clusters) { + const std::vector& clusters) { std::vector config_parts; config_parts.push_back( absl::StrFormat(" \"weighted:%s\":{\n" @@ -354,8 +344,7 @@ struct WeightedClustersKeys { // Returns the cluster names and weights key or the cluster names only key. WeightedClustersKeys GetWeightedClustersKey( - const std::vector& - weighted_clusters) { + const std::vector& weighted_clusters) { std::set cluster_names; std::set cluster_weights; for (const auto& cluster_weight : weighted_clusters) { @@ -368,8 +357,7 @@ WeightedClustersKeys GetWeightedClustersKey( } std::string XdsResolver::WeightedClustersActionName( - const std::vector& - weighted_clusters) { + const std::vector& weighted_clusters) { WeightedClustersKeys keys = GetWeightedClustersKey(weighted_clusters); auto cluster_names_map_it = weighted_cluster_index_map_.find(keys.cluster_names_key); @@ -384,13 +372,13 @@ std::string XdsResolver::WeightedClustersActionName( } void XdsResolver::UpdateWeightedClusterIndexMap( - const XdsApi::RdsUpdate& rds_update) { + const std::vector& routes) { // Construct a list of unique WeightedCluster // actions which we need to process: to find action names std::map actions_to_process; - for (const auto& route : rds_update.routes) { + for (const auto& route : routes) { if (!route.weighted_clusters.empty()) { WeightedClustersKeys keys = GetWeightedClustersKey(route.weighted_clusters); @@ -467,13 +455,13 @@ void XdsResolver::UpdateWeightedClusterIndexMap( } grpc_error* XdsResolver::CreateServiceConfig( - const XdsApi::RdsUpdate& rds_update, + const std::vector& routes, RefCountedPtr* service_config) { - UpdateWeightedClusterIndexMap(rds_update); + UpdateWeightedClusterIndexMap(routes); std::vector actions_vector; std::vector route_table; std::set actions_set; - for (const auto& route : rds_update.routes) { + for (const auto& route : routes) { const std::string action_name = route.weighted_clusters.empty() ? route.cluster_name diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index de96ca7b65a..570284aa07a 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -675,9 +675,6 @@ grpc_chttp2_stream::~grpc_chttp2_stream() { grpc_slice_buffer_destroy_internal(&decompressed_data_buffer); } - grpc_chttp2_list_remove_stalled_by_transport(t, this); - grpc_chttp2_list_remove_stalled_by_stream(t, this); - for (int i = 0; i < STREAM_LIST_COUNT; i++) { if (GPR_UNLIKELY(included[i])) { gpr_log(GPR_ERROR, "%s stream %d still included in list %d", @@ -2030,6 +2027,8 @@ static void remove_stream(grpc_chttp2_transport* t, uint32_t id, if (grpc_chttp2_list_remove_writable_stream(t, s)) { GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:remove_stream"); } + grpc_chttp2_list_remove_stalled_by_stream(t, s); + grpc_chttp2_list_remove_stalled_by_transport(t, s); GRPC_ERROR_UNREF(error); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 28da24f647d..b04a88db5a7 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -52,8 +52,12 @@ class ContextList; /* streams are kept in various linked lists depending on what things need to happen to them... this enum labels each list */ typedef enum { + /* If a stream is in the following two lists, an explicit ref is associated + with the stream */ GRPC_CHTTP2_LIST_WRITABLE, GRPC_CHTTP2_LIST_WRITING, + /* No additional ref is taken for the following refs. Make sure to remove the + stream from these lists when the stream is removed. */ GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, GRPC_CHTTP2_LIST_STALLED_BY_STREAM, /** streams that are waiting to start because there are too many concurrent diff --git a/src/core/ext/xds/xds_api.cc b/src/core/ext/xds/xds_api.cc index 45f5a76f07a..5c21e580167 100644 --- a/src/core/ext/xds/xds_api.cc +++ b/src/core/ext/xds/xds_api.cc @@ -74,11 +74,10 @@ namespace grpc_core { // -// XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher +// XdsApi::Route::Matchers::PathMatcher // -XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcher( - const PathMatcher& other) +XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other) : type(other.type) { if (type == PathMatcherType::REGEX) { regex_matcher = absl::make_unique(other.regex_matcher->pattern()); @@ -87,9 +86,8 @@ XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::PathMatcher( } } -XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher& -XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::operator=( - const PathMatcher& other) { +XdsApi::Route::Matchers::PathMatcher& XdsApi::Route::Matchers::PathMatcher:: +operator=(const PathMatcher& other) { type = other.type; if (type == PathMatcherType::REGEX) { regex_matcher = absl::make_unique(other.regex_matcher->pattern()); @@ -99,7 +97,7 @@ XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::operator=( return *this; } -bool XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::operator==( +bool XdsApi::Route::Matchers::PathMatcher::operator==( const PathMatcher& other) const { if (type != other.type) return false; if (type == PathMatcherType::REGEX) { @@ -112,8 +110,7 @@ bool XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::operator==( return string_matcher == other.string_matcher; } -std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString() - const { +std::string XdsApi::Route::Matchers::PathMatcher::ToString() const { std::string path_type_string; switch (type) { case PathMatcherType::PATH: @@ -135,10 +132,10 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString() } // -// XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher +// XdsApi::Route::Matchers::HeaderMatcher // -XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::HeaderMatcher( +XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcher( const HeaderMatcher& other) : name(other.name), type(other.type), invert_match(other.invert_match) { switch (type) { @@ -157,9 +154,8 @@ XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::HeaderMatcher( } } -XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher& -XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::operator=( - const HeaderMatcher& other) { +XdsApi::Route::Matchers::HeaderMatcher& XdsApi::Route::Matchers::HeaderMatcher:: +operator=(const HeaderMatcher& other) { name = other.name; type = other.type; invert_match = other.invert_match; @@ -180,7 +176,7 @@ XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::operator=( return *this; } -bool XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::operator==( +bool XdsApi::Route::Matchers::HeaderMatcher::operator==( const HeaderMatcher& other) const { if (name != other.name) return false; if (type != other.type) return false; @@ -197,8 +193,7 @@ bool XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::operator==( } } -std::string XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::ToString() - const { +std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const { switch (type) { case HeaderMatcherType::EXACT: return absl::StrFormat("Header exact match:%s %s:%s", @@ -226,7 +221,11 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::ToString() } } -std::string XdsApi::RdsUpdate::RdsRoute::Matchers::ToString() const { +// +// XdsApi::Route +// + +std::string XdsApi::Route::Matchers::ToString() const { std::vector contents; contents.push_back(path_matcher.ToString()); for (const auto& header_it : header_matchers) { @@ -239,11 +238,11 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::ToString() const { return absl::StrJoin(contents, "\n"); } -std::string XdsApi::RdsUpdate::RdsRoute::ClusterWeight::ToString() const { +std::string XdsApi::Route::ClusterWeight::ToString() const { return absl::StrFormat("{cluster=%s, weight=%d}", name, weight); } -std::string XdsApi::RdsUpdate::RdsRoute::ToString() const { +std::string XdsApi::Route::ToString() const { std::vector contents; contents.push_back(matchers.ToString()); if (!cluster_name.empty()) { @@ -255,12 +254,124 @@ std::string XdsApi::RdsUpdate::RdsRoute::ToString() const { return absl::StrJoin(contents, "\n"); } +// +// XdsApi::RdsUpdate +// + std::string XdsApi::RdsUpdate::ToString() const { - std::vector contents; - for (const auto& route_it : routes) { - contents.push_back(route_it.ToString()); + std::vector vhosts; + for (const VirtualHost& vhost : virtual_hosts) { + vhosts.push_back( + absl::StrCat("vhost={\n" + " domains=[", + absl::StrJoin(vhost.domains, ", "), + "]\n" + " routes=[\n")); + for (const XdsApi::Route& route : vhost.routes) { + vhosts.push_back(" {\n"); + vhosts.push_back(route.ToString()); + vhosts.push_back("\n }\n"); + } + vhosts.push_back(" ]\n"); + vhosts.push_back("]\n"); } - return absl::StrJoin(contents, ",\n"); + return absl::StrJoin(vhosts, ""); +} + +namespace { + +// Better match type has smaller value. +enum MatchType { + EXACT_MATCH, + SUFFIX_MATCH, + PREFIX_MATCH, + UNIVERSE_MATCH, + INVALID_MATCH, +}; + +// Returns true if match succeeds. +bool DomainMatch(MatchType match_type, std::string domain_pattern, + std::string expected_host_name) { + // Normalize the args to lower-case. Domain matching is case-insensitive. + std::transform(domain_pattern.begin(), domain_pattern.end(), + domain_pattern.begin(), + [](unsigned char c) { return std::tolower(c); }); + std::transform(expected_host_name.begin(), expected_host_name.end(), + expected_host_name.begin(), + [](unsigned char c) { return std::tolower(c); }); + if (match_type == EXACT_MATCH) { + return domain_pattern == expected_host_name; + } else if (match_type == SUFFIX_MATCH) { + // Asterisk must match at least one char. + if (expected_host_name.size() < domain_pattern.size()) return false; + absl::string_view pattern_suffix(domain_pattern.c_str() + 1); + absl::string_view host_suffix(expected_host_name.c_str() + + expected_host_name.size() - + pattern_suffix.size()); + return pattern_suffix == host_suffix; + } else if (match_type == PREFIX_MATCH) { + // Asterisk must match at least one char. + if (expected_host_name.size() < domain_pattern.size()) return false; + absl::string_view pattern_prefix(domain_pattern.c_str(), + domain_pattern.size() - 1); + absl::string_view host_prefix(expected_host_name.c_str(), + pattern_prefix.size()); + return pattern_prefix == host_prefix; + } else { + return match_type == UNIVERSE_MATCH; + } +} + +MatchType DomainPatternMatchType(const std::string& domain_pattern) { + if (domain_pattern.empty()) return INVALID_MATCH; + if (domain_pattern.find('*') == std::string::npos) return EXACT_MATCH; + if (domain_pattern == "*") return UNIVERSE_MATCH; + if (domain_pattern[0] == '*') return SUFFIX_MATCH; + if (domain_pattern[domain_pattern.size() - 1] == '*') return PREFIX_MATCH; + return INVALID_MATCH; +} + +} // namespace + +const XdsApi::RdsUpdate::VirtualHost* +XdsApi::RdsUpdate::FindVirtualHostForDomain(const std::string& domain) const { + // Find the best matched virtual host. + // The search order for 4 groups of domain patterns: + // 1. Exact match. + // 2. Suffix match (e.g., "*ABC"). + // 3. Prefix match (e.g., "ABC*"). + // 4. Universe match (i.e., "*"). + // Within each group, longest match wins. + // If the same best matched domain pattern appears in multiple virtual hosts, + // the first matched virtual host wins. + const VirtualHost* target_vhost = nullptr; + MatchType best_match_type = INVALID_MATCH; + size_t longest_match = 0; + // Check each domain pattern in each virtual host to determine the best + // matched virtual host. + for (const VirtualHost& vhost : virtual_hosts) { + for (const std::string& domain_pattern : vhost.domains) { + // Check the match type first. Skip the pattern if it's not better than + // current match. + const MatchType match_type = DomainPatternMatchType(domain_pattern); + // This should be caught by RouteConfigParse(). + GPR_ASSERT(match_type != INVALID_MATCH); + if (match_type > best_match_type) continue; + if (match_type == best_match_type && + domain_pattern.size() <= longest_match) { + continue; + } + // Skip if match fails. + if (!DomainMatch(match_type, domain_pattern, domain)) continue; + // Choose this match. + target_vhost = &vhost; + best_match_type = match_type; + longest_match = domain_pattern.size(); + if (best_match_type == EXACT_MATCH) break; + } + if (best_match_type == EXACT_MATCH) break; + } + return target_vhost; } // @@ -1163,60 +1274,8 @@ void MaybeLogClusterLoadAssignment( } } -// Better match type has smaller value. -enum MatchType { - EXACT_MATCH, - SUFFIX_MATCH, - PREFIX_MATCH, - UNIVERSE_MATCH, - INVALID_MATCH, -}; - -// Returns true if match succeeds. -bool DomainMatch(MatchType match_type, std::string domain_pattern, - std::string expected_host_name) { - // Normalize the args to lower-case. Domain matching is case-insensitive. - std::transform(domain_pattern.begin(), domain_pattern.end(), - domain_pattern.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(expected_host_name.begin(), expected_host_name.end(), - expected_host_name.begin(), - [](unsigned char c) { return std::tolower(c); }); - if (match_type == EXACT_MATCH) { - return domain_pattern == expected_host_name; - } else if (match_type == SUFFIX_MATCH) { - // Asterisk must match at least one char. - if (expected_host_name.size() < domain_pattern.size()) return false; - absl::string_view pattern_suffix(domain_pattern.c_str() + 1); - absl::string_view host_suffix(expected_host_name.c_str() + - expected_host_name.size() - - pattern_suffix.size()); - return pattern_suffix == host_suffix; - } else if (match_type == PREFIX_MATCH) { - // Asterisk must match at least one char. - if (expected_host_name.size() < domain_pattern.size()) return false; - absl::string_view pattern_prefix(domain_pattern.c_str(), - domain_pattern.size() - 1); - absl::string_view host_prefix(expected_host_name.c_str(), - pattern_prefix.size()); - return pattern_prefix == host_prefix; - } else { - return match_type == UNIVERSE_MATCH; - } -} - -MatchType DomainPatternMatchType(const std::string& domain_pattern) { - if (domain_pattern.empty()) return INVALID_MATCH; - if (domain_pattern.find('*') == std::string::npos) return EXACT_MATCH; - if (domain_pattern == "*") return UNIVERSE_MATCH; - if (domain_pattern[0] == '*') return SUFFIX_MATCH; - if (domain_pattern[domain_pattern.size() - 1] == '*') return PREFIX_MATCH; - return INVALID_MATCH; -} - grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match, - XdsApi::RdsUpdate::RdsRoute* rds_route, - bool* ignore_route) { + XdsApi::Route* route, bool* ignore_route) { if (envoy_config_route_v3_RouteMatch_has_prefix(match)) { absl::string_view prefix = UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match)); @@ -1241,9 +1300,9 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match, return GRPC_ERROR_NONE; } } - rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::PREFIX; - rds_route->matchers.path_matcher.string_matcher = std::string(prefix); + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX; + route->matchers.path_matcher.string_matcher = std::string(prefix); } else if (envoy_config_route_v3_RouteMatch_has_path(match)) { absl::string_view path = UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match)); @@ -1276,9 +1335,9 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match, *ignore_route = true; return GRPC_ERROR_NONE; } - rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::PATH; - rds_route->matchers.path_matcher.string_matcher = std::string(path); + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH; + route->matchers.path_matcher.string_matcher = std::string(path); } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) { const envoy_type_matcher_v3_RegexMatcher* regex_matcher = envoy_config_route_v3_RouteMatch_safe_regex(match); @@ -1290,9 +1349,9 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match, return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Invalid regex string specified in path matcher."); } - rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute:: - Matchers::PathMatcher::PathMatcherType::REGEX; - rds_route->matchers.path_matcher.regex_matcher = std::move(regex); + route->matchers.path_matcher.type = + XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX; + route->matchers.path_matcher.regex_matcher = std::move(regex); } else { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Invalid route path specifier specified."); @@ -1301,19 +1360,18 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match, } grpc_error* RouteHeaderMatchersParse( - const envoy_config_route_v3_RouteMatch* match, - XdsApi::RdsUpdate::RdsRoute* rds_route) { + const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) { size_t size; const envoy_config_route_v3_HeaderMatcher* const* headers = envoy_config_route_v3_RouteMatch_headers(match, &size); for (size_t i = 0; i < size; ++i) { const envoy_config_route_v3_HeaderMatcher* header = headers[i]; - XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher header_matcher; + XdsApi::Route::Matchers::HeaderMatcher header_matcher; header_matcher.name = UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header)); if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::EXACT; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::EXACT; header_matcher.string_matcher = UpbStringToStdString( envoy_config_route_v3_HeaderMatcher_exact_match(header)); } else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match( @@ -1328,12 +1386,12 @@ grpc_error* RouteHeaderMatchersParse( return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Invalid regex string specified in header matcher."); } - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::REGEX; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX; header_matcher.regex_match = std::move(regex); } else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::RANGE; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE; const envoy_type_v3_Int64Range* range_matcher = envoy_config_route_v3_HeaderMatcher_range_match(header); header_matcher.range_start = @@ -1345,18 +1403,18 @@ grpc_error* RouteHeaderMatchersParse( "cannot be smaller than start."); } } else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PRESENT; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PRESENT; header_matcher.present_match = envoy_config_route_v3_HeaderMatcher_present_match(header); } else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::PREFIX; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PREFIX; header_matcher.string_matcher = UpbStringToStdString( envoy_config_route_v3_HeaderMatcher_prefix_match(header)); } else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) { - header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers:: - HeaderMatcher::HeaderMatcherType::SUFFIX; + header_matcher.type = + XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::SUFFIX; header_matcher.string_matcher = UpbStringToStdString( envoy_config_route_v3_HeaderMatcher_suffix_match(header)); } else { @@ -1365,14 +1423,13 @@ grpc_error* RouteHeaderMatchersParse( } header_matcher.invert_match = envoy_config_route_v3_HeaderMatcher_invert_match(header); - rds_route->matchers.header_matchers.emplace_back(std::move(header_matcher)); + route->matchers.header_matchers.emplace_back(std::move(header_matcher)); } return GRPC_ERROR_NONE; } grpc_error* RouteRuntimeFractionParse( - const envoy_config_route_v3_RouteMatch* match, - XdsApi::RdsUpdate::RdsRoute* rds_route) { + const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) { const envoy_config_core_v3_RuntimeFractionalPercent* runtime_fraction = envoy_config_route_v3_RouteMatch_runtime_fraction(match); if (runtime_fraction != nullptr) { @@ -1398,26 +1455,25 @@ grpc_error* RouteRuntimeFractionParse( return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Unknown denominator type"); } - rds_route->matchers.fraction_per_million = numerator; + route->matchers.fraction_per_million = numerator; } } return GRPC_ERROR_NONE; } -grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route, - XdsApi::RdsUpdate::RdsRoute* rds_route, - bool* ignore_route) { - if (!envoy_config_route_v3_Route_has_route(route)) { +grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg, + XdsApi::Route* route, bool* ignore_route) { + if (!envoy_config_route_v3_Route_has_route(route_msg)) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "No RouteAction found in route."); } const envoy_config_route_v3_RouteAction* route_action = - envoy_config_route_v3_Route_route(route); + envoy_config_route_v3_Route_route(route_msg); // Get the cluster or weighted_clusters in the RouteAction. if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) { - rds_route->cluster_name = UpbStringToStdString( + route->cluster_name = UpbStringToStdString( envoy_config_route_v3_RouteAction_cluster(route_action)); - if (rds_route->cluster_name.size() == 0) { + if (route->cluster_name.size() == 0) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "RouteAction cluster contains empty cluster name."); } @@ -1439,7 +1495,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route, for (size_t j = 0; j < clusters_size; ++j) { const envoy_config_route_v3_WeightedCluster_ClusterWeight* cluster_weight = clusters[j]; - XdsApi::RdsUpdate::RdsRoute::ClusterWeight cluster; + XdsApi::Route::ClusterWeight cluster; cluster.name = UpbStringToStdString( envoy_config_route_v3_WeightedCluster_ClusterWeight_name( cluster_weight)); @@ -1457,13 +1513,13 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route, } cluster.weight = google_protobuf_UInt32Value_value(weight); sum_of_weights += cluster.weight; - rds_route->weighted_clusters.emplace_back(std::move(cluster)); + route->weighted_clusters.emplace_back(std::move(cluster)); } if (total_weight != sum_of_weights) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "RouteAction weighted_cluster has incorrect total weight"); } - if (rds_route->weighted_clusters.empty()) { + if (route->weighted_clusters.empty()) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING( "RouteAction weighted_cluster has no valid clusters specified."); } @@ -1478,101 +1534,73 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route, grpc_error* RouteConfigParse( XdsClient* client, TraceFlag* tracer, const envoy_config_route_v3_RouteConfiguration* route_config, - const std::string& expected_server_name, XdsApi::RdsUpdate* rds_update) { + XdsApi::RdsUpdate* rds_update) { MaybeLogRouteConfiguration(client, tracer, route_config); // Get the virtual hosts. size_t size; const envoy_config_route_v3_VirtualHost* const* virtual_hosts = envoy_config_route_v3_RouteConfiguration_virtual_hosts(route_config, &size); - // Find the best matched virtual host. - // The search order for 4 groups of domain patterns: - // 1. Exact match. - // 2. Suffix match (e.g., "*ABC"). - // 3. Prefix match (e.g., "ABC*"). - // 4. Universe match (i.e., "*"). - // Within each group, longest match wins. - // If the same best matched domain pattern appears in multiple virtual hosts, - // the first matched virtual host wins. - const envoy_config_route_v3_VirtualHost* target_virtual_host = nullptr; - MatchType best_match_type = INVALID_MATCH; - size_t longest_match = 0; - // Check each domain pattern in each virtual host to determine the best - // matched virtual host. for (size_t i = 0; i < size; ++i) { + rds_update->virtual_hosts.emplace_back(); + XdsApi::RdsUpdate::VirtualHost& vhost = rds_update->virtual_hosts.back(); + // Parse domains. size_t domain_size; upb_strview const* domains = envoy_config_route_v3_VirtualHost_domains( virtual_hosts[i], &domain_size); for (size_t j = 0; j < domain_size; ++j) { - const std::string domain_pattern(domains[j].data, domains[j].size); - // Check the match type first. Skip the pattern if it's not better than - // current match. + std::string domain_pattern = UpbStringToStdString(domains[j]); const MatchType match_type = DomainPatternMatchType(domain_pattern); if (match_type == INVALID_MATCH) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid domain pattern."); } - if (match_type > best_match_type) continue; - if (match_type == best_match_type && - domain_pattern.size() <= longest_match) { + vhost.domains.emplace_back(std::move(domain_pattern)); + } + if (vhost.domains.empty()) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("VirtualHost has no domains"); + } + // Parse routes. + size_t num_routes; + const envoy_config_route_v3_Route* const* routes = + envoy_config_route_v3_VirtualHost_routes(virtual_hosts[i], &num_routes); + if (num_routes < 1) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "No route found in the virtual host."); + } + // Loop over the whole list of routes + for (size_t j = 0; j < num_routes; ++j) { + const envoy_config_route_v3_RouteMatch* match = + envoy_config_route_v3_Route_match(routes[j]); + size_t query_parameters_size; + static_cast(envoy_config_route_v3_RouteMatch_query_parameters( + match, &query_parameters_size)); + if (query_parameters_size > 0) { continue; } - // Skip if match fails. - if (!DomainMatch(match_type, domain_pattern, expected_server_name)) { - continue; + XdsApi::Route route; + bool ignore_route = false; + grpc_error* error = RoutePathMatchParse(match, &route, &ignore_route); + if (error != GRPC_ERROR_NONE) return error; + if (ignore_route) continue; + error = RouteHeaderMatchersParse(match, &route); + if (error != GRPC_ERROR_NONE) return error; + error = RouteRuntimeFractionParse(match, &route); + if (error != GRPC_ERROR_NONE) return error; + error = RouteActionParse(routes[j], &route, &ignore_route); + if (error != GRPC_ERROR_NONE) return error; + if (ignore_route) continue; + const google_protobuf_BoolValue* case_sensitive = + envoy_config_route_v3_RouteMatch_case_sensitive(match); + if (case_sensitive != nullptr && + !google_protobuf_BoolValue_value(case_sensitive)) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "case_sensitive if set must be set to true."); } - // Choose this match. - target_virtual_host = virtual_hosts[i]; - best_match_type = match_type; - longest_match = domain_pattern.size(); - if (best_match_type == EXACT_MATCH) break; - } - if (best_match_type == EXACT_MATCH) break; - } - if (target_virtual_host == nullptr) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "No matched virtual host found in the route config."); - } - // Get the route list from the matched virtual host. - const envoy_config_route_v3_Route* const* routes = - envoy_config_route_v3_VirtualHost_routes(target_virtual_host, &size); - if (size < 1) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "No route found in the virtual host."); - } - // Loop over the whole list of routes - for (size_t i = 0; i < size; ++i) { - const envoy_config_route_v3_Route* route = routes[i]; - const envoy_config_route_v3_RouteMatch* match = - envoy_config_route_v3_Route_match(route); - size_t query_parameters_size; - static_cast(envoy_config_route_v3_RouteMatch_query_parameters( - match, &query_parameters_size)); - if (query_parameters_size > 0) { - continue; + vhost.routes.emplace_back(std::move(route)); } - XdsApi::RdsUpdate::RdsRoute rds_route; - bool ignore_route = false; - grpc_error* error = RoutePathMatchParse(match, &rds_route, &ignore_route); - if (error != GRPC_ERROR_NONE) return error; - if (ignore_route) continue; - error = RouteHeaderMatchersParse(match, &rds_route); - if (error != GRPC_ERROR_NONE) return error; - error = RouteRuntimeFractionParse(match, &rds_route); - if (error != GRPC_ERROR_NONE) return error; - error = RouteActionParse(route, &rds_route, &ignore_route); - if (error != GRPC_ERROR_NONE) return error; - if (ignore_route) continue; - const google_protobuf_BoolValue* case_sensitive = - envoy_config_route_v3_RouteMatch_case_sensitive(match); - if (case_sensitive != nullptr && - !google_protobuf_BoolValue_value(case_sensitive)) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "case_sensitive if set must be set to true."); + if (vhost.routes.empty()) { + return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified."); } - rds_update->routes.emplace_back(std::move(rds_route)); - } - if (rds_update->routes.empty()) { - return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified."); } return GRPC_ERROR_NONE; } @@ -1630,11 +1658,11 @@ grpc_error* LdsResponseParse( envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config( http_connection_manager); XdsApi::RdsUpdate rds_update; - grpc_error* error = RouteConfigParse(client, tracer, route_config, - expected_server_name, &rds_update); + grpc_error* error = + RouteConfigParse(client, tracer, route_config, &rds_update); if (error != GRPC_ERROR_NONE) return error; lds_update->emplace(); - (*lds_update)->rds_update.emplace(std::move(rds_update)); + (*lds_update)->rds_update = std::move(rds_update); return GRPC_ERROR_NONE; } // Validate that RDS must be used to get the route_config dynamically. @@ -1671,7 +1699,6 @@ grpc_error* LdsResponseParse( grpc_error* RdsResponseParse( XdsClient* client, TraceFlag* tracer, const envoy_service_discovery_v3_DiscoveryResponse* response, - const std::string& expected_server_name, const std::set& expected_route_configuration_names, absl::optional* rds_update, upb_arena* arena) { // Get the resources from the response. @@ -1703,8 +1730,8 @@ grpc_error* RdsResponseParse( } // Parse the route_config. XdsApi::RdsUpdate local_rds_update; - grpc_error* error = RouteConfigParse( - client, tracer, route_config, expected_server_name, &local_rds_update); + grpc_error* error = + RouteConfigParse(client, tracer, route_config, &local_rds_update); if (error != GRPC_ERROR_NONE) return error; rds_update->emplace(std::move(local_rds_update)); return GRPC_ERROR_NONE; @@ -2043,9 +2070,9 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse( LdsResponseParse(client_, tracer_, response, expected_server_name, &result.lds_update, arena.ptr()); } else if (IsRds(result.type_url)) { - result.parse_error = RdsResponseParse( - client_, tracer_, response, expected_server_name, - expected_route_configuration_names, &result.rds_update, arena.ptr()); + result.parse_error = RdsResponseParse(client_, tracer_, response, + expected_route_configuration_names, + &result.rds_update, arena.ptr()); } else if (IsCds(result.type_url)) { result.parse_error = CdsResponseParse(client_, tracer_, response, expected_cluster_names, diff --git a/src/core/ext/xds/xds_api.h b/src/core/ext/xds/xds_api.h index 3ec720e7104..265fec43c09 100644 --- a/src/core/ext/xds/xds_api.h +++ b/src/core/ext/xds/xds_api.h @@ -46,98 +46,109 @@ class XdsApi { static const char* kCdsTypeUrl; static const char* kEdsTypeUrl; - struct RdsUpdate { - // TODO(donnadionne): When we can use absl::variant<>, consider using that - // for: PathMatcher, HeaderMatcher, cluster_name and weighted_clusters - struct RdsRoute { - // Matchers for this route. - struct Matchers { - struct PathMatcher { - enum class PathMatcherType { - PATH, // path stored in string_matcher field - PREFIX, // prefix stored in string_matcher field - REGEX, // regex stored in regex_matcher field - }; - PathMatcherType type; - std::string string_matcher; - std::unique_ptr regex_matcher; - - PathMatcher() = default; - PathMatcher(const PathMatcher& other); - PathMatcher& operator=(const PathMatcher& other); - bool operator==(const PathMatcher& other) const; - std::string ToString() const; - }; - - struct HeaderMatcher { - enum class HeaderMatcherType { - EXACT, // value stored in string_matcher field - REGEX, // uses regex_match field - RANGE, // uses range_start and range_end fields - PRESENT, // uses present_match field - PREFIX, // prefix stored in string_matcher field - SUFFIX, // suffix stored in string_matcher field - }; - std::string name; - HeaderMatcherType type; - int64_t range_start; - int64_t range_end; - std::string string_matcher; - std::unique_ptr regex_match; - bool present_match; - // invert_match field may or may not exisit, so initialize it to - // false. - bool invert_match = false; - - HeaderMatcher() = default; - HeaderMatcher(const HeaderMatcher& other); - HeaderMatcher& operator=(const HeaderMatcher& other); - bool operator==(const HeaderMatcher& other) const; - std::string ToString() const; + // TODO(donnadionne): When we can use absl::variant<>, consider using that + // for: PathMatcher, HeaderMatcher, cluster_name and weighted_clusters + struct Route { + // Matchers for this route. + struct Matchers { + struct PathMatcher { + enum class PathMatcherType { + PATH, // path stored in string_matcher field + PREFIX, // prefix stored in string_matcher field + REGEX, // regex stored in regex_matcher field }; - - PathMatcher path_matcher; - std::vector header_matchers; - absl::optional fraction_per_million; - - bool operator==(const Matchers& other) const { - return (path_matcher == other.path_matcher && - header_matchers == other.header_matchers && - fraction_per_million == other.fraction_per_million); - } + PathMatcherType type; + std::string string_matcher; + std::unique_ptr regex_matcher; + + PathMatcher() = default; + PathMatcher(const PathMatcher& other); + PathMatcher& operator=(const PathMatcher& other); + bool operator==(const PathMatcher& other) const; std::string ToString() const; }; - Matchers matchers; - - // Action for this route. - // TODO(roth): When we can use absl::variant<>, consider using that - // here, to enforce the fact that only one of the two fields can be set. - std::string cluster_name; - struct ClusterWeight { + struct HeaderMatcher { + enum class HeaderMatcherType { + EXACT, // value stored in string_matcher field + REGEX, // uses regex_match field + RANGE, // uses range_start and range_end fields + PRESENT, // uses present_match field + PREFIX, // prefix stored in string_matcher field + SUFFIX, // suffix stored in string_matcher field + }; std::string name; - uint32_t weight; - bool operator==(const ClusterWeight& other) const { - return (name == other.name && weight == other.weight); - } + HeaderMatcherType type; + int64_t range_start; + int64_t range_end; + std::string string_matcher; + std::unique_ptr regex_match; + bool present_match; + // invert_match field may or may not exisit, so initialize it to + // false. + bool invert_match = false; + + HeaderMatcher() = default; + HeaderMatcher(const HeaderMatcher& other); + HeaderMatcher& operator=(const HeaderMatcher& other); + bool operator==(const HeaderMatcher& other) const; std::string ToString() const; }; - std::vector weighted_clusters; - bool operator==(const RdsRoute& other) const { - return (matchers == other.matchers && - cluster_name == other.cluster_name && - weighted_clusters == other.weighted_clusters); + PathMatcher path_matcher; + std::vector header_matchers; + absl::optional fraction_per_million; + + bool operator==(const Matchers& other) const { + return (path_matcher == other.path_matcher && + header_matchers == other.header_matchers && + fraction_per_million == other.fraction_per_million); } std::string ToString() const; }; - std::vector routes; + Matchers matchers; + + // Action for this route. + // TODO(roth): When we can use absl::variant<>, consider using that + // here, to enforce the fact that only one of the two fields can be set. + std::string cluster_name; + struct ClusterWeight { + std::string name; + uint32_t weight; + bool operator==(const ClusterWeight& other) const { + return (name == other.name && weight == other.weight); + } + std::string ToString() const; + }; + std::vector weighted_clusters; + + bool operator==(const Route& other) const { + return (matchers == other.matchers && + cluster_name == other.cluster_name && + weighted_clusters == other.weighted_clusters); + } + std::string ToString() const; + }; + + struct RdsUpdate { + struct VirtualHost { + std::vector domains; + std::vector routes; + + bool operator==(const VirtualHost& other) const { + return domains == other.domains && routes == other.routes; + } + }; + + std::vector virtual_hosts; bool operator==(const RdsUpdate& other) const { - return routes == other.routes; + return virtual_hosts == other.virtual_hosts; } std::string ToString() const; + const VirtualHost* FindVirtualHostForDomain( + const std::string& domain) const; }; // TODO(roth): When we can use absl::variant<>, consider using that @@ -145,8 +156,8 @@ class XdsApi { struct LdsUpdate { // The name to use in the RDS request. std::string route_config_name; - // The name to use in the CDS request. Present if the LDS response has it - // inlined. + // The RouteConfiguration to use for this listener. + // Present only if it is inlined in the LDS response. absl::optional rds_update; bool operator==(const LdsUpdate& other) const { diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc index 67ee5fd2177..976b1cbe252 100644 --- a/src/core/ext/xds/xds_client.cc +++ b/src/core/ext/xds/xds_client.cc @@ -448,7 +448,7 @@ grpc_channel_args* BuildXdsChannelArgs(const grpc_channel_args& args) { absl::InlinedVector args_to_add; // Keepalive interval. args_to_add.emplace_back(grpc_channel_arg_integer_create( - const_cast(GRPC_ARG_KEEPALIVE_TIME_MS), 5000)); + const_cast(GRPC_ARG_KEEPALIVE_TIME_MS), 5 * 60 * GPR_MS_PER_SEC)); // A channel arg indicating that the target is an xds server. // TODO(roth): Once we figure out our fallback and credentials story, decide // whether this is actually needed. Note that it's currently used by the @@ -787,7 +787,7 @@ void XdsClient::ChannelState::AdsCallState::Orphan() { // on_status_received_ will complete the cancellation and clean up. Otherwise, // we are here because xds_client has to orphan a failed call, then the // following cancellation will be a no-op. - grpc_call_cancel(call_, nullptr); + grpc_call_cancel_internal(call_); state_map_.clear(); // Note that the initial ref is hold by on_status_received_. So the // corresponding unref happens in on_status_received_ instead of here. @@ -892,13 +892,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate( ? lds_update->route_config_name.c_str() : "")); if (lds_update->rds_update.has_value()) { - gpr_log(GPR_INFO, "RouteConfiguration contains %" PRIuPTR " routes", - lds_update->rds_update.value().routes.size()); - for (size_t i = 0; i < lds_update->rds_update.value().routes.size(); - ++i) { - gpr_log(GPR_INFO, "Route %" PRIuPTR ":\n%s", i, - lds_update->rds_update.value().routes[i].ToString().c_str()); - } + gpr_log(GPR_INFO, "RouteConfiguration: %s", + lds_update->rds_update->ToString().c_str()); } } auto& lds_state = state_map_[XdsApi::kLdsTypeUrl]; @@ -924,8 +919,16 @@ void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate( if (xds_client()->lds_result_->rds_update.has_value()) { // If the RouteConfiguration was found inlined in LDS response, notify // the watcher immediately. - xds_client()->listener_watcher_->OnListenerChanged( - *xds_client()->lds_result_); + const XdsApi::RdsUpdate::VirtualHost* vhost = + xds_client()->lds_result_->rds_update->FindVirtualHostForDomain( + xds_client()->server_name_); + if (vhost == nullptr) { + xds_client()->listener_watcher_->OnError( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "no VirtualHost found for domain")); + } else { + xds_client()->listener_watcher_->OnListenerChanged(vhost->routes); + } } else { // Send RDS request for dynamic resolution. Subscribe(XdsApi::kRdsTypeUrl, @@ -944,14 +947,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate( return; } if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { - gpr_log(GPR_INFO, - "[xds_client %p] RDS update received; RouteConfiguration contains " - "%" PRIuPTR " routes", - this, rds_update.value().routes.size()); - for (size_t i = 0; i < rds_update.value().routes.size(); ++i) { - gpr_log(GPR_INFO, "Route %" PRIuPTR ":\n%s", i, - rds_update.value().routes[i].ToString().c_str()); - } + gpr_log(GPR_INFO, "[xds_client %p] RDS update received:\n%s", xds_client(), + rds_update->ToString().c_str()); } auto& rds_state = state_map_[XdsApi::kRdsTypeUrl]; auto& state = @@ -969,9 +966,16 @@ void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate( } xds_client()->rds_result_ = std::move(rds_update); // Notify the watcher. - XdsApi::LdsUpdate lds_result = *xds_client()->lds_result_; - lds_result.rds_update = xds_client()->rds_result_; - xds_client()->listener_watcher_->OnListenerChanged(lds_result); + const XdsApi::RdsUpdate::VirtualHost* vhost = + xds_client()->rds_result_->FindVirtualHostForDomain( + xds_client()->server_name_); + if (vhost == nullptr) { + xds_client()->listener_watcher_->OnError( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "no VirtualHost found for domain")); + } else { + xds_client()->listener_watcher_->OnListenerChanged(vhost->routes); + } } void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate( @@ -1553,7 +1557,7 @@ void XdsClient::ChannelState::LrsCallState::Orphan() { // on_status_received_ will complete the cancellation and clean up. Otherwise, // we are here because xds_client has to orphan a failed call, then the // following cancellation will be a no-op. - grpc_call_cancel(call_, nullptr); + grpc_call_cancel_internal(call_); // Note that the initial ref is hold by on_status_received_. So the // corresponding unref happens in on_status_received_ instead of here. } diff --git a/src/core/ext/xds/xds_client.h b/src/core/ext/xds/xds_client.h index cb8864b0e27..c9184348a8c 100644 --- a/src/core/ext/xds/xds_client.h +++ b/src/core/ext/xds/xds_client.h @@ -45,7 +45,7 @@ class XdsClient : public InternallyRefCounted { public: virtual ~ListenerWatcherInterface() = default; - virtual void OnListenerChanged(XdsApi::LdsUpdate listener_data) = 0; + virtual void OnListenerChanged(std::vector routes) = 0; virtual void OnError(grpc_error* error) = 0; diff --git a/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h b/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h new file mode 100644 index 00000000000..d9d99726787 --- /dev/null +++ b/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h @@ -0,0 +1,42 @@ +// Copyright 2020 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. + +#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H +#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H + +#include + +#include + +#include "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h" + +namespace grpc_core { +namespace mock_cel { + +// This is a temporary stub implementation of CEL APIs. +// Once gRPC imports the CEL library, this file will be removed. + +struct InterpreterOptions { + bool short_circuiting = true; +}; + +std::unique_ptr CreateCelExpressionBuilder( + const InterpreterOptions& options) { + return absl::make_unique(); +} + +} // namespace mock_cel +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPR_BUILDER_FACTORY_H \ No newline at end of file diff --git a/src/core/lib/security/authorization/mock_cel/cel_expression.h b/src/core/lib/security/authorization/mock_cel/cel_expression.h new file mode 100644 index 00000000000..bdeba67a41d --- /dev/null +++ b/src/core/lib/security/authorization/mock_cel/cel_expression.h @@ -0,0 +1,68 @@ +// Copyright 2020 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. + +#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H +#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H + +#include + +#include +#include + +#include "google/api/expr/v1alpha1/syntax.upb.h" +#include "src/core/lib/security/authorization/mock_cel/activation.h" +#include "src/core/lib/security/authorization/mock_cel/cel_value.h" +#include "src/core/lib/security/authorization/mock_cel/statusor.h" + +namespace grpc_core { +namespace mock_cel { + +// This is a temporary stub implementation of CEL APIs. +// Once gRPC imports the CEL library, this file will be removed. + +// Base interface for expression evaluating objects. +class CelExpression { + public: + virtual ~CelExpression() = default; + + // Evaluates expression and returns value. + // activation contains bindings from parameter names to values + virtual StatusOr Evaluate( + const BaseActivation& activation) const = 0; +}; + +// Base class for Expression Builder implementations +// Provides user with factory to register extension functions. +// ExpressionBuilder MUST NOT be destroyed before CelExpression objects +// it built. +class CelExpressionBuilder { + public: + virtual ~CelExpressionBuilder() = default; + + // Creates CelExpression object from AST tree. + // expr specifies root of AST tree + virtual StatusOr> CreateExpression( + const google_api_expr_v1alpha1_Expr* expr, + const google_api_expr_v1alpha1_SourceInfo* source_info) const = 0; + + virtual StatusOr> CreateExpression( + const google_api_expr_v1alpha1_Expr* expr, + const google_api_expr_v1alpha1_SourceInfo* source_info, + std::vector* warnings) const = 0; +}; + +} // namespace mock_cel +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_CEL_EXPRESSION_H \ No newline at end of file diff --git a/src/core/lib/security/authorization/mock_cel/evaluator_core.h b/src/core/lib/security/authorization/mock_cel/evaluator_core.h new file mode 100644 index 00000000000..7ddf495baf0 --- /dev/null +++ b/src/core/lib/security/authorization/mock_cel/evaluator_core.h @@ -0,0 +1,67 @@ +// Copyright 2020 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. + +#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H +#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H + +#include + +#include +#include +#include + +#include "google/api/expr/v1alpha1/syntax.upb.h" +#include "src/core/lib/security/authorization/mock_cel/activation.h" +#include "src/core/lib/security/authorization/mock_cel/cel_expression.h" +#include "src/core/lib/security/authorization/mock_cel/cel_value.h" +#include "src/core/lib/security/authorization/mock_cel/statusor.h" + +namespace grpc_core { +namespace mock_cel { + +// This is a temporary stub implementation of CEL APIs. +// Once gRPC imports the CEL library, this file will be removed. + +class ExpressionStep { + public: + virtual ~ExpressionStep() = default; +}; + +using ExecutionPath = std::vector>; + +// Implementation of the CelExpression that utilizes flattening +// of the expression tree. +class CelExpressionFlatImpl : public CelExpression { + // Constructs CelExpressionFlatImpl instance. + // path is flat execution path that is based upon + // flattened AST tree. Max iterations dictates the maximum number of + // iterations in the comprehension expressions (use 0 to disable the upper + // bound). + public: + CelExpressionFlatImpl(const google_api_expr_v1alpha1_Expr* root_expr, + ExecutionPath path, int max_iterations, + std::set iter_variable_names, + bool enable_unknowns = false, + bool enable_unknown_function_results = false) {} + + // Implementation of CelExpression evaluate method. + StatusOr Evaluate(const BaseActivation& activation) const override { + return CelValue::CreateNull(); + } +}; + +} // namespace mock_cel +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H \ No newline at end of file diff --git a/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h b/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h new file mode 100644 index 00000000000..86f5a239a32 --- /dev/null +++ b/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h @@ -0,0 +1,56 @@ +// Copyright 2020 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. + +#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H +#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H + +#include + +#include + +#include "src/core/lib/security/authorization/mock_cel/evaluator_core.h" + +namespace grpc_core { +namespace mock_cel { + +// This is a temporary stub implementation of CEL APIs. +// Once gRPC imports the CEL library, this file will be removed. + +// CelExpressionBuilder implementation. +// Builds instances of CelExpressionFlatImpl. +class FlatExprBuilder : public CelExpressionBuilder { + public: + FlatExprBuilder() = default; + + cel_base::StatusOr> CreateExpression( + const google::api::expr::v1alpha1::Expr* expr, + const google::api::expr::v1alpha1::SourceInfo* source_info) + const override { + ExecutionPath path; + return absl::make_unique(nullptr, path, 0); + } + + cel_base::StatusOr> CreateExpression( + const google::api::expr::v1alpha1::Expr* expr, + const google::api::expr::v1alpha1::SourceInfo* source_info, + std::vector* warnings) const override { + ExecutionPath path; + return absl::make_unique(nullptr, path, 0); + } +}; + +} // namespace mock_cel +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H diff --git a/src/core/lib/security/authorization/mock_cel/statusor.h b/src/core/lib/security/authorization/mock_cel/statusor.h new file mode 100644 index 00000000000..f97a8ec1229 --- /dev/null +++ b/src/core/lib/security/authorization/mock_cel/statusor.h @@ -0,0 +1,50 @@ +// Copyright 2020 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. + +#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H +#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H + +#include + +#include + +#include "absl/status/status.h" + +namespace grpc_core { +namespace mock_cel { + +// This is a temporary stub implementation of CEL APIs. +// Once gRPC imports the CEL library, this file will be removed. + +template +class ABSL_MUST_USE_RESULT StatusOr; + +template +class StatusOr { + public: + StatusOr() = default; + + StatusOr(const T& value) {} + + StatusOr(const absl::Status& status) {} + + StatusOr(absl::Status&& status) {} + + bool ok() const { return true; } +}; + +} // namespace mock_cel +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H \ No newline at end of file diff --git a/src/core/lib/security/certificate_provider.h b/src/core/lib/security/certificate_provider.h new file mode 100644 index 00000000000..5a9af3d615e --- /dev/null +++ b/src/core/lib/security/certificate_provider.h @@ -0,0 +1,59 @@ +// +// +// Copyright 2020 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. +// +// + +#ifndef GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H +#define GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H + +#include + +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/pollset_set.h" + +// TODO(yashkt): After https://github.com/grpc/grpc/pull/23572, remove this +// forward declaration and include the header for the distributor instead. +struct grpc_tls_certificate_distributor; + +// Interface for a grpc_tls_certificate_provider that handles the process to +// fetch credentials and validation contexts. Implementations are free to rely +// on local or remote sources to fetch the latest secrets, and free to share any +// state among different instances as they deem fit. +// +// On creation, grpc_tls_certificate_provider creates a +// grpc_tls_certificate_distributor object. When the credentials and validation +// contexts become valid or changed, a grpc_tls_certificate_provider should +// notify its distributor so as to propagate the update to the watchers. +struct grpc_tls_certificate_provider + : public RefCounted { + public: + grpc_tls_certificate_provider() + : interested_parties_(grpc_pollset_set_create()) {} + + virtual ~grpc_tls_certificate_provider() { + grpc_pollset_set_destroy(interested_parties_); + } + + grpc_pollset_set* interested_parties() const { return interested_parties_; } + + virtual RefCountedPtr distributor() + const = 0; + + private: + grpc_pollset_set* interested_parties_; +}; + +#endif // GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_H diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 181a480d955..e022da47a69 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -23,6 +23,6 @@ #include -const char* grpc_version_string(void) { return "11.0.0"; } +const char* grpc_version_string(void) { return "12.0.0"; } -const char* grpc_g_stands_for(void) { return "giggle"; } +const char* grpc_g_stands_for(void) { return "geeky"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index e37246bcfa0..479c4fa228f 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -std::string Version() { return "1.32.0-dev"; } +std::string Version() { return "1.33.0-dev"; } } // namespace grpc diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 69988329bd0..9e13f99b4d3 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -283,10 +283,6 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor { }; } // namespace -} // namespace grpc - -namespace grpc_impl { - /// Use private inheritance rather than composition only to establish order /// of construction, since the public base class should be constructed after the /// elements belonging to the private base class are constructed. This is not @@ -1358,4 +1354,4 @@ grpc::CompletionQueue* Server::CallbackCQ() { return callback_cq_; } -} // namespace grpc_impl +} // namespace grpc diff --git a/src/csharp/Grpc.Core.Api/VersionInfo.cs b/src/csharp/Grpc.Core.Api/VersionInfo.cs index 0c7416b0c6e..feaf39ccdf0 100644 --- a/src/csharp/Grpc.Core.Api/VersionInfo.cs +++ b/src/csharp/Grpc.Core.Api/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "2.32.0.0"; + public const string CurrentAssemblyFileVersion = "2.33.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "2.32.0-dev"; + public const string CurrentVersion = "2.33.0-dev"; } } diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index 5186d2f6dae..cb7cb089f72 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -27,10 +27,40 @@ namespace Math { { static readonly string __ServiceName = "math.Math"; - static readonly grpc::Marshaller __Marshaller_math_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivReply.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.FibArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_math_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.Num.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_math_DivArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.DivArgs.Parser)); + static readonly grpc::Marshaller __Marshaller_math_DivReply = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.DivReply.Parser)); + static readonly grpc::Marshaller __Marshaller_math_FibArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.FibArgs.Parser)); + static readonly grpc::Marshaller __Marshaller_math_Num = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Math.Num.Parser)); static readonly grpc::Method __Method_Div = new grpc::Method( grpc::MethodType.Unary, diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index d5051f3b05a..ffa666c5155 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -30,8 +30,38 @@ namespace Grpc.Health.V1 { { static readonly string __ServiceName = "grpc.health.v1.Health"; - static readonly grpc::Marshaller __Marshaller_grpc_health_v1_HealthCheckRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_health_v1_HealthCheckResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_health_v1_HealthCheckRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Health.V1.HealthCheckRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_health_v1_HealthCheckResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Health.V1.HealthCheckResponse.Parser)); static readonly grpc::Method __Method_Check = new grpc::Method( grpc::MethodType.Unary, diff --git a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs index 4a608be318c..7c65cda71b5 100644 --- a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs @@ -29,8 +29,38 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.BenchmarkService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.SimpleRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.SimpleResponse.Parser)); static readonly grpc::Method __Method_UnaryCall = new grpc::Method( grpc::MethodType.Unary, diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index fbc3690d2ac..0b364cdd783 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -33,9 +33,39 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.MetricsService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_EmptyMessage = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_GaugeResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_GaugeRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_EmptyMessage = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.EmptyMessage.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_GaugeResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.GaugeResponse.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_GaugeRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.GaugeRequest.Parser)); static readonly grpc::Method __Method_GetAllGauges = new grpc::Method( grpc::MethodType.ServerStreaming, diff --git a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs index e35c7c39fd5..98f03dbab3a 100644 --- a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs @@ -29,8 +29,38 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReportQpsScenarioService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_ScenarioResult = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ScenarioResult.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_ScenarioResult = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ScenarioResult.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_Void = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Void.Parser)); static readonly grpc::Method __Method_ReportScenario = new grpc::Method( grpc::MethodType.Unary, diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index ffa8388e3fb..168c0892bae 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -34,13 +34,43 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.TestService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingOutputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingOutputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallResponse.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingInputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingInputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallResponse.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Empty.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.SimpleRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_SimpleResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.SimpleResponse.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingOutputCallRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.StreamingOutputCallRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingOutputCallResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.StreamingOutputCallResponse.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingInputCallRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.StreamingInputCallRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_StreamingInputCallResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.StreamingInputCallResponse.Parser)); static readonly grpc::Method __Method_EmptyCall = new grpc::Method( grpc::MethodType.Unary, @@ -565,7 +595,37 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.UnimplementedService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Empty.Parser)); static readonly grpc::Method __Method_UnimplementedCall = new grpc::Method( grpc::MethodType.Unary, @@ -696,9 +756,39 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReconnectService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_ReconnectParams = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_ReconnectInfo = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_ReconnectParams = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ReconnectParams.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Empty.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_ReconnectInfo = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ReconnectInfo.Parser)); static readonly grpc::Method __Method_Start = new grpc::Method( grpc::MethodType.Unary, @@ -825,8 +915,38 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.LoadBalancerStatsService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_LoadBalancerStatsRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.LoadBalancerStatsRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_LoadBalancerStatsResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.LoadBalancerStatsResponse.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_LoadBalancerStatsRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.LoadBalancerStatsRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_LoadBalancerStatsResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.LoadBalancerStatsResponse.Parser)); static readonly grpc::Method __Method_GetClientStats = new grpc::Method( grpc::MethodType.Unary, @@ -957,7 +1077,37 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.XdsUpdateHealthService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Empty.Parser)); static readonly grpc::Method __Method_SetServing = new grpc::Method( grpc::MethodType.Unary, diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs index 66378081626..31bab7ca424 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs @@ -29,13 +29,43 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.WorkerService"; - static readonly grpc::Marshaller __Marshaller_grpc_testing_ServerArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_ServerStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_ClientArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_ClientStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_CoreRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_CoreResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_testing_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_testing_ServerArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ServerArgs.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_ServerStatus = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ServerStatus.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_ClientArgs = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ClientArgs.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_ClientStatus = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.ClientStatus.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_CoreRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.CoreRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_CoreResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.CoreResponse.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_testing_Void = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Testing.Void.Parser)); static readonly grpc::Method __Method_RunServer = new grpc::Method( grpc::MethodType.DuplexStreaming, diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs index fa482eba494..d5822be354c 100644 --- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -29,8 +29,38 @@ namespace Grpc.Reflection.V1Alpha { { static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; - static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); - static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser)); + static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser)); static readonly grpc::Method __Method_ServerReflectionInfo = new grpc::Method( grpc::MethodType.DuplexStreaming, diff --git a/src/csharp/build/dependencies.props b/src/csharp/build/dependencies.props index 5e6658b29b7..9fcb122009e 100644 --- a/src/csharp/build/dependencies.props +++ b/src/csharp/build/dependencies.props @@ -1,7 +1,7 @@ - 2.32.0-dev + 2.33.0-dev 3.13.0 diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat index 8915ebdf8fc..1568b6d2789 100644 --- a/src/csharp/build_unitypackage.bat +++ b/src/csharp/build_unitypackage.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=2.32.0-dev +set VERSION=2.33.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index b00ae58875e..71c71503033 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.32.0-dev' + v = '1.33.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 48d2f7abd35..bdb3a66de1e 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.32.0-dev' + v = '1.33.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/version.h index acf091a3c51..d9e73d2eb4b 100644 --- a/src/objective-c/GRPCClient/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.32.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.33.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index b16c890372d..902692831b3 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.32.0-dev" -#define GRPC_C_VERSION_STRING @"11.0.0" +#define GRPC_OBJC_VERSION_STRING @"1.33.0-dev" +#define GRPC_C_VERSION_STRING @"12.0.0" diff --git a/src/php/composer.json b/src/php/composer.json index d69036895ef..df51d7aac20 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Development use only", "license": "Apache-2.0", - "version": "1.32.0", + "version": "1.33.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 777b3f0f9d4..55111a5ad0b 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.32.0dev" +#define PHP_GRPC_VERSION "1.33.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 4f2c71a51b5..fe2b7f5879d 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.32.0.dev0""" +__version__ = """1.33.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 55270b0f447..036c15b0ecb 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py index afc27a8bfff..85bece3c009 100644 --- a/src/python/grpcio_channelz/grpc_version.py +++ b/src/python/grpcio_channelz/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 90b465cdf25..815fff2a3f8 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index cf587708391..2dd4b7403e0 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py index b75a7215c76..03ef182a288 100644 --- a/src/python/grpcio_status/grpc_version.py +++ b/src/python/grpcio_status/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 2068e2b5a1b..c74f56c17cf 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index fbff270f918..82e01e25915 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/src/python/grpcio_tests/tests/unit/_exit_test.py b/src/python/grpcio_tests/tests/unit/_exit_test.py index da1658db812..146d30162ea 100644 --- a/src/python/grpcio_tests/tests/unit/_exit_test.py +++ b/src/python/grpcio_tests/tests/unit/_exit_test.py @@ -24,6 +24,7 @@ import six import subprocess import sys import threading +import datetime import time import unittest import logging @@ -37,7 +38,9 @@ INTERPRETER = sys.executable BASE_COMMAND = [INTERPRETER, SCENARIO_FILE] BASE_SIGTERM_COMMAND = BASE_COMMAND + ['--wait_for_interrupt'] -INIT_TIME = 1.0 +INIT_TIME = datetime.timedelta(seconds=1) +WAIT_CHECK_INTERVAL = datetime.timedelta(milliseconds=100) +WAIT_CHECK_DEFAULT_TIMEOUT = datetime.timedelta(seconds=5) processes = [] process_lock = threading.Lock() @@ -57,18 +60,27 @@ def cleanup_processes(): atexit.register(cleanup_processes) +def _process_wait_with_timeout(process, timeout=WAIT_CHECK_DEFAULT_TIMEOUT): + """A funciton to mimic 3.3+ only timeout argument in process.wait.""" + deadline = datetime.datetime.now() + timeout + while (process.poll() is None) and (datetime.datetime.now() < deadline): + time.sleep(WAIT_CHECK_INTERVAL.total_seconds()) + if process.returncode is None: + raise RuntimeError('Process failed to exit within %s' % timeout) + + def interrupt_and_wait(process): with process_lock: processes.append(process) - time.sleep(INIT_TIME) + time.sleep(INIT_TIME.total_seconds()) os.kill(process.pid, signal.SIGINT) - process.wait() + _process_wait_with_timeout(process) def wait(process): with process_lock: processes.append(process) - process.wait() + _process_wait_with_timeout(process) class ExitTest(unittest.TestCase): @@ -138,7 +150,6 @@ class ExitTest(unittest.TestCase): stderr=sys.stderr) interrupt_and_wait(process) - @unittest.skipIf(six.PY2, 'https://github.com/grpc/grpc/issues/6999') @unittest.skipIf(os.name == 'nt', 'os.kill does not have required permission on Windows') def test_in_flight_unary_stream_call(self): @@ -157,7 +168,7 @@ class ExitTest(unittest.TestCase): stderr=sys.stderr) interrupt_and_wait(process) - @unittest.skipIf(six.PY2, 'https://github.com/grpc/grpc/issues/6999') + @unittest.skip('https://github.com/grpc/grpc/issues/23982') @unittest.skipIf(os.name == 'nt', 'os.kill does not have required permission on Windows') def test_in_flight_stream_stream_call(self): @@ -167,7 +178,6 @@ class ExitTest(unittest.TestCase): stderr=sys.stderr) interrupt_and_wait(process) - @unittest.skipIf(six.PY2, 'https://github.com/grpc/grpc/issues/6999') @unittest.skipIf(os.name == 'nt', 'os.kill does not have required permission on Windows') def test_in_flight_partial_unary_stream_call(self): @@ -188,7 +198,7 @@ class ExitTest(unittest.TestCase): stderr=sys.stderr) interrupt_and_wait(process) - @unittest.skipIf(six.PY2, 'https://github.com/grpc/grpc/issues/6999') + @unittest.skip('https://github.com/grpc/grpc/issues/23982') @unittest.skipIf(os.name == 'nt', 'os.kill does not have required permission on Windows') def test_in_flight_partial_stream_stream_call(self): @@ -201,5 +211,5 @@ class ExitTest(unittest.TestCase): if __name__ == '__main__': - logging.basicConfig() + logging.basicConfig(level=logging.DEBUG) unittest.main(verbosity=2) diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 3e81b021c3b..daabad9e9a4 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.32.0.dev' + VERSION = '1.33.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 778eeacb68a..c21abf825e6 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.32.0.dev' + VERSION = '1.33.0.dev' end end diff --git a/test/core/security/evaluate_args_test.cc b/test/core/security/evaluate_args_test.cc index 394344dd60e..ff696c390af 100644 --- a/test/core/security/evaluate_args_test.cc +++ b/test/core/security/evaluate_args_test.cc @@ -14,7 +14,9 @@ #include +#include #include + #include "absl/strings/string_view.h" #include "src/core/lib/security/authorization/evaluate_args.h" @@ -45,27 +47,172 @@ class EvaluateArgsTest : public ::testing::Test { TEST_F(EvaluateArgsTest, TestEvaluateArgsLocalAddress) { absl::string_view src_address = evaluate_args_->GetLocalAddress(); - EXPECT_EQ(src_address, local_address_) - << "Error: Failed to extract correct Local address from EvaluateArgs."; + EXPECT_EQ(src_address, local_address_); } TEST_F(EvaluateArgsTest, TestEvaluateArgsLocalPort) { int src_port = evaluate_args_->GetLocalPort(); - EXPECT_EQ(src_port, local_port_) - << "Error: Failed to extract correct Local port from EvaluateArgs."; + EXPECT_EQ(src_port, local_port_); } TEST_F(EvaluateArgsTest, TestEvaluateArgsPeerAddress) { absl::string_view dest_address = evaluate_args_->GetPeerAddress(); - EXPECT_EQ(dest_address, peer_address_) - << "Error: Failed to extract correct Peer address from " - "EvaluateArgs. "; + EXPECT_EQ(dest_address, peer_address_); } TEST_F(EvaluateArgsTest, TestEvaluateArgsPeerPort) { int dest_port = evaluate_args_->GetPeerPort(); - EXPECT_EQ(dest_port, peer_port_) - << "Error: Failed to extract correct Peer port from EvaluateArgs."; + EXPECT_EQ(dest_port, peer_port_); +} + +TEST(EvaluateArgsMetadataTest, HandlesNullMetadata) { + EvaluateArgs eval_args(nullptr, nullptr, nullptr); + EXPECT_EQ(eval_args.GetPath(), nullptr); + EXPECT_EQ(eval_args.GetMethod(), nullptr); + EXPECT_EQ(eval_args.GetHost(), nullptr); + EXPECT_THAT(eval_args.GetHeaders(), ::testing::ElementsAre()); +} + +TEST(EvaluateArgsMetadataTest, HandlesEmptyMetadata) { + grpc_metadata_batch metadata; + grpc_metadata_batch_init(&metadata); + EvaluateArgs eval_args(&metadata, nullptr, nullptr); + EXPECT_EQ(eval_args.GetPath(), nullptr); + EXPECT_EQ(eval_args.GetMethod(), nullptr); + EXPECT_EQ(eval_args.GetHost(), nullptr); + EXPECT_THAT(eval_args.GetHeaders(), ::testing::ElementsAre()); + grpc_metadata_batch_destroy(&metadata); +} + +TEST(EvaluateArgsMetadataTest, GetPathSuccess) { + grpc_init(); + const char* kPath = "/some/path"; + grpc_metadata_batch metadata; + grpc_metadata_batch_init(&metadata); + grpc_slice fake_val = grpc_slice_intern(grpc_slice_from_static_string(kPath)); + grpc_mdelem fake_val_md = grpc_mdelem_from_slices(GRPC_MDSTR_PATH, fake_val); + grpc_linked_mdelem storage; + storage.md = fake_val_md; + ASSERT_EQ(grpc_metadata_batch_link_head(&metadata, &storage), + GRPC_ERROR_NONE); + EvaluateArgs eval_args(&metadata, nullptr, nullptr); + EXPECT_EQ(eval_args.GetPath(), kPath); + grpc_metadata_batch_destroy(&metadata); + grpc_shutdown(); +} + +TEST(EvaluateArgsMetadataTest, GetHostSuccess) { + grpc_init(); + const char* kHost = "host"; + grpc_metadata_batch metadata; + grpc_metadata_batch_init(&metadata); + grpc_slice fake_val = grpc_slice_intern(grpc_slice_from_static_string(kHost)); + grpc_mdelem fake_val_md = grpc_mdelem_from_slices(GRPC_MDSTR_HOST, fake_val); + grpc_linked_mdelem storage; + storage.md = fake_val_md; + ASSERT_EQ(grpc_metadata_batch_link_head(&metadata, &storage), + GRPC_ERROR_NONE); + EvaluateArgs eval_args(&metadata, nullptr, nullptr); + EXPECT_EQ(eval_args.GetHost(), kHost); + grpc_metadata_batch_destroy(&metadata); + grpc_shutdown(); +} + +TEST(EvaluateArgsMetadataTest, GetMethodSuccess) { + grpc_init(); + const char* kMethod = "GET"; + grpc_metadata_batch metadata; + grpc_metadata_batch_init(&metadata); + grpc_slice fake_val = + grpc_slice_intern(grpc_slice_from_static_string(kMethod)); + grpc_mdelem fake_val_md = + grpc_mdelem_from_slices(GRPC_MDSTR_METHOD, fake_val); + grpc_linked_mdelem storage; + storage.md = fake_val_md; + ASSERT_EQ(grpc_metadata_batch_link_head(&metadata, &storage), + GRPC_ERROR_NONE); + EvaluateArgs eval_args(&metadata, nullptr, nullptr); + EXPECT_EQ(eval_args.GetMethod(), kMethod); + grpc_metadata_batch_destroy(&metadata); + grpc_shutdown(); +} + +TEST(EvaluateArgsMetadataTest, GetHeadersSuccess) { + grpc_init(); + const char* kPath = "/some/path"; + const char* kHost = "host"; + grpc_metadata_batch metadata; + grpc_metadata_batch_init(&metadata); + grpc_slice fake_path = + grpc_slice_intern(grpc_slice_from_static_string(kPath)); + grpc_mdelem fake_path_md = + grpc_mdelem_from_slices(GRPC_MDSTR_PATH, fake_path); + grpc_linked_mdelem storage; + storage.md = fake_path_md; + ASSERT_EQ(grpc_metadata_batch_link_head(&metadata, &storage, GRPC_BATCH_PATH), + GRPC_ERROR_NONE); + grpc_slice fake_host = + grpc_slice_intern(grpc_slice_from_static_string(kHost)); + grpc_mdelem fake_host_md = + grpc_mdelem_from_slices(GRPC_MDSTR_HOST, fake_host); + grpc_linked_mdelem storage2; + storage2.md = fake_host_md; + ASSERT_EQ( + grpc_metadata_batch_link_tail(&metadata, &storage2, GRPC_BATCH_HOST), + GRPC_ERROR_NONE); + EvaluateArgs eval_args(&metadata, nullptr, nullptr); + EXPECT_THAT( + eval_args.GetHeaders(), + ::testing::UnorderedElementsAre( + ::testing::Pair(StringViewFromSlice(GRPC_MDSTR_HOST), kHost), + ::testing::Pair(StringViewFromSlice(GRPC_MDSTR_PATH), kPath))); + grpc_metadata_batch_destroy(&metadata); + grpc_shutdown(); +} + +TEST(EvaluateArgsAuthContextTest, HandlesNullAuthContext) { + EvaluateArgs eval_args(nullptr, nullptr, nullptr); + EXPECT_EQ(eval_args.GetSpiffeId(), nullptr); + EXPECT_EQ(eval_args.GetCertServerName(), nullptr); +} + +TEST(EvaluateArgsAuthContextTest, HandlesEmptyAuthCtx) { + grpc_auth_context auth_context(nullptr); + EvaluateArgs eval_args(nullptr, &auth_context, nullptr); + EXPECT_EQ(eval_args.GetSpiffeId(), nullptr); + EXPECT_EQ(eval_args.GetCertServerName(), nullptr); +} + +TEST(EvaluateArgsAuthContextTest, GetSpiffeIdSuccessOneProperty) { + grpc_auth_context auth_context(nullptr); + const char* kId = "spiffeid"; + auth_context.add_cstring_property(GRPC_PEER_SPIFFE_ID_PROPERTY_NAME, kId); + EvaluateArgs eval_args(nullptr, &auth_context, nullptr); + EXPECT_EQ(eval_args.GetSpiffeId(), kId); +} + +TEST(EvaluateArgsAuthContextTest, GetSpiffeIdFailDuplicateProperty) { + grpc_auth_context auth_context(nullptr); + auth_context.add_cstring_property(GRPC_PEER_SPIFFE_ID_PROPERTY_NAME, "id1"); + auth_context.add_cstring_property(GRPC_PEER_SPIFFE_ID_PROPERTY_NAME, "id2"); + EvaluateArgs eval_args(nullptr, &auth_context, nullptr); + EXPECT_EQ(eval_args.GetSpiffeId(), nullptr); +} + +TEST(EvaluateArgsAuthContextTest, GetCertServerNameSuccessOneProperty) { + grpc_auth_context auth_context(nullptr); + const char* kServer = "server"; + auth_context.add_cstring_property(GRPC_X509_CN_PROPERTY_NAME, kServer); + EvaluateArgs eval_args(nullptr, &auth_context, nullptr); + EXPECT_EQ(eval_args.GetCertServerName(), kServer); +} + +TEST(EvaluateArgsAuthContextTest, GetCertServerNameFailDuplicateProperty) { + grpc_auth_context auth_context(nullptr); + auth_context.add_cstring_property(GRPC_X509_CN_PROPERTY_NAME, "server1"); + auth_context.add_cstring_property(GRPC_X509_CN_PROPERTY_NAME, "server2"); + EvaluateArgs eval_args(nullptr, &auth_context, nullptr); + EXPECT_EQ(eval_args.GetCertServerName(), nullptr); } } // namespace grpc_core diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index b2099f12806..b3303c62771 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -2500,7 +2500,7 @@ TEST_P(LdsRdsTest, ListenerRemoved) { AdsServiceImpl::ResponseState::ACKED); } -// Tests that LDS client should send a NACK if matching domain can't be found in +// Tests that LDS client ACKs but fails if matching domain can't be found in // the LDS response. TEST_P(LdsRdsTest, NoMatchedDomain) { RouteConfiguration route_config = @@ -2511,10 +2511,10 @@ TEST_P(LdsRdsTest, NoMatchedDomain) { SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); CheckRpcSendFailure(); + // Do a bit of polling, to allow the ACK to get to the ADS server. + channel_->WaitForConnected(grpc_timeout_milliseconds_to_deadline(100)); const auto& response_state = RouteConfigurationResponseState(0); - EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::NACKED); - EXPECT_EQ(response_state.error_message, - "No matched virtual host found in the route config."); + EXPECT_EQ(response_state.state, AdsServiceImpl::ResponseState::ACKED); } // Tests that LDS client should choose the virtual host with matching domain if @@ -2525,10 +2525,6 @@ TEST_P(LdsRdsTest, ChooseMatchedDomain) { *(route_config.add_virtual_hosts()) = route_config.virtual_hosts(0); route_config.mutable_virtual_hosts(0)->clear_domains(); route_config.mutable_virtual_hosts(0)->add_domains("unmatched_domain"); - route_config.mutable_virtual_hosts(0) - ->mutable_routes(0) - ->mutable_route() - ->mutable_cluster_header(); SetRouteConfiguration(0, route_config); SetNextResolution({}); SetNextResolutionForLbChannelAllBalancers(); diff --git a/test/distrib/csharp/DistribTest/DistribTest.csproj b/test/distrib/csharp/DistribTest/DistribTest.csproj index e65c1f8070c..f11f5c1e163 100644 --- a/test/distrib/csharp/DistribTest/DistribTest.csproj +++ b/test/distrib/csharp/DistribTest/DistribTest.csproj @@ -56,6 +56,16 @@ true 4 + + + $(DefineConstants);GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + + true + ..\packages\Grpc.Auth.__GRPC_NUGET_VERSION__\lib\net45\Grpc.Auth.dll @@ -101,7 +111,7 @@ ..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll - ..\packages\Google.Protobuf.3.12.2\lib\net45\Google.Protobuf.dll + ..\packages\Google.Protobuf.3.13.0\lib\net45\Google.Protobuf.dll diff --git a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj index 75c7973046f..5b14fff4444 100644 --- a/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj +++ b/test/distrib/csharp/DistribTest/DistribTestDotNet.csproj @@ -16,7 +16,7 @@ - + diff --git a/test/distrib/csharp/DistribTest/packages.config b/test/distrib/csharp/DistribTest/packages.config index 07033764495..b0a9cd55c1b 100644 --- a/test/distrib/csharp/DistribTest/packages.config +++ b/test/distrib/csharp/DistribTest/packages.config @@ -8,7 +8,7 @@ - + diff --git a/tools/distrib/python/grpc_version.py b/tools/distrib/python/grpc_version.py index 3f85118019d..fec9dadecf4 100644 --- a/tools/distrib/python/grpc_version.py +++ b/tools/distrib/python/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 0b7c753bdfd..54a1dd53902 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.32.0.dev0' +VERSION = '1.33.0.dev0' diff --git a/tools/dockerfile/distribtest/python_dev_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/python_dev_centos7_x64/Dockerfile index 954146c5e91..18e3c7b05c6 100644 --- a/tools/dockerfile/distribtest/python_dev_centos7_x64/Dockerfile +++ b/tools/dockerfile/distribtest/python_dev_centos7_x64/Dockerfile @@ -15,8 +15,25 @@ FROM centos:7 RUN yum install -y python +RUN yum install -y python-devel RUN yum install -y epel-release RUN yum install -y python-pip -RUN pip install virtualenv -RUN yum groupinstall -y 'Development Tools' -RUN yum install -y python-devel +RUN pip install --upgrade pip +RUN pip install -U virtualenv + +# The default gcc of CentOS 7 is gcc 4.8 which is older than gcc 4.9, +# the minimum supported gcc version for gRPC Core so let's upgrade to +# the oldest one that can build gRPC on Centos 7. +RUN yum install -y centos-release-scl +RUN yum install -y devtoolset-8-binutils devtoolset-8-gcc devtoolset-8-gcc-c++ + +# Activate devtoolset-8 by default +# https://austindewey.com/2019/03/26/enabling-software-collections-binaries-on-a-docker-image/ +RUN echo $'#!/bin/bash\n\ +source scl_source enable devtoolset-8\n\ +"$@"\n' > /usr/bin/entrypoint.sh +RUN chmod +x /usr/bin/entrypoint.sh +RUN cat /usr/bin/entrypoint.sh +ENTRYPOINT [ "/usr/bin/entrypoint.sh" ] + +CMD ["/bin/bash"] diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 1a09e6929ea..8c6cbb0e2a4 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.32.0-dev +PROJECT_NUMBER = 1.33.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1023,7 +1023,6 @@ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_context.h \ -include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream_impl.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 99454333951..b51cb751cb6 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.32.0-dev +PROJECT_NUMBER = 1.33.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1023,7 +1023,6 @@ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ include/grpcpp/server_context.h \ -include/grpcpp/server_impl.h \ include/grpcpp/server_posix.h \ include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream_impl.h \ @@ -1714,7 +1713,13 @@ src/core/lib/security/authorization/authorization_engine.h \ src/core/lib/security/authorization/evaluate_args.cc \ src/core/lib/security/authorization/evaluate_args.h \ src/core/lib/security/authorization/mock_cel/activation.h \ +src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h \ +src/core/lib/security/authorization/mock_cel/cel_expression.h \ src/core/lib/security/authorization/mock_cel/cel_value.h \ +src/core/lib/security/authorization/mock_cel/evaluator_core.h \ +src/core/lib/security/authorization/mock_cel/flat_expr_builder.h \ +src/core/lib/security/authorization/mock_cel/statusor.h \ +src/core/lib/security/certificate_provider.h \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/context/security_context.h \ src/core/lib/security/credentials/alts/alts_credentials.cc \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 8da50b0c21b..dc51def7ed2 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 11.0.0 +PROJECT_NUMBER = 12.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index f4afb777a81..c30a42258e0 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 11.0.0 +PROJECT_NUMBER = 12.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1542,7 +1542,13 @@ src/core/lib/security/authorization/authorization_engine.h \ src/core/lib/security/authorization/evaluate_args.cc \ src/core/lib/security/authorization/evaluate_args.h \ src/core/lib/security/authorization/mock_cel/activation.h \ +src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h \ +src/core/lib/security/authorization/mock_cel/cel_expression.h \ src/core/lib/security/authorization/mock_cel/cel_value.h \ +src/core/lib/security/authorization/mock_cel/evaluator_core.h \ +src/core/lib/security/authorization/mock_cel/flat_expr_builder.h \ +src/core/lib/security/authorization/mock_cel/statusor.h \ +src/core/lib/security/certificate_provider.h \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/context/security_context.h \ src/core/lib/security/credentials/alts/alts_credentials.cc \ diff --git a/tools/doxygen/Doxyfile.objc b/tools/doxygen/Doxyfile.objc index 5ae4647fd22..5bcec39f1d8 100644 --- a/tools/doxygen/Doxyfile.objc +++ b/tools/doxygen/Doxyfile.objc @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Objective-C" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.32.0-dev +PROJECT_NUMBER = 1.33.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.objc.internal b/tools/doxygen/Doxyfile.objc.internal index 636c73f0660..1c8424a48b0 100644 --- a/tools/doxygen/Doxyfile.objc.internal +++ b/tools/doxygen/Doxyfile.objc.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Objective-C" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.32.0-dev +PROJECT_NUMBER = 1.33.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.php b/tools/doxygen/Doxyfile.php index c1025e5cf55..097f40fb947 100644 --- a/tools/doxygen/Doxyfile.php +++ b/tools/doxygen/Doxyfile.php @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC PHP" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.32.0-dev +PROJECT_NUMBER = 1.33.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index e68a89acc04..e7bc43946c9 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -88,7 +88,7 @@ if [ "${PREPARE_BUILD_INSTALL_DEPS_PYTHON}" == "true" ] then # python time pip install --user virtualenv - time pip install --user --upgrade Mako six tox setuptools twisted pyyaml pyjwt cryptography requests + time pip install --user --upgrade Mako six tox setuptools==44.1.1 twisted pyyaml pyjwt cryptography requests export PYTHONPATH=/Library/Python/3.4/site-packages # make sure md5sum is available (requires coreutils 8.31+) diff --git a/tools/internal_ci/linux/grpc_android.sh b/tools/internal_ci/linux/grpc_android.sh index 209b30d1ad7..87c7a24dd7f 100755 --- a/tools/internal_ci/linux/grpc_android.sh +++ b/tools/internal_ci/linux/grpc_android.sh @@ -15,6 +15,13 @@ set -ex +# Install packages which were not preinstalled yet. +# Protobuf needs autoconf & automake to build +sudo apt-get install -y autoconf automake + +# Accept the Android SDK licences. +yes | /opt/android-sdk/current/tools/bin/sdkmanager --licenses + # change to grpc repo root cd $(dirname $0)/../../.. diff --git a/tools/internal_ci/linux/grpc_xds_csharp.cfg b/tools/internal_ci/linux/grpc_xds_csharp.cfg index 579cd47277c..1f6ab280ad0 100644 --- a/tools/internal_ci/linux/grpc_xds_csharp.cfg +++ b/tools/internal_ci/linux/grpc_xds_csharp.cfg @@ -16,7 +16,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/linux/grpc_xds_csharp.sh" -timeout_mins: 90 +timeout_mins: 120 action { define_artifacts { regex: "**/*sponge_log.*" diff --git a/tools/internal_ci/linux/grpc_xds_python.cfg b/tools/internal_ci/linux/grpc_xds_python.cfg index 922b1aa88a1..8eea6fe3831 100644 --- a/tools/internal_ci/linux/grpc_xds_python.cfg +++ b/tools/internal_ci/linux/grpc_xds_python.cfg @@ -16,7 +16,7 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/linux/grpc_xds.sh" -timeout_mins: 90 +timeout_mins: 120 env_vars { key: "BAZEL_SCRIPT" value: "tools/internal_ci/linux/grpc_xds_bazel_python_test_in_docker.sh" diff --git a/tools/internal_ci/macos/grpc_build_artifacts.sh b/tools/internal_ci/macos/grpc_build_artifacts.sh index 10fe02a1215..878d30dc12b 100755 --- a/tools/internal_ci/macos/grpc_build_artifacts.sh +++ b/tools/internal_ci/macos/grpc_build_artifacts.sh @@ -24,11 +24,11 @@ export PREPARE_BUILD_INSTALL_DEPS_RUBY=true source tools/internal_ci/helper_scripts/prepare_build_macos_rc # install cython for all python versions -python2.7 -m pip install -U cython setuptools wheel --user -python3.5 -m pip install -U cython setuptools wheel --user -python3.6 -m pip install -U cython setuptools wheel --user -python3.7 -m pip install -U cython setuptools wheel --user -python3.8 -m pip install -U cython setuptools wheel --user +python2.7 -m pip install -U cython setuptools==44.1.1 wheel --user +python3.5 -m pip install -U cython setuptools==44.1.1 wheel --user +python3.6 -m pip install -U cython setuptools==44.1.1 wheel --user +python3.7 -m pip install -U cython setuptools==44.1.1 wheel --user +python3.8 -m pip install -U cython setuptools==44.1.1 wheel --user # needed to build ruby artifacts time bash tools/distrib/build_ruby_environment_macos.sh diff --git a/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh index d4d3535d8c7..78ea9b6facb 100644 --- a/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh +++ b/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh @@ -24,6 +24,12 @@ cd $(dirname $0)/../../.. # The "local" execution strategy is required because the test runs sudo and that doesn't work in a sandboxed environment (the default on mac) tools/bazel test $RUN_TESTS_FLAGS --spawn_strategy=local --genrule_strategy=local --test_output=all --copt="-DGRPC_CFSTREAM=1" //test/cpp/end2end:cfstream_test +# Missing the /var/db/ntp-kod file may breaks the ntp synchronization. +# Create the file and change the ownership to root before NTP sync. +# TODO(yulin-liang): investigate how to run time_jump_test without needing to mess with the system time directly. +# See b/166245303 +sudo touch /var/db/ntp-kod +sudo chown root:wheel /var/db/ntp-kod # Make sure time is in sync before running time_jump_test because the test does # NTP sync before exiting. Bazel gets confused if test end time < start time. sudo sntp -sS pool.ntp.org diff --git a/tools/run_tests/artifacts/build_artifact_python.bat b/tools/run_tests/artifacts/build_artifact_python.bat index 82d7a48fde6..ff5a6af6fcd 100644 --- a/tools/run_tests/artifacts/build_artifact_python.bat +++ b/tools/run_tests/artifacts/build_artifact_python.bat @@ -17,7 +17,7 @@ set PATH=C:\%1;C:\%1\scripts;C:\msys64\mingw%2\bin;C:\tools\msys64\mingw%2\bin;% python -m pip install --upgrade six @rem some artifacts are broken for setuptools 38.5.0. See https://github.com/grpc/grpc/issues/14317 -python -m pip install --upgrade setuptools==38.2.4 +python -m pip install --upgrade setuptools==44.1.1 python -m pip install --upgrade cython python -m pip install -rrequirements.txt --user diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py index 816729e3e8a..2684cda8c4d 100644 --- a/tools/run_tests/artifacts/distribtest_targets.py +++ b/tools/run_tests/artifacts/distribtest_targets.py @@ -235,7 +235,9 @@ class PHPDistribTest(object): self.platform = platform self.arch = arch self.docker_suffix = docker_suffix - self.labels = ['distribtest', 'php', platform, arch, docker_suffix] + self.labels = ['distribtest', 'php', platform, arch] + if docker_suffix: + self.labels.append(docker_suffix) def pre_build_jobspecs(self): return [] @@ -275,8 +277,14 @@ class CppDistribTest(object): self.docker_suffix = docker_suffix self.testcase = testcase self.labels = [ - 'distribtest', 'cpp', platform, arch, docker_suffix, testcase + 'distribtest', + 'cpp', + platform, + arch, + testcase, ] + if docker_suffix: + self.labels.append(docker_suffix) def pre_build_jobspecs(self): return [] diff --git a/tools/run_tests/helper_scripts/build_python.sh b/tools/run_tests/helper_scripts/build_python.sh index 60031fa6e95..a9a186c52bd 100755 --- a/tools/run_tests/helper_scripts/build_python.sh +++ b/tools/run_tests/helper_scripts/build_python.sh @@ -184,8 +184,9 @@ case "$VENV" in ;; esac + +pip_install --upgrade setuptools==44.1.1 pip_install --upgrade pip==19.3.1 -pip_install --upgrade setuptools pip_install --upgrade cython pip_install --upgrade six enum34 protobuf diff --git a/tools/run_tests/run_xds_tests.py b/tools/run_tests/run_xds_tests.py index 285658308f1..9d2d8527b28 100755 --- a/tools/run_tests/run_xds_tests.py +++ b/tools/run_tests/run_xds_tests.py @@ -226,7 +226,7 @@ _WAIT_FOR_BACKEND_SEC = args.wait_for_backend_sec _WAIT_FOR_OPERATION_SEC = 1200 _INSTANCE_GROUP_SIZE = args.instance_group_size _NUM_TEST_RPCS = 10 * args.qps -_WAIT_FOR_STATS_SEC = 180 +_WAIT_FOR_STATS_SEC = 360 _WAIT_FOR_VALID_CONFIG_SEC = 60 _WAIT_FOR_URL_MAP_PATCH_SEC = 300 _CONNECTION_TIMEOUT_SEC = 60 diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py index 934c4089715..a551c801dfd 100755 --- a/tools/run_tests/sanity/core_banned_functions.py +++ b/tools/run_tests/sanity/core_banned_functions.py @@ -43,7 +43,7 @@ BANNED_EXCEPT = { 'grpc_wsa_error(': ['src/core/lib/iomgr/error.cc'], 'grpc_log_if_error(': ['src/core/lib/iomgr/error.cc'], 'grpc_slice_malloc(': ['src/core/lib/slice/slice.cc'], - 'grpc_call_cancel_internal(': ['src/core/lib/surface/call.cc'], + 'grpc_call_cancel(': ['src/core/lib/surface/call.cc'], 'grpc_closure_create(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_init(': ['src/core/lib/iomgr/closure.cc'], 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.cc'], diff --git a/tools/run_tests/task_runner.py b/tools/run_tests/task_runner.py index 067e11a861f..ab180046cb9 100755 --- a/tools/run_tests/task_runner.py +++ b/tools/run_tests/task_runner.py @@ -49,7 +49,7 @@ def _create_build_map(): if set(target_build_map.keys()).intersection(label_build_map.keys()): raise Exception('Target names need to be distinct from label names') - return dict(target_build_map.items() + label_build_map.items()) + return dict(list(target_build_map.items()) + list(label_build_map.items())) _BUILD_MAP = _create_build_map() @@ -83,7 +83,7 @@ for label in args.build: # Among targets selected by -b, filter out those that don't match the filter targets = [t for t in targets if all(f in t.labels for f in args.filter)] -targets = sorted(set(targets)) +targets = sorted(set(targets), key=lambda target: target.name) # Execute pre-build phase prebuild_jobs = []