From b7a83305e6e2f6de7366de1e933236ec10260b05 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 17 Mar 2023 16:56:45 -0700 Subject: [PATCH] [config] Move global config alongside core configuration (#30788) This is a big rewrite of global config. It does a few things, all somewhat intertwined: 1. centralize the list of configuration we have to a yaml file that can be parsed, and code generated from it 2. add an initialization and a reset stage so that config vars can be centrally accessed very quickly without the need for caching them 3. makes the syntax more C++ like (less macros!) 4. (optionally) adds absl flags to the OSS build This first round of changes is intended to keep the system where it is without major changes. We pick up absl flags to match internal code and remove one point of deviation - but importantly continue to read from the environment variables. In doing so we don't force absl flags on our customers - it's possible to configure grpc without the flags - but instead allow users that do use absl flags to configure grpc using that mechanism. Importantly this lets internal customers configure grpc the same everywhere. Future changes along this path will be two-fold: 1. Move documentation generation into the code generation step, so that within the source of truth yaml file we can find all documentation and data about a configuration knob - eliminating the chance of forgetting to document something in all the right places. 2. Provide fuzzing over configurations. Currently most config variables get stashed in static constants across the codebase. To fuzz over these we'd need a way to reset those cached values between fuzzing rounds, something that is terrifically difficult right now, but with these changes should simply be a reset on `ConfigVars`. --------- Co-authored-by: ctiller --- BUILD | 56 +++- CMakeLists.txt | 120 ++------ Makefile | 17 +- build_autogenerated.yaml | 53 +--- config.m4 | 18 +- config.w32 | 17 +- gRPC-C++.podspec | 18 +- gRPC-Core.podspec | 24 +- grpc.gemspec | 38 ++- grpc.gyp | 10 +- package.xml | 38 ++- .../interop/app/src/main/cpp/grpc-interop.cc | 4 +- src/core/BUILD | 16 +- .../filters/client_channel/backup_poller.cc | 13 +- .../filters/client_channel/backup_poller.h | 3 - .../resolver/dns/c_ares/dns_resolver_ares.cc | 20 +- .../resolver/dns/dns_resolver_selection.cc | 30 -- .../resolver/dns/dns_resolver_selection.h | 29 -- .../resolver/dns/native/dns_resolver.cc | 10 +- src/core/lib/config/config_vars.cc | 137 +++++++++ src/core/lib/config/config_vars.h | 129 +++++++++ src/core/lib/config/config_vars.yaml | 102 +++++++ .../lib/config/config_vars_non_generated.cc | 51 ++++ src/core/lib/config/load_config.cc | 70 +++++ src/core/lib/config/load_config.h | 46 +++ src/core/lib/debug/trace.cc | 11 +- src/core/lib/debug/trace.h | 5 - .../posix_engine/ev_poll_posix.cc | 4 - .../event_poller_posix_default.cc | 12 +- src/core/lib/experiments/config.cc | 13 +- src/core/lib/gpr/log.cc | 43 +-- src/core/lib/gprpp/fork.cc | 14 +- src/core/lib/gprpp/global_config.h | 93 ------ src/core/lib/gprpp/global_config_custom.h | 29 -- src/core/lib/gprpp/global_config_env.cc | 140 --------- src/core/lib/gprpp/global_config_env.h | 133 --------- src/core/lib/gprpp/global_config_generic.h | 40 --- src/core/lib/iomgr/ev_posix.cc | 66 +---- src/core/lib/iomgr/ev_posix.h | 3 - src/core/lib/iomgr/iomgr.cc | 12 +- src/core/lib/iomgr/tcp_posix.cc | 1 - .../load_system_roots_supported.cc | 16 +- .../security/security_connector/ssl_utils.cc | 36 +-- .../security_connector/ssl_utils_config.cc | 32 --- .../security_connector/ssl_utils_config.h | 29 -- .../frame_protector/alts_frame_protector.cc | 1 + .../CronetTests/CoreCronetEnd2EndTests.mm | 2 +- .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 5 + .../grpc/_cython/_cygrpc/records.pyx.pxi | 4 + src/python/grpcio/grpc_core_dependencies.py | 15 +- .../tests_py3_only/unit/_simple_stubs_test.py | 1 + test/core/bad_ssl/bad_ssl_test.cc | 5 +- .../resolvers/dns_resolver_test.cc | 9 +- test/core/end2end/BUILD | 17 +- test/core/end2end/fixtures/h2_full+trace.cc | 10 +- .../end2end/fixtures/h2_sockpair+trace.cc | 12 +- .../fixtures/h2_ssl_cred_reload_tls12.cc | 11 +- .../fixtures/h2_ssl_cred_reload_tls13.cc | 11 +- test/core/end2end/fixtures/h2_ssl_proxy.cc | 11 +- test/core/end2end/fixtures/h2_ssl_tls12.cc | 11 +- test/core/end2end/fixtures/h2_ssl_tls13.cc | 11 +- .../fixtures/h2_tls_certwatch_async_tls1_3.cc | 10 +- .../fixtures/h2_tls_certwatch_sync_tls1_2.cc | 10 +- test/core/end2end/fixtures/h2_tls_simple.cc | 10 +- .../fixtures/h2_tls_static_async_tls1_3.cc | 10 +- test/core/end2end/h2_ssl_cert_test.cc | 8 +- .../core/end2end/h2_ssl_session_reuse_test.cc | 9 +- ...ls_peer_property_external_verifier_test.cc | 10 +- test/core/end2end/tests/keepalive_timeout.cc | 16 +- .../posix/event_poller_posix_test.cc | 11 +- .../event_engine/posix/posix_endpoint_test.cc | 11 +- test/core/gprpp/BUILD | 31 -- test/core/gprpp/global_config_env_test.cc | 127 --------- test/core/gprpp/global_config_test.cc | 61 ---- test/core/http/httpcli_test_util.cc | 15 +- test/core/iomgr/buffer_list_test.cc | 1 - test/core/iomgr/resolve_address_posix_test.cc | 19 +- test/core/iomgr/resolve_address_test.cc | 6 +- .../grpc_tls_credentials_options_test.cc | 6 +- test/core/security/security_connector_test.cc | 28 +- .../security/tls_security_connector_test.cc | 6 +- .../remove_stream_from_stalled_lists_test.cc | 9 +- test/cpp/end2end/async_end2end_test.cc | 8 +- test/cpp/end2end/client_lb_end2end_test.cc | 7 +- test/cpp/end2end/end2end_test.cc | 10 +- test/cpp/end2end/grpclb_end2end_test.cc | 5 +- test/cpp/end2end/rls_end2end_test.cc | 5 +- .../server_load_reporting_end2end_test.cc | 5 +- .../end2end/service_config_end2end_test.cc | 5 +- .../end2end/xds/xds_cluster_end2end_test.cc | 5 +- .../xds/xds_cluster_type_end2end_test.cc | 5 +- test/cpp/end2end/xds/xds_core_end2end_test.cc | 5 +- test/cpp/end2end/xds/xds_csds_end2end_test.cc | 5 +- test/cpp/end2end/xds/xds_end2end_test.cc | 5 +- .../xds/xds_fault_injection_end2end_test.cc | 5 +- .../xds/xds_outlier_detection_end2end_test.cc | 5 +- .../xds/xds_override_host_end2end_test.cc | 5 +- .../end2end/xds/xds_ring_hash_end2end_test.cc | 5 +- test/cpp/end2end/xds/xds_rls_end2end_test.cc | 5 +- .../end2end/xds/xds_routing_end2end_test.cc | 5 +- test/cpp/end2end/xds/xds_wrr_end2end_test.cc | 5 +- test/cpp/naming/address_sorting_test.cc | 12 +- test/cpp/naming/cancel_ares_query_test.cc | 6 +- tools/codegen/core/gen_config_vars.py | 266 ++++++++++++++++++ tools/distrib/fix_build_deps.py | 76 +++-- tools/doxygen/Doxyfile.c++.internal | 14 +- tools/doxygen/Doxyfile.core.internal | 14 +- tools/run_tests/generated/tests.json | 46 --- 108 files changed, 1418 insertions(+), 1472 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc delete mode 100644 src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h create mode 100644 src/core/lib/config/config_vars.cc create mode 100644 src/core/lib/config/config_vars.h create mode 100644 src/core/lib/config/config_vars.yaml create mode 100644 src/core/lib/config/config_vars_non_generated.cc create mode 100644 src/core/lib/config/load_config.cc create mode 100644 src/core/lib/config/load_config.h delete mode 100644 src/core/lib/gprpp/global_config.h delete mode 100644 src/core/lib/gprpp/global_config_custom.h delete mode 100644 src/core/lib/gprpp/global_config_env.cc delete mode 100644 src/core/lib/gprpp/global_config_env.h delete mode 100644 src/core/lib/gprpp/global_config_generic.h delete mode 100644 src/core/lib/security/security_connector/ssl_utils_config.cc delete mode 100644 src/core/lib/security/security_connector/ssl_utils_config.h delete mode 100644 test/core/gprpp/global_config_env_test.cc delete mode 100644 test/core/gprpp/global_config_test.cc create mode 100755 tools/codegen/core/gen_config_vars.py diff --git a/BUILD b/BUILD index 7ada5282efb..fae67df83fe 100644 --- a/BUILD +++ b/BUILD @@ -668,7 +668,6 @@ grpc_cc_library( "//src/core:lib/gpr/wrap_memcpy.cc", "//src/core:lib/gprpp/crash.cc", "//src/core:lib/gprpp/fork.cc", - "//src/core:lib/gprpp/global_config_env.cc", "//src/core:lib/gprpp/host_port.cc", "//src/core:lib/gprpp/mpscq.cc", "//src/core:lib/gprpp/posix/stat.cc", @@ -684,10 +683,6 @@ grpc_cc_library( "//src/core:lib/gpr/tmpfile.h", "//src/core:lib/gprpp/crash.h", "//src/core:lib/gprpp/fork.h", - "//src/core:lib/gprpp/global_config.h", - "//src/core:lib/gprpp/global_config_custom.h", - "//src/core:lib/gprpp/global_config_env.h", - "//src/core:lib/gprpp/global_config_generic.h", "//src/core:lib/gprpp/host_port.h", "//src/core:lib/gprpp/memory.h", "//src/core:lib/gprpp/mpscq.h", @@ -716,6 +711,7 @@ grpc_cc_library( ], visibility = ["@grpc:public"], deps = [ + "config_vars", "debug_location", "//src/core:construct_destruct", "//src/core:env", @@ -1441,6 +1437,7 @@ grpc_cc_library( deps = [ "channel_stack_builder", "config", + "config_vars", "cpp_impl_of", "debug_location", "exec_ctx", @@ -2281,14 +2278,56 @@ grpc_cc_library( name = "grpc_trace", srcs = ["//src/core:lib/debug/trace.cc"], hdrs = ["//src/core:lib/debug/trace.h"], + external_deps = ["absl/strings"], language = "c++", visibility = ["@grpc:trace"], deps = [ + "config_vars", "gpr", "grpc_public_hdrs", ], ) +grpc_cc_library( + name = "load_config", + srcs = [ + "//src/core:lib/config/load_config.cc", + ], + hdrs = [ + "//src/core:lib/config/load_config.h", + ], + external_deps = [ + "absl/flags:flag", + "absl/flags:marshalling", + "absl/strings", + "absl/types:optional", + ], + deps = [ + "gpr_platform", + "//src/core:env", + ], +) + +grpc_cc_library( + name = "config_vars", + srcs = [ + "//src/core:lib/config/config_vars.cc", + "//src/core:lib/config/config_vars_non_generated.cc", + ], + hdrs = [ + "//src/core:lib/config/config_vars.h", + ], + external_deps = [ + "absl/flags:flag", + "absl/strings", + "absl/types:optional", + ], + deps = [ + "gpr_platform", + "load_config", + ], +) + grpc_cc_library( name = "config", srcs = [ @@ -2804,6 +2843,7 @@ grpc_cc_library( "backoff", "channel_stack_builder", "config", + "config_vars", "debug_location", "exec_ctx", "gpr", @@ -2898,6 +2938,7 @@ grpc_cc_library( deps = [ "backoff", "config", + "config_vars", "debug_location", "exec_ctx", "gpr", @@ -2917,7 +2958,6 @@ grpc_cc_library( "//src/core:closure", "//src/core:error", "//src/core:event_engine_common", - "//src/core:grpc_resolver_dns_selection", "//src/core:grpc_service_config", "//src/core:grpc_sockaddr", "//src/core:iomgr_fwd", @@ -3118,6 +3158,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:public"], deps = [ + "config_vars", "gpr", "grpc_base", "grpc_security_base", @@ -3240,14 +3281,12 @@ grpc_cc_library( name = "tsi_ssl_credentials", srcs = [ "//src/core:lib/security/security_connector/ssl_utils.cc", - "//src/core:lib/security/security_connector/ssl_utils_config.cc", "//src/core:tsi/ssl/key_logging/ssl_key_logging.cc", "//src/core:tsi/ssl_transport_security.cc", "//src/core:tsi/ssl_transport_security_utils.cc", ], hdrs = [ "//src/core:lib/security/security_connector/ssl_utils.h", - "//src/core:lib/security/security_connector/ssl_utils_config.h", "//src/core:tsi/ssl/key_logging/ssl_key_logging.h", "//src/core:tsi/ssl_transport_security.h", "//src/core:tsi/ssl_transport_security_utils.h", @@ -3262,6 +3301,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:public"], deps = [ + "config_vars", "gpr", "grpc_base", "grpc_credentials_util", diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae6cb92577..b3db59a80e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,16 @@ set(gRPC_ABSL_USED_TARGETS absl_exponential_biased absl_fast_type_id absl_fixed_array + absl_flags + absl_flags_commandlineflag + absl_flags_commandlineflag_internal + absl_flags_config + absl_flags_internal + absl_flags_marshalling + absl_flags_path_util + absl_flags_private_handle_accessor + absl_flags_program_name + absl_flags_reflection absl_flat_hash_map absl_flat_hash_set absl_function_ref @@ -967,10 +977,6 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx fuzzing_event_engine_test) endif() add_dependencies(buildtests_cxx generic_end2end_test) - if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_dependencies(buildtests_cxx global_config_env_test) - endif() - add_dependencies(buildtests_cxx global_config_test) add_dependencies(buildtests_cxx google_c2p_resolver_test) add_dependencies(buildtests_cxx google_mesh_ca_certificate_provider_factory_test) add_dependencies(buildtests_cxx graceful_shutdown_test) @@ -1556,6 +1562,9 @@ target_link_libraries(end2end_tests endif() add_library(gpr + src/core/lib/config/config_vars.cc + src/core/lib/config/config_vars_non_generated.cc + src/core/lib/config/load_config.cc src/core/lib/event_engine/thread_local.cc src/core/lib/gpr/alloc.cc src/core/lib/gpr/android/log.cc @@ -1587,7 +1596,6 @@ add_library(gpr src/core/lib/gprpp/crash.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc src/core/lib/gprpp/host_port.cc src/core/lib/gprpp/linux/env.cc src/core/lib/gprpp/mpscq.cc @@ -1639,6 +1647,8 @@ target_link_libraries(gpr ${_gRPC_ALLTARGETS_LIBRARIES} absl::base absl::core_headers + absl::flags + absl::flags_marshalling absl::memory absl::random_random absl::status @@ -1759,7 +1769,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc @@ -2377,7 +2386,6 @@ add_library(grpc src/core/lib/security/security_connector/security_connector.cc src/core/lib/security/security_connector/ssl/ssl_security_connector.cc src/core/lib/security/security_connector/ssl_utils.cc - src/core/lib/security/security_connector/ssl_utils_config.cc src/core/lib/security/security_connector/tls/tls_security_connector.cc src/core/lib/security/transport/client_auth_filter.cc src/core/lib/security/transport/secure_endpoint.cc @@ -2774,7 +2782,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/resolver/polling_resolver.cc @@ -4051,7 +4058,6 @@ target_link_libraries(grpc++_test_util ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -11785,82 +11791,6 @@ target_link_libraries(generic_end2end_test ) -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(global_config_env_test - test/core/gprpp/global_config_env_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - target_compile_features(global_config_env_test PUBLIC cxx_std_14) - target_include_directories(global_config_env_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - - target_link_libraries(global_config_env_test - ${_gRPC_BASELIB_LIBRARIES} - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ZLIB_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - ) - - -endif() -endif() -if(gRPC_BUILD_TESTS) - -add_executable(global_config_test - test/core/gprpp/global_config_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) -target_compile_features(global_config_test PUBLIC cxx_std_14) -target_include_directories(global_config_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(global_config_test - ${_gRPC_BASELIB_LIBRARIES} - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ZLIB_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util -) - - endif() if(gRPC_BUILD_TESTS) @@ -12259,7 +12189,6 @@ target_link_libraries(grpc_cli ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc++_test_config ) @@ -17408,7 +17337,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags absl::flags_parse grpc_test_util ) @@ -17512,7 +17440,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags absl::flags_parse grpc_test_util ) @@ -23323,7 +23250,6 @@ target_link_libraries(xds_common_types_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -24314,7 +24240,6 @@ target_link_libraries(xds_http_filters_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -24383,7 +24308,6 @@ target_link_libraries(xds_interop_client ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++_reflection grpcpp_channelz grpc_test_util @@ -24459,7 +24383,6 @@ target_link_libraries(xds_interop_server ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++_reflection grpcpp_channelz grpc_test_util @@ -24569,7 +24492,6 @@ target_link_libraries(xds_lb_policy_registry_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -24705,7 +24627,6 @@ target_link_libraries(xds_listener_resource_type_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -25597,7 +25518,6 @@ target_link_libraries(xds_route_config_resource_type_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::flags grpc++ grpc_test_util ) @@ -26018,7 +25938,7 @@ generate_pkgconfig( "gpr" "gRPC platform support library" "${gRPC_CORE_VERSION}" - "absl_base absl_cord absl_core_headers absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant" + "absl_base absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant" "" "-lgpr" "" @@ -26029,7 +25949,7 @@ generate_pkgconfig( "gRPC" "high performance general RPC framework" "${gRPC_CORE_VERSION}" - "gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" + "gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" "openssl re2 libcares zlib" "-lgrpc" "-laddress_sorting -lupb" @@ -26040,7 +25960,7 @@ generate_pkgconfig( "gRPC unsecure" "high performance general RPC framework without SSL" "${gRPC_CORE_VERSION}" - "gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" + "gpr absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" "re2 libcares zlib" "-lgrpc_unsecure" "-laddress_sorting -lupb" @@ -26051,7 +25971,7 @@ generate_pkgconfig( "gRPC++" "C++ wrapper for gRPC" "${gRPC_CPP_VERSION}" - "grpc absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" + "grpc absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" "" "-lgrpc++" "" @@ -26062,7 +25982,7 @@ generate_pkgconfig( "gRPC++ unsecure" "C++ wrapper for gRPC without SSL" "${gRPC_CPP_VERSION}" - "grpc_unsecure absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" + "grpc_unsecure absl_any_invocable absl_base absl_bind_front absl_cleanup absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_memory absl_optional absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant" "" "-lgrpc++_unsecure" "" diff --git a/Makefile b/Makefile index f5710676a33..a6229bb5198 100644 --- a/Makefile +++ b/Makefile @@ -840,6 +840,9 @@ endif # start of build recipe for library "gpr" (generated by makelib(lib) template function) LIBGPR_SRC = \ + src/core/lib/config/config_vars.cc \ + src/core/lib/config/config_vars_non_generated.cc \ + src/core/lib/config/load_config.cc \ src/core/lib/event_engine/thread_local.cc \ src/core/lib/gpr/alloc.cc \ src/core/lib/gpr/android/log.cc \ @@ -871,7 +874,6 @@ LIBGPR_SRC = \ src/core/lib/gprpp/crash.cc \ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/fork.cc \ - src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/linux/env.cc \ src/core/lib/gprpp/mpscq.cc \ @@ -1008,7 +1010,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc \ @@ -1626,7 +1627,6 @@ LIBGRPC_SRC = \ src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ - src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/tls_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -1876,7 +1876,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/polling_resolver.cc \ @@ -2861,6 +2860,15 @@ LIBGRPC_ABSEIL_SRC = \ third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc \ third_party/abseil-cpp/absl/debugging/stacktrace.cc \ third_party/abseil-cpp/absl/debugging/symbolize.cc \ + third_party/abseil-cpp/absl/flags/commandlineflag.cc \ + third_party/abseil-cpp/absl/flags/flag.cc \ + third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc \ + third_party/abseil-cpp/absl/flags/internal/flag.cc \ + third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc \ + third_party/abseil-cpp/absl/flags/internal/program_name.cc \ + third_party/abseil-cpp/absl/flags/marshalling.cc \ + third_party/abseil-cpp/absl/flags/reflection.cc \ + third_party/abseil-cpp/absl/flags/usage_config.cc \ third_party/abseil-cpp/absl/hash/internal/city.cc \ third_party/abseil-cpp/absl/hash/internal/hash.cc \ third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc \ @@ -3336,7 +3344,6 @@ src/core/lib/security/security_connector/alts/alts_security_connector.cc: $(OPEN src/core/lib/security/security_connector/local/local_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl/ssl_security_connector.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/ssl_utils.cc: $(OPENSSL_DEP) -src/core/lib/security/security_connector/ssl_utils_config.cc: $(OPENSSL_DEP) src/core/lib/security/security_connector/tls/tls_security_connector.cc: $(OPENSSL_DEP) src/core/plugin_registry/grpc_plugin_registry_extra.cc: $(OPENSSL_DEP) src/core/tsi/alts/crypt/aes_gcm.cc: $(OPENSSL_DEP) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 577fbbac247..7cd255f0668 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -177,6 +177,8 @@ libs: - include/grpc/support/thd_id.h - include/grpc/support/time.h headers: + - src/core/lib/config/config_vars.h + - src/core/lib/config/load_config.h - src/core/lib/event_engine/thread_local.h - src/core/lib/gpr/alloc.h - src/core/lib/gpr/string.h @@ -189,10 +191,6 @@ libs: - src/core/lib/gprpp/env.h - src/core/lib/gprpp/examine_stack.h - src/core/lib/gprpp/fork.h - - src/core/lib/gprpp/global_config.h - - src/core/lib/gprpp/global_config_custom.h - - src/core/lib/gprpp/global_config_env.h - - src/core/lib/gprpp/global_config_generic.h - src/core/lib/gprpp/host_port.h - src/core/lib/gprpp/memory.h - src/core/lib/gprpp/mpscq.h @@ -204,6 +202,9 @@ libs: - src/core/lib/gprpp/thd.h - src/core/lib/gprpp/time_util.h src: + - src/core/lib/config/config_vars.cc + - src/core/lib/config/config_vars_non_generated.cc + - src/core/lib/config/load_config.cc - src/core/lib/event_engine/thread_local.cc - src/core/lib/gpr/alloc.cc - src/core/lib/gpr/android/log.cc @@ -235,7 +236,6 @@ libs: - src/core/lib/gprpp/crash.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - - src/core/lib/gprpp/global_config_env.cc - src/core/lib/gprpp/host_port.cc - src/core/lib/gprpp/linux/env.cc - src/core/lib/gprpp/mpscq.cc @@ -251,6 +251,8 @@ libs: deps: - absl/base:base - absl/base:core_headers + - absl/flags:flag + - absl/flags:marshalling - absl/memory:memory - absl/random:random - absl/status:status @@ -370,7 +372,6 @@ libs: - src/core/ext/filters/client_channel/local_subchannel_pool.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h - src/core/ext/filters/client_channel/resolver/polling_resolver.h - src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h @@ -1025,7 +1026,6 @@ libs: - src/core/lib/security/security_connector/security_connector.h - src/core/lib/security/security_connector/ssl/ssl_security_connector.h - src/core/lib/security/security_connector/ssl_utils.h - - src/core/lib/security/security_connector/ssl_utils_config.h - src/core/lib/security/security_connector/tls/tls_security_connector.h - src/core/lib/security/transport/auth_filters.h - src/core/lib/security/transport/secure_endpoint.h @@ -1157,7 +1157,6 @@ libs: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc - src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc @@ -1775,7 +1774,6 @@ libs: - src/core/lib/security/security_connector/security_connector.cc - src/core/lib/security/security_connector/ssl/ssl_security_connector.cc - src/core/lib/security/security_connector/ssl_utils.cc - - src/core/lib/security/security_connector/ssl_utils_config.cc - src/core/lib/security/security_connector/tls/tls_security_connector.cc - src/core/lib/security/transport/client_auth_filter.cc - src/core/lib/security/transport/secure_endpoint.cc @@ -2042,7 +2040,6 @@ libs: - src/core/ext/filters/client_channel/local_subchannel_pool.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h - src/core/ext/filters/client_channel/resolver/polling_resolver.h - src/core/ext/filters/client_channel/retry_filter.h @@ -2438,7 +2435,6 @@ libs: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc - - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc - src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc - src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc - src/core/ext/filters/client_channel/resolver/polling_resolver.cc @@ -3239,7 +3235,6 @@ libs: - test/cpp/util/subprocess.cc - test/cpp/util/test_credentials_provider.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util - name: grpc++_unsecure @@ -7905,30 +7900,6 @@ targets: - test/cpp/end2end/generic_end2end_test.cc deps: - grpc++_test_util -- name: global_config_env_test - gtest: true - build: test - language: c++ - headers: [] - src: - - test/core/gprpp/global_config_env_test.cc - deps: - - grpc_test_util - platforms: - - linux - - posix - - mac - uses_polling: false -- name: global_config_test - gtest: true - build: test - language: c++ - headers: [] - src: - - test/core/gprpp/global_config_test.cc - deps: - - grpc_test_util - uses_polling: false - name: google_c2p_resolver_test gtest: true build: test @@ -8114,7 +8085,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc++_test_config - name: grpc_completion_queue_test @@ -10397,7 +10367,6 @@ targets: - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - - absl/flags:flag - absl/flags:parse - grpc_test_util args: @@ -10476,7 +10445,6 @@ targets: - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - - absl/flags:flag - absl/flags:parse - grpc_test_util args: @@ -12979,7 +12947,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util uses_polling: false @@ -13316,7 +13283,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util uses_polling: false @@ -13338,7 +13304,6 @@ targets: - src/cpp/server/csds/csds.cc - test/cpp/interop/xds_interop_client.cc deps: - - absl/flags:flag - grpc++_reflection - grpcpp_channelz - grpc_test_util @@ -13364,7 +13329,6 @@ targets: - test/cpp/end2end/test_health_check_service_impl.cc - test/cpp/interop/xds_interop_server.cc deps: - - absl/flags:flag - grpc++_reflection - grpcpp_channelz - grpc_test_util @@ -13405,7 +13369,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util uses_polling: false @@ -13451,7 +13414,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util uses_polling: false @@ -13742,7 +13704,6 @@ targets: - test/cpp/util/proto_reflection_descriptor_database.cc - test/cpp/util/service_describer.cc deps: - - absl/flags:flag - grpc++ - grpc_test_util uses_polling: false diff --git a/config.m4 b/config.m4 index 92612e073b6..81c7089a115 100644 --- a/config.m4 +++ b/config.m4 @@ -89,7 +89,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ - src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc \ @@ -501,7 +500,10 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ + src/core/lib/config/config_vars.cc \ + src/core/lib/config/config_vars_non_generated.cc \ src/core/lib/config/core_configuration.cc \ + src/core/lib/config/load_config.cc \ src/core/lib/debug/event_log.cc \ src/core/lib/debug/histogram_view.cc \ src/core/lib/debug/stats.cc \ @@ -577,7 +579,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gprpp/crash.cc \ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/fork.cc \ - src/core/lib/gprpp/global_config_env.cc \ src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/linux/env.cc \ src/core/lib/gprpp/load_file.cc \ @@ -751,7 +752,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/security/security_connector/security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl_utils.cc \ - src/core/lib/security/security_connector/ssl_utils_config.cc \ src/core/lib/security/security_connector/tls/tls_security_connector.cc \ src/core/lib/security/transport/client_auth_filter.cc \ src/core/lib/security/transport/secure_endpoint.cc \ @@ -873,6 +873,15 @@ if test "$PHP_GRPC" != "no"; then third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc \ third_party/abseil-cpp/absl/debugging/stacktrace.cc \ third_party/abseil-cpp/absl/debugging/symbolize.cc \ + third_party/abseil-cpp/absl/flags/commandlineflag.cc \ + third_party/abseil-cpp/absl/flags/flag.cc \ + third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc \ + third_party/abseil-cpp/absl/flags/internal/flag.cc \ + third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc \ + third_party/abseil-cpp/absl/flags/internal/program_name.cc \ + third_party/abseil-cpp/absl/flags/marshalling.cc \ + third_party/abseil-cpp/absl/flags/reflection.cc \ + third_party/abseil-cpp/absl/flags/usage_config.cc \ third_party/abseil-cpp/absl/hash/internal/city.cc \ third_party/abseil-cpp/absl/hash/internal/hash.cc \ third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc \ @@ -1285,7 +1294,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/binder) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake) @@ -1485,6 +1493,8 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/crc/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/debugging) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/debugging/internal) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/flags) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/flags/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/hash/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/numeric) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/profiling/internal) diff --git a/config.w32 b/config.w32 index 6da67e3c94c..e9dbafed555 100644 --- a/config.w32 +++ b/config.w32 @@ -55,7 +55,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " + - "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\fake\\fake_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\google_c2p\\google_c2p_resolver.cc " + @@ -467,7 +466,10 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + + "src\\core\\lib\\config\\config_vars.cc " + + "src\\core\\lib\\config\\config_vars_non_generated.cc " + "src\\core\\lib\\config\\core_configuration.cc " + + "src\\core\\lib\\config\\load_config.cc " + "src\\core\\lib\\debug\\event_log.cc " + "src\\core\\lib\\debug\\histogram_view.cc " + "src\\core\\lib\\debug\\stats.cc " + @@ -543,7 +545,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gprpp\\crash.cc " + "src\\core\\lib\\gprpp\\examine_stack.cc " + "src\\core\\lib\\gprpp\\fork.cc " + - "src\\core\\lib\\gprpp\\global_config_env.cc " + "src\\core\\lib\\gprpp\\host_port.cc " + "src\\core\\lib\\gprpp\\linux\\env.cc " + "src\\core\\lib\\gprpp\\load_file.cc " + @@ -717,7 +718,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\security\\security_connector\\security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl\\ssl_security_connector.cc " + "src\\core\\lib\\security\\security_connector\\ssl_utils.cc " + - "src\\core\\lib\\security\\security_connector\\ssl_utils_config.cc " + "src\\core\\lib\\security\\security_connector\\tls\\tls_security_connector.cc " + "src\\core\\lib\\security\\transport\\client_auth_filter.cc " + "src\\core\\lib\\security\\transport\\secure_endpoint.cc " + @@ -839,6 +839,15 @@ if (PHP_GRPC != "no") { "third_party\\abseil-cpp\\absl\\debugging\\internal\\vdso_support.cc " + "third_party\\abseil-cpp\\absl\\debugging\\stacktrace.cc " + "third_party\\abseil-cpp\\absl\\debugging\\symbolize.cc " + + "third_party\\abseil-cpp\\absl\\flags\\commandlineflag.cc " + + "third_party\\abseil-cpp\\absl\\flags\\flag.cc " + + "third_party\\abseil-cpp\\absl\\flags\\internal\\commandlineflag.cc " + + "third_party\\abseil-cpp\\absl\\flags\\internal\\flag.cc " + + "third_party\\abseil-cpp\\absl\\flags\\internal\\private_handle_accessor.cc " + + "third_party\\abseil-cpp\\absl\\flags\\internal\\program_name.cc " + + "third_party\\abseil-cpp\\absl\\flags\\marshalling.cc " + + "third_party\\abseil-cpp\\absl\\flags\\reflection.cc " + + "third_party\\abseil-cpp\\absl\\flags\\usage_config.cc " + "third_party\\abseil-cpp\\absl\\hash\\internal\\city.cc " + "third_party\\abseil-cpp\\absl\\hash\\internal\\hash.cc " + "third_party\\abseil-cpp\\absl\\hash\\internal\\low_level_hash.cc " + @@ -1626,6 +1635,8 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\crc\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\debugging"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\debugging\\internal"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\flags"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\flags\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\numeric"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 5656c0bcc96..f1a15464ca6 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -220,6 +220,8 @@ Pod::Spec.new do |s| ss.dependency 'abseil/container/flat_hash_map', abseil_version ss.dependency 'abseil/container/flat_hash_set', abseil_version ss.dependency 'abseil/container/inlined_vector', abseil_version + ss.dependency 'abseil/flags/flag', abseil_version + ss.dependency 'abseil/flags/marshalling', abseil_version ss.dependency 'abseil/functional/any_invocable', abseil_version ss.dependency 'abseil/functional/bind_front', abseil_version ss.dependency 'abseil/functional/function_ref', abseil_version @@ -276,7 +278,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/local_subchannel_pool.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/resolver/polling_resolver.h', 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h', @@ -728,7 +729,9 @@ Pod::Spec.new do |s| 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', + 'src/core/lib/config/config_vars.h', 'src/core/lib/config/core_configuration.h', + 'src/core/lib/config/load_config.h', 'src/core/lib/debug/event_log.h', 'src/core/lib/debug/histogram_view.h', 'src/core/lib/debug/stats.h', @@ -795,10 +798,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/env.h', 'src/core/lib/gprpp/examine_stack.h', 'src/core/lib/gprpp/fork.h', - 'src/core/lib/gprpp/global_config.h', - 'src/core/lib/gprpp/global_config_custom.h', - 'src/core/lib/gprpp/global_config_env.h', - 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/load_file.h', 'src/core/lib/gprpp/manual_constructor.h', @@ -995,7 +994,6 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', - 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/tls_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', @@ -1229,7 +1227,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/local_subchannel_pool.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/resolver/polling_resolver.h', 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h', @@ -1663,7 +1660,9 @@ Pod::Spec.new do |s| 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', + 'src/core/lib/config/config_vars.h', 'src/core/lib/config/core_configuration.h', + 'src/core/lib/config/load_config.h', 'src/core/lib/debug/event_log.h', 'src/core/lib/debug/histogram_view.h', 'src/core/lib/debug/stats.h', @@ -1730,10 +1729,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/env.h', 'src/core/lib/gprpp/examine_stack.h', 'src/core/lib/gprpp/fork.h', - 'src/core/lib/gprpp/global_config.h', - 'src/core/lib/gprpp/global_config_custom.h', - 'src/core/lib/gprpp/global_config_env.h', - 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/load_file.h', 'src/core/lib/gprpp/manual_constructor.h', @@ -1930,7 +1925,6 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', - 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/tls_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 5f1b1963a26..923623757a4 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -186,6 +186,8 @@ Pod::Spec.new do |s| ss.dependency 'abseil/container/flat_hash_map', abseil_version ss.dependency 'abseil/container/flat_hash_set', abseil_version ss.dependency 'abseil/container/inlined_vector', abseil_version + ss.dependency 'abseil/flags/flag', abseil_version + ss.dependency 'abseil/flags/marshalling', abseil_version ss.dependency 'abseil/functional/any_invocable', abseil_version ss.dependency 'abseil/functional/bind_front', abseil_version ss.dependency 'abseil/functional/function_ref', abseil_version @@ -292,8 +294,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', @@ -1118,8 +1118,13 @@ Pod::Spec.new do |s| 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/message_compress.h', + 'src/core/lib/config/config_vars.cc', + 'src/core/lib/config/config_vars.h', + 'src/core/lib/config/config_vars_non_generated.cc', 'src/core/lib/config/core_configuration.cc', 'src/core/lib/config/core_configuration.h', + 'src/core/lib/config/load_config.cc', + 'src/core/lib/config/load_config.h', 'src/core/lib/debug/event_log.cc', 'src/core/lib/debug/event_log.h', 'src/core/lib/debug/histogram_view.cc', @@ -1261,11 +1266,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/examine_stack.h', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/fork.h', - 'src/core/lib/gprpp/global_config.h', - 'src/core/lib/gprpp/global_config_custom.h', - 'src/core/lib/gprpp/global_config_env.cc', - 'src/core/lib/gprpp/global_config_env.h', - 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/linux/env.cc', @@ -1635,8 +1635,6 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.cc', 'src/core/lib/security/security_connector/ssl_utils.h', - 'src/core/lib/security/security_connector/ssl_utils_config.cc', - 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/tls_security_connector.cc', 'src/core/lib/security/security_connector/tls/tls_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', @@ -1938,7 +1936,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/local_subchannel_pool.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/resolver/polling_resolver.h', 'src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h', @@ -2352,7 +2349,9 @@ Pod::Spec.new do |s| 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', + 'src/core/lib/config/config_vars.h', 'src/core/lib/config/core_configuration.h', + 'src/core/lib/config/load_config.h', 'src/core/lib/debug/event_log.h', 'src/core/lib/debug/histogram_view.h', 'src/core/lib/debug/stats.h', @@ -2419,10 +2418,6 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/env.h', 'src/core/lib/gprpp/examine_stack.h', 'src/core/lib/gprpp/fork.h', - 'src/core/lib/gprpp/global_config.h', - 'src/core/lib/gprpp/global_config_custom.h', - 'src/core/lib/gprpp/global_config_env.h', - 'src/core/lib/gprpp/global_config_generic.h', 'src/core/lib/gprpp/host_port.h', 'src/core/lib/gprpp/load_file.h', 'src/core/lib/gprpp/manual_constructor.h', @@ -2619,7 +2614,6 @@ Pod::Spec.new do |s| 'src/core/lib/security/security_connector/security_connector.h', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.h', 'src/core/lib/security/security_connector/ssl_utils.h', - 'src/core/lib/security/security_connector/ssl_utils_config.h', 'src/core/lib/security/security_connector/tls/tls_security_connector.h', 'src/core/lib/security/transport/auth_filters.h', 'src/core/lib/security/transport/secure_endpoint.h', diff --git a/grpc.gemspec b/grpc.gemspec index fdbd9757882..01f7b372b7c 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -201,8 +201,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc ) - s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) @@ -1027,8 +1025,13 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.cc ) s.files += %w( src/core/lib/compression/message_compress.h ) + s.files += %w( src/core/lib/config/config_vars.cc ) + s.files += %w( src/core/lib/config/config_vars.h ) + s.files += %w( src/core/lib/config/config_vars_non_generated.cc ) s.files += %w( src/core/lib/config/core_configuration.cc ) s.files += %w( src/core/lib/config/core_configuration.h ) + s.files += %w( src/core/lib/config/load_config.cc ) + s.files += %w( src/core/lib/config/load_config.h ) s.files += %w( src/core/lib/debug/event_log.cc ) s.files += %w( src/core/lib/debug/event_log.h ) s.files += %w( src/core/lib/debug/histogram_view.cc ) @@ -1170,11 +1173,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/examine_stack.h ) s.files += %w( src/core/lib/gprpp/fork.cc ) s.files += %w( src/core/lib/gprpp/fork.h ) - s.files += %w( src/core/lib/gprpp/global_config.h ) - s.files += %w( src/core/lib/gprpp/global_config_custom.h ) - s.files += %w( src/core/lib/gprpp/global_config_env.cc ) - s.files += %w( src/core/lib/gprpp/global_config_env.h ) - s.files += %w( src/core/lib/gprpp/global_config_generic.h ) s.files += %w( src/core/lib/gprpp/host_port.cc ) s.files += %w( src/core/lib/gprpp/host_port.h ) s.files += %w( src/core/lib/gprpp/linux/env.cc ) @@ -1544,8 +1542,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/security_connector/ssl/ssl_security_connector.h ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.cc ) s.files += %w( src/core/lib/security/security_connector/ssl_utils.h ) - s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.cc ) - s.files += %w( src/core/lib/security/security_connector/ssl_utils_config.h ) s.files += %w( src/core/lib/security/security_connector/tls/tls_security_connector.cc ) s.files += %w( src/core/lib/security/security_connector/tls/tls_security_connector.h ) s.files += %w( src/core/lib/security/transport/auth_filters.h ) @@ -1836,6 +1832,30 @@ Gem::Specification.new do |s| s.files += %w( third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc ) s.files += %w( third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc ) s.files += %w( third_party/abseil-cpp/absl/debugging/symbolize_win32.inc ) + s.files += %w( third_party/abseil-cpp/absl/flags/commandlineflag.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/commandlineflag.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/config.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/declare.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/flag.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/flag.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/commandlineflag.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/flag.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/flag.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/path_util.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/program_name.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/program_name.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/registry.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/internal/sequence_lock.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/marshalling.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/marshalling.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/reflection.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/reflection.h ) + s.files += %w( third_party/abseil-cpp/absl/flags/usage_config.cc ) + s.files += %w( third_party/abseil-cpp/absl/flags/usage_config.h ) s.files += %w( third_party/abseil-cpp/absl/functional/any_invocable.h ) s.files += %w( third_party/abseil-cpp/absl/functional/bind_front.h ) s.files += %w( third_party/abseil-cpp/absl/functional/function_ref.h ) diff --git a/grpc.gyp b/grpc.gyp index cba8fd1e7aa..302e13d6aa7 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -293,6 +293,8 @@ 'dependencies': [ 'absl/base:base', 'absl/base:core_headers', + 'absl/flags:flag', + 'absl/flags:marshalling', 'absl/memory:memory', 'absl/random:random', 'absl/status:status', @@ -305,6 +307,9 @@ 'absl/types:variant', ], 'sources': [ + 'src/core/lib/config/config_vars.cc', + 'src/core/lib/config/config_vars_non_generated.cc', + 'src/core/lib/config/load_config.cc', 'src/core/lib/event_engine/thread_local.cc', 'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/android/log.cc', @@ -336,7 +341,6 @@ 'src/core/lib/gprpp/crash.cc', 'src/core/lib/gprpp/examine_stack.cc', 'src/core/lib/gprpp/fork.cc', - 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/linux/env.cc', 'src/core/lib/gprpp/mpscq.cc', @@ -421,7 +425,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc', @@ -1039,7 +1042,6 @@ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', - 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/tls_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', @@ -1231,7 +1233,6 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/polling_resolver.cc', @@ -1712,7 +1713,6 @@ 'target_name': 'grpc++_test_util', 'type': 'static_library', 'dependencies': [ - 'absl/flags:flag', 'grpc++', 'grpc_test_util', ], diff --git a/package.xml b/package.xml index bf49b7242cc..156ca9b77cd 100644 --- a/package.xml +++ b/package.xml @@ -183,8 +183,6 @@ - - @@ -1009,8 +1007,13 @@ + + + + + @@ -1152,11 +1155,6 @@ - - - - - @@ -1526,8 +1524,6 @@ - - @@ -1840,6 +1836,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc index 40009dd0223..e2fd0e8b85b 100644 --- a/src/android/test/interop/app/src/main/cpp/grpc-interop.cc +++ b/src/android/test/interop/app/src/main/cpp/grpc-interop.cc @@ -16,10 +16,10 @@ * */ -#include #include -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include + #include "test/cpp/interop/interop_client.h" std::shared_ptr GetClient(const char* host, diff --git a/src/core/BUILD b/src/core/BUILD index dd2c2f50f17..5e9b1000c43 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -116,6 +116,7 @@ grpc_cc_library( language = "c++", deps = [ "no_destruct", + "//:config_vars", "//:gpr", ], ) @@ -1730,6 +1731,7 @@ grpc_cc_library( "posix_event_engine_event_poller", "posix_event_engine_poller_posix_epoll1", "posix_event_engine_poller_posix_poll", + "//:config_vars", "//:gpr", ], ) @@ -4849,18 +4851,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_resolver_dns_selection", - srcs = [ - "ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc", - ], - hdrs = [ - "ext/filters/client_channel/resolver/dns/dns_resolver_selection.h", - ], - language = "c++", - deps = ["//:gpr"], -) - grpc_cc_library( name = "grpc_resolver_dns_native", srcs = [ @@ -4876,12 +4866,12 @@ grpc_cc_library( language = "c++", deps = [ "channel_args", - "grpc_resolver_dns_selection", "polling_resolver", "resolved_address", "time", "//:backoff", "//:config", + "//:config_vars", "//:debug_location", "//:gpr", "//:grpc_base", diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index cf74703ed13..0aab5985eaa 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -28,7 +28,7 @@ #include #include -#include "src/core/lib/gprpp/global_config.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/closure.h" @@ -61,19 +61,10 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu static grpc_core::Duration g_poll_interval = grpc_core::Duration::Milliseconds(DEFAULT_POLL_INTERVAL_MS); -GPR_GLOBAL_CONFIG_DEFINE_INT32( - grpc_client_channel_backup_poll_interval_ms, DEFAULT_POLL_INTERVAL_MS, - "Declares the interval in ms between two backup polls on client channels. " - "These polls are run in the timer thread so that gRPC can process " - "connection failures while there is no active polling thread. " - "They help reconnect disconnected client channels (mostly due to " - "idleness), so that the next RPC on this channel won't fail. Set to 0 to " - "turn off the backup polls."); - void grpc_client_channel_global_init_backup_polling() { gpr_mu_init(&g_poller_mu); int32_t poll_interval_ms = - GPR_GLOBAL_CONFIG_GET(grpc_client_channel_backup_poll_interval_ms); + grpc_core::ConfigVars::Get().ClientChannelBackupPollIntervalMs(); if (poll_interval_ms < 0) { gpr_log(GPR_ERROR, "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %d, " diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 6c03b788d32..e2982bbe3cd 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -21,11 +21,8 @@ #include -#include "src/core/lib/gprpp/global_config_generic.h" #include "src/core/lib/iomgr/iomgr_fwd.h" -GPR_GLOBAL_CONFIG_DECLARE_INT32(grpc_client_channel_backup_poll_interval_ms); - // Initializes backup polling. void grpc_client_channel_global_init_backup_polling(); diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 8277a636a60..fe874007662 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -30,6 +30,7 @@ #include "absl/base/thread_annotations.h" #include "absl/status/status.h" #include "absl/status/statusor.h" +#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" #include "absl/types/optional.h" @@ -41,8 +42,6 @@ #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/status_helper.h" @@ -61,7 +60,6 @@ #if GRPC_ARES == 1 #include -#include #include @@ -70,12 +68,11 @@ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver/polling_resolver.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/handle_containers.h" -#include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/gethostname.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/json/json.h" @@ -811,19 +808,12 @@ class AresDNSResolver : public DNSResolver { intptr_t aba_token_ ABSL_GUARDED_BY(mu_) = 0; }; -bool ShouldUseAres(const char* resolver_env) { - return resolver_env == nullptr || strlen(resolver_env) == 0 || - gpr_stricmp(resolver_env, "ares") == 0; +bool ShouldUseAres(absl::string_view resolver_env) { + return resolver_env.empty() || absl::EqualsIgnoreCase(resolver_env, "ares"); } bool UseAresDnsResolver() { - static const bool result = []() { - UniquePtr resolver = GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - bool result = ShouldUseAres(resolver.get()); - if (result) gpr_log(GPR_DEBUG, "Using ares dns resolver"); - return result; - }(); - return result; + return ShouldUseAres(ConfigVars::Get().DnsResolver()); } } // namespace diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc deleted file mode 100644 index 97920b9ba12..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright 2019 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. -// - -// This is similar to the sockaddr resolver, except that it supports a -// bunch of query args that are useful for dependency injection in tests. - -#include - -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" - -#include "src/core/lib/gprpp/global_config.h" - -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_dns_resolver, "", - "Declares which DNS resolver to use. The default is ares if gRPC is built " - "with c-ares support. Otherwise, the value of this environment variable is " - "ignored.") diff --git a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h b/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h deleted file mode 100644 index ae7afa72728..00000000000 --- a/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H -#define GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H - -#include - -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/gprpp/memory.h" - -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_dns_resolver); - -#endif // GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 06372d844a6..7c268fd38c6 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -25,6 +25,7 @@ #include "absl/functional/bind_front.h" #include "absl/status/status.h" #include "absl/status/statusor.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/strings/strip.h" @@ -33,16 +34,13 @@ #include #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/ext/filters/client_channel/resolver/polling_resolver.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/debug_location.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" @@ -181,9 +179,7 @@ class NativeClientChannelDNSResolverFactory : public ResolverFactory { } // namespace void RegisterNativeDnsResolver(CoreConfiguration::Builder* builder) { - static const char* const resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver).release(); - if (gpr_stricmp(resolver, "native") == 0) { + if (absl::EqualsIgnoreCase(ConfigVars::Get().DnsResolver(), "native")) { gpr_log(GPR_DEBUG, "Using native dns resolver"); builder->resolver_registry()->RegisterResolverFactory( std::make_unique()); diff --git a/src/core/lib/config/config_vars.cc b/src/core/lib/config/config_vars.cc new file mode 100644 index 00000000000..7a5723b08be --- /dev/null +++ b/src/core/lib/config/config_vars.cc @@ -0,0 +1,137 @@ +// Copyright 2023 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. + +// +// Automatically generated by tools/codegen/core/gen_config_vars.py +// + +#include + +#include "src/core/lib/config/config_vars.h" + +#include "absl/flags/flag.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" + +#include "src/core/lib/config/load_config.h" + +#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING +#define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" +#endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING + +#ifdef GRPC_ENABLE_FORK_SUPPORT +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true +#else +#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false +#endif // GRPC_ENABLE_FORK_SUPPORT + +ABSL_FLAG(absl::optional, grpc_experiments, absl::nullopt, + "A comma separated list of currently active experiments. Experiments " + "may be prefixed with a '-' to disable them."); +ABSL_FLAG(absl::optional, grpc_client_channel_backup_poll_interval_ms, + absl::nullopt, + "Declares the interval in ms between two backup polls on client " + "channels. These polls are run in the timer thread so that gRPC can " + "process connection failures while there is no active polling " + "thread. They help reconnect disconnected client channels (mostly " + "due to idleness), so that the next RPC on this channel won't fail. " + "Set to 0 to turn off the backup polls."); +ABSL_FLAG(absl::optional, grpc_dns_resolver, absl::nullopt, + "Declares which DNS resolver to use. The default is ares if gRPC is " + "built with c-ares support. Otherwise, the value of this environment " + "variable is ignored."); +ABSL_FLAG(absl::optional, grpc_trace, absl::nullopt, + "A comma separated list of tracers that provide additional insight " + "into how gRPC C core is processing requests via debug logs."); +ABSL_FLAG(absl::optional, grpc_verbosity, absl::nullopt, + "Default gRPC logging verbosity"); +ABSL_FLAG(absl::optional, grpc_stacktrace_minloglevel, + absl::nullopt, + "Messages logged at the same or higher level than this will print " + "stacktrace"); +ABSL_FLAG(absl::optional, grpc_enable_fork_support, absl::nullopt, + "Enable fork support"); +ABSL_FLAG(absl::optional, grpc_poll_strategy, absl::nullopt, + "Declares which polling engines to try when starting gRPC. This is a " + "comma-separated list of engines, which are tried in priority order " + "first -> last."); +ABSL_FLAG(absl::optional, grpc_abort_on_leaks, absl::nullopt, + "A debugging aid to cause a call to abort() when gRPC objects are " + "leaked past grpc_shutdown()"); +ABSL_FLAG(absl::optional, grpc_system_ssl_roots_dir, absl::nullopt, + "Custom directory to SSL Roots"); +ABSL_FLAG(absl::optional, grpc_default_ssl_roots_file_path, + absl::nullopt, "Path to the default SSL roots file."); +ABSL_FLAG(absl::optional, grpc_not_use_system_ssl_roots, absl::nullopt, + "Disable loading system root certificates."); +ABSL_FLAG(absl::optional, grpc_ssl_cipher_suites, absl::nullopt, + "A colon separated list of cipher suites to use with OpenSSL"); + +namespace grpc_core { + +ConfigVars::ConfigVars(const Overrides& overrides) + : client_channel_backup_poll_interval_ms_( + LoadConfig(FLAGS_grpc_client_channel_backup_poll_interval_ms, + overrides.client_channel_backup_poll_interval_ms, 5000)), + enable_fork_support_(LoadConfig(FLAGS_grpc_enable_fork_support, + overrides.enable_fork_support, + GRPC_ENABLE_FORK_SUPPORT_DEFAULT)), + abort_on_leaks_(LoadConfig(FLAGS_grpc_abort_on_leaks, + overrides.abort_on_leaks, false)), + not_use_system_ssl_roots_(LoadConfig(FLAGS_grpc_not_use_system_ssl_roots, + overrides.not_use_system_ssl_roots, + false)), + experiments_( + LoadConfig(FLAGS_grpc_experiments, overrides.experiments, "")), + dns_resolver_( + LoadConfig(FLAGS_grpc_dns_resolver, overrides.dns_resolver, "")), + trace_(LoadConfig(FLAGS_grpc_trace, overrides.trace, "")), + verbosity_(LoadConfig(FLAGS_grpc_verbosity, overrides.verbosity, + GPR_DEFAULT_LOG_VERBOSITY_STRING)), + stacktrace_minloglevel_(LoadConfig(FLAGS_grpc_stacktrace_minloglevel, + overrides.stacktrace_minloglevel, "")), + poll_strategy_( + LoadConfig(FLAGS_grpc_poll_strategy, overrides.poll_strategy, "all")), + system_ssl_roots_dir_(LoadConfig(FLAGS_grpc_system_ssl_roots_dir, + overrides.system_ssl_roots_dir, "")), + default_ssl_roots_file_path_( + LoadConfig(FLAGS_grpc_default_ssl_roots_file_path, + overrides.default_ssl_roots_file_path, "")), + ssl_cipher_suites_(LoadConfig( + FLAGS_grpc_ssl_cipher_suites, overrides.ssl_cipher_suites, + "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_" + "SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:" + "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384")) {} + +std::string ConfigVars::ToString() const { + return absl::StrCat( + "experiments: ", "\"", absl::CEscape(experiments_), "\"", + ", client_channel_backup_poll_interval_ms: ", + client_channel_backup_poll_interval_ms_, ", dns_resolver: ", "\"", + absl::CEscape(dns_resolver_), "\"", ", trace: ", "\"", + absl::CEscape(trace_), "\"", ", verbosity: ", "\"", + absl::CEscape(verbosity_), "\"", ", stacktrace_minloglevel: ", "\"", + absl::CEscape(stacktrace_minloglevel_), "\"", + ", enable_fork_support: ", enable_fork_support_ ? "true" : "false", + ", poll_strategy: ", "\"", absl::CEscape(poll_strategy_), "\"", + ", abort_on_leaks: ", abort_on_leaks_ ? "true" : "false", + ", system_ssl_roots_dir: ", "\"", absl::CEscape(system_ssl_roots_dir_), + "\"", ", default_ssl_roots_file_path: ", "\"", + absl::CEscape(default_ssl_roots_file_path_), "\"", + ", not_use_system_ssl_roots: ", + not_use_system_ssl_roots_ ? "true" : "false", + ", ssl_cipher_suites: ", "\"", absl::CEscape(ssl_cipher_suites_), "\""); +} + +} // namespace grpc_core diff --git a/src/core/lib/config/config_vars.h b/src/core/lib/config/config_vars.h new file mode 100644 index 00000000000..81c294f98d6 --- /dev/null +++ b/src/core/lib/config/config_vars.h @@ -0,0 +1,129 @@ +// Copyright 2023 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. + +// +// Automatically generated by tools/codegen/core/gen_config_vars.py +// + +#ifndef GRPC_SRC_CORE_LIB_CONFIG_CONFIG_VARS_H +#define GRPC_SRC_CORE_LIB_CONFIG_CONFIG_VARS_H + +#include + +#include + +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" + +namespace grpc_core { + +class ConfigVars { + public: + struct Overrides { + absl::optional client_channel_backup_poll_interval_ms; + absl::optional enable_fork_support; + absl::optional abort_on_leaks; + absl::optional not_use_system_ssl_roots; + absl::optional experiments; + absl::optional dns_resolver; + absl::optional trace; + absl::optional verbosity; + absl::optional stacktrace_minloglevel; + absl::optional poll_strategy; + absl::optional system_ssl_roots_dir; + absl::optional default_ssl_roots_file_path; + absl::optional ssl_cipher_suites; + }; + ConfigVars(const ConfigVars&) = delete; + ConfigVars& operator=(const ConfigVars&) = delete; + // Get the core configuration; if it does not exist, create it. + static const ConfigVars& Get() { + auto* p = config_vars_.load(std::memory_order_acquire); + if (p != nullptr) return *p; + return Load(); + } + static void SetOverrides(const Overrides& overrides); + // Drop the config vars. Users must ensure no other threads are + // accessing the configuration. + static void Reset(); + std::string ToString() const; + // A comma separated list of currently active experiments. Experiments may be + // prefixed with a '-' to disable them. + absl::string_view Experiments() const { return experiments_; } + // Declares the interval in ms between two backup polls on client channels. + // These polls are run in the timer thread so that gRPC can process connection + // failures while there is no active polling thread. They help reconnect + // disconnected client channels (mostly due to idleness), so that the next RPC + // on this channel won't fail. Set to 0 to turn off the backup polls. + int32_t ClientChannelBackupPollIntervalMs() const { + return client_channel_backup_poll_interval_ms_; + } + // Declares which DNS resolver to use. The default is ares if gRPC is built + // with c-ares support. Otherwise, the value of this environment variable is + // ignored. + absl::string_view DnsResolver() const { return dns_resolver_; } + // A comma separated list of tracers that provide additional insight into how + // gRPC C core is processing requests via debug logs. + absl::string_view Trace() const { return trace_; } + // Default gRPC logging verbosity + absl::string_view Verbosity() const { return verbosity_; } + // Messages logged at the same or higher level than this will print stacktrace + absl::string_view StacktraceMinloglevel() const { + return stacktrace_minloglevel_; + } + // Enable fork support + bool EnableForkSupport() const { return enable_fork_support_; } + // Declares which polling engines to try when starting gRPC. This is a + // comma-separated list of engines, which are tried in priority order first -> + // last. + absl::string_view PollStrategy() const { return poll_strategy_; } + // A debugging aid to cause a call to abort() when gRPC objects are leaked + // past grpc_shutdown() + bool AbortOnLeaks() const { return abort_on_leaks_; } + // Custom directory to SSL Roots + absl::string_view SystemSslRootsDir() const { return system_ssl_roots_dir_; } + // Path to the default SSL roots file. + absl::string_view DefaultSslRootsFilePath() const { + return default_ssl_roots_file_path_; + } + // Disable loading system root certificates. + bool NotUseSystemSslRoots() const { return not_use_system_ssl_roots_; } + // A colon separated list of cipher suites to use with OpenSSL + absl::string_view SslCipherSuites() const { return ssl_cipher_suites_; } + + private: + explicit ConfigVars(const Overrides& overrides); + static const ConfigVars& Load(); + static std::atomic config_vars_; + int32_t client_channel_backup_poll_interval_ms_; + bool enable_fork_support_; + bool abort_on_leaks_; + bool not_use_system_ssl_roots_; + std::string experiments_; + std::string dns_resolver_; + std::string trace_; + std::string verbosity_; + std::string stacktrace_minloglevel_; + std::string poll_strategy_; + std::string system_ssl_roots_dir_; + std::string default_ssl_roots_file_path_; + std::string ssl_cipher_suites_; +}; + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_LIB_CONFIG_CONFIG_VARS_H diff --git a/src/core/lib/config/config_vars.yaml b/src/core/lib/config/config_vars.yaml new file mode 100644 index 00000000000..370668be215 --- /dev/null +++ b/src/core/lib/config/config_vars.yaml @@ -0,0 +1,102 @@ +# Copyright 2022 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. + +- name: experiments + type: string + description: + A comma separated list of currently active experiments. Experiments may be + prefixed with a '-' to disable them. + default: +- name: client_channel_backup_poll_interval_ms + type: int + default: 5000 + description: + Declares the interval in ms between two backup polls on client channels. + These polls are run in the timer thread so that gRPC can process + connection failures while there is no active polling thread. + They help reconnect disconnected client channels (mostly due to + idleness), so that the next RPC on this channel won't fail. Set to 0 to + turn off the backup polls. +- name: dns_resolver + default: + type: string + description: + Declares which DNS resolver to use. The default is ares if gRPC is built + with c-ares support. Otherwise, the value of this environment variable is + ignored. +- name: trace + type: string + default: + description: + A comma separated list of tracers that provide additional insight into + how gRPC C core is processing requests via debug logs. +- name: verbosity + type: string + prelude: | + #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING + #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" + #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING + default: $GPR_DEFAULT_LOG_VERBOSITY_STRING + description: + Default gRPC logging verbosity +- name: stacktrace_minloglevel + type: string + default: + description: + Messages logged at the same or higher level than this will print stacktrace +- name: enable_fork_support + type: bool + description: Enable fork support + prelude: | + #ifdef GRPC_ENABLE_FORK_SUPPORT + #define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true + #else + #define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false + #endif // GRPC_ENABLE_FORK_SUPPORT + default: $GRPC_ENABLE_FORK_SUPPORT_DEFAULT +- name: poll_strategy + type: string + description: + Declares which polling engines to try when starting gRPC. + This is a comma-separated list of engines, which are tried in priority + order first -> last. + default: all +- name: abort_on_leaks + type: bool + default: false + description: + A debugging aid to cause a call to abort() when gRPC objects are leaked + past grpc_shutdown() +- name: system_ssl_roots_dir + type: string + default: + description: Custom directory to SSL Roots +- name: default_ssl_roots_file_path + type: string + default: + description: Path to the default SSL roots file. +- name: not_use_system_ssl_roots + type: bool + default: false + description: Disable loading system root certificates. +- name: ssl_cipher_suites + type: string + description: A colon separated list of cipher suites to use with OpenSSL + default: "TLS_AES_128_GCM_SHA256:\ + TLS_AES_256_GCM_SHA384:\ + TLS_CHACHA20_POLY1305_SHA256:\ + ECDHE-ECDSA-AES128-GCM-SHA256:\ + ECDHE-ECDSA-AES256-GCM-SHA384:\ + ECDHE-RSA-AES128-GCM-SHA256:\ + ECDHE-RSA-AES256-GCM-SHA384" diff --git a/src/core/lib/config/config_vars_non_generated.cc b/src/core/lib/config/config_vars_non_generated.cc new file mode 100644 index 00000000000..2261d968680 --- /dev/null +++ b/src/core/lib/config/config_vars_non_generated.cc @@ -0,0 +1,51 @@ +// Copyright 2022 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include + +#include +#include + +#include "src/core/lib/config/config_vars.h" + +namespace grpc_core { + +std::atomic ConfigVars::config_vars_{nullptr}; + +const ConfigVars& ConfigVars::Load() { + // Called from get, so we know there's no existing config vars. + // We might race for them though. + auto vars = new ConfigVars({}); + ConfigVars* expected = nullptr; + if (!config_vars_.compare_exchange_strong(expected, vars, + std::memory_order_acq_rel, + std::memory_order_acquire)) { + delete vars; + return *expected; + } + return *vars; +} + +void ConfigVars::Reset() { + delete config_vars_.exchange(nullptr, std::memory_order_acq_rel); +} + +void ConfigVars::SetOverrides(const Overrides& overrides) { + delete config_vars_.exchange(new ConfigVars(overrides), + std::memory_order_acq_rel); +} + +} // namespace grpc_core diff --git a/src/core/lib/config/load_config.cc b/src/core/lib/config/load_config.cc new file mode 100644 index 00000000000..926d6271115 --- /dev/null +++ b/src/core/lib/config/load_config.cc @@ -0,0 +1,70 @@ +// Copyright 2022 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "src/core/lib/config/load_config.h" + +#include + +#include "absl/flags/marshalling.h" +#include "absl/strings/ascii.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/types/optional.h" + +#include "src/core/lib/gprpp/env.h" + +namespace grpc_core { + +namespace { +std::string EnvironmentVarFromVarName(absl::string_view var_name) { + return absl::StrCat(absl::AsciiStrToUpper(var_name)); +} + +absl::optional LoadEnv(absl::string_view var_name) { + return GetEnv(EnvironmentVarFromVarName(var_name).c_str()); +} +} // namespace + +std::string LoadConfigFromEnv(absl::string_view var_name, + const char* default_value) { + return LoadEnv(var_name).value_or(default_value); +} + +int32_t LoadConfigFromEnv(absl::string_view var_name, int32_t default_value) { + auto env = LoadEnv(var_name); + if (env.has_value()) { + int32_t out; + if (absl::SimpleAtoi(*env, &out)) return out; + fprintf(stderr, "Error reading int from %s: '%s' is not a number", + EnvironmentVarFromVarName(var_name).c_str(), env->c_str()); + } + return default_value; +} + +bool LoadConfigFromEnv(absl::string_view var_name, bool default_value) { + auto env = LoadEnv(var_name); + if (env.has_value()) { + bool out; + std::string error; + if (absl::ParseFlag(env->c_str(), &out, &error)) return out; + fprintf(stderr, "Error reading bool from %s: '%s' is not a bool: %s", + EnvironmentVarFromVarName(var_name).c_str(), env->c_str(), + error.c_str()); + } + return default_value; +} + +} // namespace grpc_core diff --git a/src/core/lib/config/load_config.h b/src/core/lib/config/load_config.h new file mode 100644 index 00000000000..0d376c14690 --- /dev/null +++ b/src/core/lib/config/load_config.h @@ -0,0 +1,46 @@ +// Copyright 2022 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_SRC_CORE_LIB_CONFIG_LOAD_CONFIG_H +#define GRPC_SRC_CORE_LIB_CONFIG_LOAD_CONFIG_H + +#include + +#include + +#include + +#include "absl/flags/flag.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" + +namespace grpc_core { + +std::string LoadConfigFromEnv(absl::string_view var_name, + const char* default_value); +int32_t LoadConfigFromEnv(absl::string_view var_name, int32_t default_value); +bool LoadConfigFromEnv(absl::string_view var_name, bool default_value); + +template +T LoadConfig(const absl::Flag>& flag, + const absl::optional& override, D default_value) { + if (override.has_value()) return *override; + auto from_flag = absl::GetFlag(flag); + if (from_flag.has_value()) return std::move(*from_flag); + return LoadConfigFromEnv(flag.Name(), default_value); +} + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_LIB_CONFIG_LOAD_CONFIG_H diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index 865f026b826..71d427dac6e 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -22,16 +22,16 @@ #include +#include #include +#include "absl/strings/string_view.h" + #include #include #include -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_trace, "", - "A comma separated list of tracers that provide additional insight into " - "how gRPC C core is processing requests via debug logs."); +#include "src/core/lib/config/config_vars.h" int grpc_tracer_set_enabled(const char* name, int enabled); @@ -144,8 +144,7 @@ void grpc_tracer_init(const char* env_var_name) { } void grpc_tracer_init() { - grpc_core::UniquePtr value = GPR_GLOBAL_CONFIG_GET(grpc_trace); - parse(value.get()); + parse(std::string(grpc_core::ConfigVars::Get().Trace()).c_str()); } int grpc_tracer_set_enabled(const char* name, int enabled) { diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 2264653630c..9e7071075f9 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -23,11 +23,6 @@ #include -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" - -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace); - // TODO(veblush): Remove this deprecated function once codes depending on this // function are updated in the internal repo. void grpc_tracer_init(const char* env_var_name); diff --git a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc index b54e1c7b85c..ae014edf6d9 100644 --- a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +++ b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc @@ -40,7 +40,6 @@ #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" #include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/port.h" #ifdef GRPC_POSIX_SOCKET_EV_POLL @@ -58,14 +57,11 @@ #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h" #include "src/core/lib/event_engine/time_util.h" #include "src/core/lib/gprpp/fork.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/gprpp/strerror.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/time.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); - static const intptr_t kClosureNotReady = 0; static const intptr_t kClosureReady = 1; static const int kPollinCheck = POLLIN | POLLHUP | POLLERR; diff --git a/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc b/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc index 3c660dff2af..89853899f91 100644 --- a/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +++ b/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc @@ -17,17 +17,12 @@ #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h" #include "src/core/lib/event_engine/posix_engine/ev_poll_posix.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/port.h" -#ifdef GRPC_POSIX_SOCKET_TCP -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); -#endif - namespace grpc_event_engine { namespace experimental { @@ -41,10 +36,9 @@ bool PollStrategyMatches(absl::string_view strategy, absl::string_view want) { } // namespace PosixEventPoller* MakeDefaultPoller(Scheduler* scheduler) { - static const char* poll_strategy = - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy).release(); PosixEventPoller* poller = nullptr; - auto strings = absl::StrSplit(poll_strategy, ','); + auto strings = + absl::StrSplit(grpc_core::ConfigVars::Get().PollStrategy(), ','); for (auto it = strings.begin(); it != strings.end() && poller == nullptr; it++) { if (PollStrategyMatches(*it, "epoll1")) { diff --git a/src/core/lib/experiments/config.cc b/src/core/lib/experiments/config.cc index 2693cae48b9..d42829b4a1f 100644 --- a/src/core/lib/experiments/config.cc +++ b/src/core/lib/experiments/config.cc @@ -29,17 +29,12 @@ #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/no_destruct.h" #ifndef GRPC_EXPERIMENTS_ARE_FINAL -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_experiments, "", - "List of grpc experiments to enable (or with a '-' prefix to disable)."); - namespace grpc_core { namespace { @@ -66,11 +61,9 @@ GPR_ATTRIBUTE_NOINLINE Experiments LoadExperimentsFromConfigVariable() { experiments.enabled[i] = g_forced_experiments[i].value; } } - // Get the global config. - auto experiments_str = GPR_GLOBAL_CONFIG_GET(grpc_experiments); // For each comma-separated experiment in the global config: - for (auto experiment : - absl::StrSplit(absl::string_view(experiments_str.get()), ',')) { + for (auto experiment : absl::StrSplit( + absl::string_view(ConfigVars::Get().Experiments()), ',')) { // Strip whitespace. experiment = absl::StripAsciiWhitespace(experiment); // Handle ",," without crashing. diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc index d290b95ad0d..25c53f9a5c1 100644 --- a/src/core/lib/gpr/log.cc +++ b/src/core/lib/gpr/log.cc @@ -21,27 +21,21 @@ #include #include +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/gprpp/global_config.h" #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_verbosity, - GPR_DEFAULT_LOG_VERBOSITY_STRING, - "Default gRPC logging verbosity") -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_stacktrace_minloglevel, "", - "Messages logged at the same or higher level " - "than this will print stacktrace") - static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10; static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11; @@ -106,42 +100,35 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { (gpr_atm)min_severity_to_print); } -static gpr_atm parse_log_severity(const char* str, gpr_atm error_value) { - if (gpr_stricmp(str, "DEBUG") == 0) { - return GPR_LOG_SEVERITY_DEBUG; - } else if (gpr_stricmp(str, "INFO") == 0) { - return GPR_LOG_SEVERITY_INFO; - } else if (gpr_stricmp(str, "ERROR") == 0) { - return GPR_LOG_SEVERITY_ERROR; - } else if (gpr_stricmp(str, "NONE") == 0) { - return GPR_LOG_SEVERITY_NONE; - } else { - return error_value; - } +static gpr_atm parse_log_severity(absl::string_view str, gpr_atm error_value) { + if (absl::EqualsIgnoreCase(str, "DEBUG")) return GPR_LOG_SEVERITY_DEBUG; + if (absl::EqualsIgnoreCase(str, "INFO")) return GPR_LOG_SEVERITY_INFO; + if (absl::EqualsIgnoreCase(str, "ERROR")) return GPR_LOG_SEVERITY_ERROR; + if (absl::EqualsIgnoreCase(str, "NONE")) return GPR_LOG_SEVERITY_NONE; + return error_value; } void gpr_log_verbosity_init() { // init verbosity when it hasn't been set if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) == GPR_LOG_SEVERITY_UNSET) { - grpc_core::UniquePtr verbosity = - GPR_GLOBAL_CONFIG_GET(grpc_verbosity); + auto verbosity = grpc_core::ConfigVars::Get().Verbosity(); gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR; - if (strlen(verbosity.get()) > 0) { + if (!verbosity.empty()) { min_severity_to_print = - parse_log_severity(verbosity.get(), min_severity_to_print); + parse_log_severity(verbosity, min_severity_to_print); } gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); } // init stacktrace_minloglevel when it hasn't been set if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) == GPR_LOG_SEVERITY_UNSET) { - grpc_core::UniquePtr stacktrace_minloglevel = - GPR_GLOBAL_CONFIG_GET(grpc_stacktrace_minloglevel); + auto stacktrace_minloglevel = + grpc_core::ConfigVars::Get().StacktraceMinloglevel(); gpr_atm min_severity_to_print_stacktrace = GPR_LOG_SEVERITY_NONE; - if (strlen(stacktrace_minloglevel.get()) > 0) { + if (!stacktrace_minloglevel.empty()) { min_severity_to_print_stacktrace = parse_log_severity( - stacktrace_minloglevel.get(), min_severity_to_print_stacktrace); + stacktrace_minloglevel, min_severity_to_print_stacktrace); } gpr_atm_no_barrier_store(&g_min_severity_to_print_stacktrace, min_severity_to_print_stacktrace); diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index 532f1551334..365c16e36be 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -24,8 +24,8 @@ #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/thread_local.h" -#include "src/core/lib/gprpp/global_config_env.h" #include "src/core/lib/gprpp/no_destruct.h" // @@ -33,16 +33,6 @@ // AROUND VERY SPECIFIC USE CASES. // -#ifdef GRPC_ENABLE_FORK_SUPPORT -#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true -#else -#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false -#endif // GRPC_ENABLE_FORK_SUPPORT - -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support, - GRPC_ENABLE_FORK_SUPPORT_DEFAULT, - "Enable fork support"); - namespace grpc_core { namespace { // The exec_ctx_count has 2 modes, blocked and unblocked. @@ -176,7 +166,7 @@ class ThreadState { void Fork::GlobalInit() { if (!override_enabled_) { - support_enabled_.store(GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support), + support_enabled_.store(ConfigVars::Get().EnableForkSupport(), std::memory_order_relaxed); } } diff --git a/src/core/lib/gprpp/global_config.h b/src/core/lib/gprpp/global_config.h deleted file mode 100644 index 4f2be88d574..00000000000 --- a/src/core/lib/gprpp/global_config.h +++ /dev/null @@ -1,93 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H -#define GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H - -#include - -// -------------------------------------------------------------------- -// How to use global configuration variables: -// -// Defining config variables of a specified type: -// GPR_GLOBAL_CONFIG_DEFINE_*TYPE*(name, default_value, help); -// -// Supported TYPEs: BOOL, INT32, STRING -// -// It's recommended to use lowercase letters for 'name' like -// regular variables. The builtin configuration system uses -// environment variable and the name is converted to uppercase -// when looking up the value. For example, -// GPR_GLOBAL_CONFIG_DEFINE(grpc_latency) looks up the value with the -// name, "GRPC_LATENCY". -// -// The variable initially has the specified 'default_value' -// which must be an expression convertible to 'Type'. -// 'default_value' may be evaluated 0 or more times, -// and at an unspecified time; keep it -// simple and usually free of side-effects. -// -// GPR_GLOBAL_CONFIG_DEFINE_*TYPE* should not be called in a C++ header. -// It should be called at the top-level (outside any namespaces) -// in a .cc file. -// -// Getting the variables: -// GPR_GLOBAL_CONFIG_GET(name) -// -// If error happens during getting variables, error messages will -// be logged and default value will be returned. -// -// Setting the variables with new value: -// GPR_GLOBAL_CONFIG_SET(name, new_value) -// -// Declaring config variables for other modules to access: -// GPR_GLOBAL_CONFIG_DECLARE_*TYPE*(name) -// -// * Caveat for setting global configs at runtime -// -// Setting global configs at runtime multiple times is safe but it doesn't -// mean that it will have a valid effect on the module depending configs. -// In unit tests, it may be unpredictable to set different global configs -// between test cases because grpc init and shutdown can ignore changes. -// It's considered safe to set global configs before the first call to -// grpc_init(). - -// -------------------------------------------------------------------- -// How to customize the global configuration system: -// -// How to read and write configuration value can be customized. -// Builtin system uses environment variables but it can be extended to -// support command-line flag, file, etc. -// -// To customize it, following macros should be redefined. -// -// GPR_GLOBAL_CONFIG_DEFINE_BOOL -// GPR_GLOBAL_CONFIG_DEFINE_INT32 -// GPR_GLOBAL_CONFIG_DEFINE_STRING -// -// These macros should define functions for getting and setting variable. -// For example, GPR_GLOBAL_CONFIG_DEFINE_BOOL(test, ...) would define two -// functions. -// -// bool gpr_global_config_get_test(); -// void gpr_global_config_set_test(bool value); - -#include "src/core/lib/gprpp/global_config_custom.h" // IWYU pragma: export -#include "src/core/lib/gprpp/global_config_env.h" // IWYU pragma: export - -#endif // GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_H diff --git a/src/core/lib/gprpp/global_config_custom.h b/src/core/lib/gprpp/global_config_custom.h deleted file mode 100644 index e1e06e6a19a..00000000000 --- a/src/core/lib/gprpp/global_config_custom.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H -#define GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H - -// This is a placeholder for custom global configuration implementation. -// To use the custom one, please define following macros here. -// -// GPR_GLOBAL_CONFIG_DEFINE_BOOL -// GPR_GLOBAL_CONFIG_DEFINE_INT32 -// GPR_GLOBAL_CONFIG_DEFINE_STRING - -#endif // GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H diff --git a/src/core/lib/gprpp/global_config_env.cc b/src/core/lib/gprpp/global_config_env.cc deleted file mode 100644 index 11dca88a9d9..00000000000 --- a/src/core/lib/gprpp/global_config_env.cc +++ /dev/null @@ -1,140 +0,0 @@ -// -// -// Copyright 2019 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#include - -#include "src/core/lib/gprpp/global_config_env.h" - -#include -#include - -#include -#include -#include -#include - -#include "absl/strings/str_format.h" -#include "absl/types/optional.h" - -#include -#include - -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/env.h" - -namespace grpc_core { - -namespace { - -void DefaultGlobalConfigEnvErrorFunction(const char* error_message) { - gpr_log(GPR_ERROR, "%s", error_message); -} - -GlobalConfigEnvErrorFunctionType g_global_config_env_error_func = - DefaultGlobalConfigEnvErrorFunction; - -void LogParsingError(const char* name, const char* value) { - std::string error_message = absl::StrFormat( - "Illegal value '%s' specified for environment variable '%s'", value, - name); - (*g_global_config_env_error_func)(error_message.c_str()); -} - -} // namespace - -void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func) { - g_global_config_env_error_func = func; -} - -UniquePtr GlobalConfigEnv::GetValue() { - auto env = GetEnv(GetName()); - return UniquePtr(env.has_value() ? gpr_strdup(env.value().c_str()) - : nullptr); -} - -void GlobalConfigEnv::SetValue(const char* value) { SetEnv(GetName(), value); } - -void GlobalConfigEnv::Unset() { UnsetEnv(GetName()); } - -char* GlobalConfigEnv::GetName() { - // This makes sure that name_ is in a canonical form having uppercase - // letters. This is okay to be called serveral times. - for (char* c = name_; *c != 0; ++c) { - *c = toupper(*c); - } - return name_; -} -static_assert(std::is_trivially_destructible::value, - "GlobalConfigEnvBool needs to be trivially destructible."); - -bool GlobalConfigEnvBool::Get() { - UniquePtr str = GetValue(); - if (str == nullptr) { - return default_value_; - } - // parsing given value string. - bool result = false; - if (!gpr_parse_bool_value(str.get(), &result)) { - LogParsingError(GetName(), str.get()); - result = default_value_; - } - return result; -} - -void GlobalConfigEnvBool::Set(bool value) { - SetValue(value ? "true" : "false"); -} - -static_assert(std::is_trivially_destructible::value, - "GlobalConfigEnvInt32 needs to be trivially destructible."); - -int32_t GlobalConfigEnvInt32::Get() { - UniquePtr str = GetValue(); - if (str == nullptr) { - return default_value_; - } - // parsing given value string. - char* end = str.get(); - long result = strtol(str.get(), &end, 10); - if (*end != 0) { - LogParsingError(GetName(), str.get()); - result = default_value_; - } - return static_cast(result); -} - -void GlobalConfigEnvInt32::Set(int32_t value) { - char buffer[GPR_LTOA_MIN_BUFSIZE]; - gpr_ltoa(value, buffer); - SetValue(buffer); -} - -static_assert(std::is_trivially_destructible::value, - "GlobalConfigEnvString needs to be trivially destructible."); - -UniquePtr GlobalConfigEnvString::Get() { - UniquePtr str = GetValue(); - if (str == nullptr) { - return UniquePtr(gpr_strdup(default_value_)); - } - return str; -} - -void GlobalConfigEnvString::Set(const char* value) { SetValue(value); } - -} // namespace grpc_core diff --git a/src/core/lib/gprpp/global_config_env.h b/src/core/lib/gprpp/global_config_env.h deleted file mode 100644 index faa7a6bd442..00000000000 --- a/src/core/lib/gprpp/global_config_env.h +++ /dev/null @@ -1,133 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H -#define GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H - -#include - -#include - -#include "src/core/lib/gprpp/global_config_generic.h" // IWYU pragma: export -#include "src/core/lib/gprpp/memory.h" - -namespace grpc_core { - -typedef void (*GlobalConfigEnvErrorFunctionType)(const char* error_message); - -// -// Set global_config_env_error_function which is called when config system -// encounters errors such as parsing error. What the default function does -// is logging error message. -// -void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func); - -// Base class for all classes to access environment variables. -class GlobalConfigEnv { - protected: - // `name` should be writable and alive after constructor is called. - constexpr explicit GlobalConfigEnv(char* name) : name_(name) {} - - public: - // Returns the value of `name` variable. - UniquePtr GetValue(); - - // Sets the value of `name` variable. - void SetValue(const char* value); - - // Unsets `name` variable. - void Unset(); - - protected: - char* GetName(); - - private: - char* name_; -}; - -class GlobalConfigEnvBool : public GlobalConfigEnv { - public: - constexpr GlobalConfigEnvBool(char* name, bool default_value) - : GlobalConfigEnv(name), default_value_(default_value) {} - - bool Get(); - void Set(bool value); - - private: - bool default_value_; -}; - -class GlobalConfigEnvInt32 : public GlobalConfigEnv { - public: - constexpr GlobalConfigEnvInt32(char* name, int32_t default_value) - : GlobalConfigEnv(name), default_value_(default_value) {} - - int32_t Get(); - void Set(int32_t value); - - private: - int32_t default_value_; -}; - -class GlobalConfigEnvString : public GlobalConfigEnv { - public: - constexpr GlobalConfigEnvString(char* name, const char* default_value) - : GlobalConfigEnv(name), default_value_(default_value) {} - - UniquePtr Get(); - void Set(const char* value); - - private: - const char* default_value_; -}; - -} // namespace grpc_core - -// Macros for defining global config instances using environment variables. -// This defines a GlobalConfig*Type* instance with arguments for -// mutable variable name and default value. -// Mutable name (g_env_str_##name) is here for having an array -// for the canonical name without dynamic allocation. -// `help` argument is ignored for this implementation. - -#define GPR_GLOBAL_CONFIG_DEFINE_BOOL(name, default_value, help) \ - static char g_env_str_##name[] = #name; \ - static ::grpc_core::GlobalConfigEnvBool g_env_##name(g_env_str_##name, \ - default_value); \ - bool gpr_global_config_get_##name() { return g_env_##name.Get(); } \ - void gpr_global_config_set_##name(bool value) { g_env_##name.Set(value); } - -#define GPR_GLOBAL_CONFIG_DEFINE_INT32(name, default_value, help) \ - static char g_env_str_##name[] = #name; \ - static ::grpc_core::GlobalConfigEnvInt32 g_env_##name(g_env_str_##name, \ - default_value); \ - int32_t gpr_global_config_get_##name() { return g_env_##name.Get(); } \ - void gpr_global_config_set_##name(int32_t value) { g_env_##name.Set(value); } - -#define GPR_GLOBAL_CONFIG_DEFINE_STRING(name, default_value, help) \ - static char g_env_str_##name[] = #name; \ - static ::grpc_core::GlobalConfigEnvString g_env_##name(g_env_str_##name, \ - default_value); \ - ::grpc_core::UniquePtr gpr_global_config_get_##name() { \ - return g_env_##name.Get(); \ - } \ - void gpr_global_config_set_##name(const char* value) { \ - g_env_##name.Set(value); \ - } - -#endif // GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_ENV_H diff --git a/src/core/lib/gprpp/global_config_generic.h b/src/core/lib/gprpp/global_config_generic.h deleted file mode 100644 index adebb1c8100..00000000000 --- a/src/core/lib/gprpp/global_config_generic.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H -#define GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H - -#include - -#define GPR_GLOBAL_CONFIG_GET(name) gpr_global_config_get_##name() - -#define GPR_GLOBAL_CONFIG_SET(name, value) gpr_global_config_set_##name(value) - -#define GPR_GLOBAL_CONFIG_DECLARE_BOOL(name) \ - extern bool gpr_global_config_get_##name(); \ - extern void gpr_global_config_set_##name(bool value) - -#define GPR_GLOBAL_CONFIG_DECLARE_INT32(name) \ - extern int32_t gpr_global_config_get_##name(); \ - extern void gpr_global_config_set_##name(int32_t value) - -#define GPR_GLOBAL_CONFIG_DECLARE_STRING(name) \ - extern grpc_core::UniquePtr gpr_global_config_get_##name(); \ - extern void gpr_global_config_set_##name(const char* value) - -#endif // GRPC_SRC_CORE_LIB_GPRPP_GLOBAL_CONFIG_GENERIC_H diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index afa76299700..1c1ca9dc558 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -27,26 +27,21 @@ #include #include "absl/strings/str_format.h" +#include "absl/strings/str_split.h" #include #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/internal_errqueue.h" -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_poll_strategy, "all", - "Declares which polling engines to try when starting gRPC. " - "This is a comma-separated list of engines, which are tried in priority " - "order first -> last.") - grpc_core::DebugOnlyTraceFlag grpc_polling_trace( false, "polling"); // Disabled by default @@ -106,40 +101,14 @@ static const grpc_event_engine_vtable* g_vtables[] = { nullptr, }; -static void add(const char* beg, const char* end, char*** ss, size_t* ns) { - size_t n = *ns; - size_t np = n + 1; - char* s; - size_t len; - GPR_ASSERT(end >= beg); - len = static_cast(end - beg); - s = static_cast(gpr_malloc(len + 1)); - memcpy(s, beg, len); - s[len] = 0; - *ss = static_cast(gpr_realloc(*ss, sizeof(char**) * np)); - (*ss)[n] = s; - *ns = np; -} - -static void split(const char* s, char*** ss, size_t* ns) { - const char* c = strchr(s, ','); - if (c == nullptr) { - add(s, s + strlen(s), ss, ns); - } else { - add(s, c, ss, ns); - split(c + 1, ss, ns); - } -} - -static bool is(const char* want, const char* have) { - return 0 == strcmp(want, "all") || 0 == strcmp(want, have); +static bool is(absl::string_view want, absl::string_view have) { + return want == "all" || want == have; } -static void try_engine(const char* engine) { +static void try_engine(absl::string_view engine) { for (size_t i = 0; i < GPR_ARRAY_SIZE(g_vtables); i++) { if (g_vtables[i] != nullptr && is(engine, g_vtables[i]->name) && - g_vtables[i]->check_engine_available( - 0 == strcmp(engine, g_vtables[i]->name))) { + g_vtables[i]->check_engine_available(engine == g_vtables[i]->name)) { g_event_engine = g_vtables[i]; gpr_log(GPR_DEBUG, "Using polling engine: %s", g_event_engine->name); return; @@ -173,25 +142,16 @@ const char* grpc_get_poll_strategy_name() { return g_event_engine->name; } void grpc_event_engine_init(void) { gpr_once_init(&g_choose_engine, []() { - grpc_core::UniquePtr value = - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - - char** strings = nullptr; - size_t nstrings = 0; - split(value.get(), &strings, &nstrings); - - for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) { - try_engine(strings[i]); - } - - for (size_t i = 0; i < nstrings; i++) { - gpr_free(strings[i]); + auto value = grpc_core::ConfigVars::Get().PollStrategy(); + for (auto trial : absl::StrSplit(value, ',')) { + try_engine(trial); + if (g_event_engine != nullptr) return; } - gpr_free(strings); if (g_event_engine == nullptr) { - grpc_core::Crash(absl::StrFormat( - "No event engine could be initialized from %s", value.get())); + grpc_core::Crash( + absl::StrFormat("No event engine could be initialized from %s", + std::string(value).c_str())); } }); g_event_engine->init_engine(); diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 4e8db6daca3..d7d84879f4c 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -24,14 +24,11 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); - extern grpc_core::DebugOnlyTraceFlag grpc_fd_trace; // Disabled by default extern grpc_core::DebugOnlyTraceFlag grpc_polling_trace; // Disabled by default diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index 08c51cdd653..b6fefdc2b4f 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -29,10 +29,10 @@ #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/buffer_list.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -42,15 +42,10 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer_manager.h" -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false, - "A debugging aid to cause a call to abort() when " - "gRPC objects are leaked past grpc_shutdown()"); - static gpr_mu g_mu; static gpr_cv g_rcv; static int g_shutdown; static grpc_iomgr_object g_root_object; -static bool g_grpc_abort_on_leaks; void grpc_iomgr_init() { grpc_core::ExecCtx exec_ctx; @@ -65,7 +60,6 @@ void grpc_iomgr_init() { g_root_object.name = const_cast("root"); grpc_iomgr_platform_init(); grpc_timer_list_init(); - g_grpc_abort_on_leaks = GPR_GLOBAL_CONFIG_GET(grpc_abort_on_leaks); } void grpc_iomgr_start() { grpc_timer_manager_init(); } @@ -198,4 +192,6 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object* obj) { gpr_free(obj->name); } -bool grpc_iomgr_abort_on_leaks(void) { return g_grpc_abort_on_leaks; } +bool grpc_iomgr_abort_on_leaks(void) { + return grpc_core::ConfigVars::Get().AbortOnLeaks(); +} diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index e134551a3ec..3b732122528 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -20,7 +20,6 @@ #include -#include "src/core/lib/gprpp/global_config_generic.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/port.h" diff --git a/src/core/lib/security/security_connector/load_system_roots_supported.cc b/src/core/lib/security/security_connector/load_system_roots_supported.cc index bb6dc3169b8..870b5710e24 100644 --- a/src/core/lib/security/security_connector/load_system_roots_supported.cc +++ b/src/core/lib/security/security_connector/load_system_roots_supported.cc @@ -19,15 +19,17 @@ #include #include +#include #include +#include "absl/strings/string_view.h" + #if defined(GPR_LINUX) || defined(GPR_ANDROID) || defined(GPR_FREEBSD) || \ defined(GPR_APPLE) #include #include #include -#include #include #include #include @@ -35,17 +37,13 @@ #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/security_connector/load_system_roots.h" #include "src/core/lib/security/security_connector/load_system_roots_supported.h" -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_system_ssl_roots_dir, "", - "Custom directory to SSL Roots"); - namespace grpc_core { namespace { @@ -150,9 +148,9 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) { grpc_slice LoadSystemRootCerts() { grpc_slice result = grpc_empty_slice(); // Prioritize user-specified custom directory if flag is set. - UniquePtr custom_dir = GPR_GLOBAL_CONFIG_GET(grpc_system_ssl_roots_dir); - if (strlen(custom_dir.get()) > 0) { - result = CreateRootCertsBundle(custom_dir.get()); + auto custom_dir = ConfigVars::Get().SystemSslRootsDir(); + if (!custom_dir.empty()) { + result = CreateRootCertsBundle(std::string(custom_dir).c_str()); } // If the custom directory is empty/invalid/not specified, fallback to // distribution-specific directory. diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index 7f88846f2dd..e81cd663aa9 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -32,19 +32,18 @@ #include #include #include +#include #include #include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/security_connector/load_system_roots.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" @@ -76,22 +75,9 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) { static gpr_once cipher_suites_once = GPR_ONCE_INIT; static const char* cipher_suites = nullptr; -// All cipher suites for default are compliant with HTTP2. -GPR_GLOBAL_CONFIG_DEFINE_STRING( - grpc_ssl_cipher_suites, - "TLS_AES_128_GCM_SHA256:" - "TLS_AES_256_GCM_SHA384:" - "TLS_CHACHA20_POLY1305_SHA256:" - "ECDHE-ECDSA-AES128-GCM-SHA256:" - "ECDHE-ECDSA-AES256-GCM-SHA384:" - "ECDHE-RSA-AES128-GCM-SHA256:" - "ECDHE-RSA-AES256-GCM-SHA384", - "A colon separated list of cipher suites to use with OpenSSL") - static void init_cipher_suites(void) { - grpc_core::UniquePtr value = - GPR_GLOBAL_CONFIG_GET(grpc_ssl_cipher_suites); - cipher_suites = value.release(); + cipher_suites = gpr_strdup( + std::string(grpc_core::ConfigVars::Get().SslCipherSuites()).c_str()); } // --- Util --- @@ -573,14 +559,13 @@ const char* DefaultSslRootStore::GetPemRootCerts() { grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); - const bool not_use_system_roots = - GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots); // First try to load the roots from the configuration. - UniquePtr default_root_certs_path = - GPR_GLOBAL_CONFIG_GET(grpc_default_ssl_roots_file_path); - if (strlen(default_root_certs_path.get()) > 0) { + auto default_root_certs_path = ConfigVars::Get().DefaultSslRootsFilePath(); + if (!default_root_certs_path.empty()) { GRPC_LOG_IF_ERROR( - "load_file", grpc_load_file(default_root_certs_path.get(), 1, &result)); + "load_file", + grpc_load_file(std::string(default_root_certs_path).c_str(), 1, + &result)); } // Try overridden roots if needed. grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; @@ -596,7 +581,8 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() { gpr_free(pem_root_certs); } // Try loading roots from OS trust store if flag is enabled. - if (GRPC_SLICE_IS_EMPTY(result) && !not_use_system_roots) { + if (GRPC_SLICE_IS_EMPTY(result) && + !ConfigVars::Get().NotUseSystemSslRoots()) { result = LoadSystemRootCerts(); } // Fallback to roots manually shipped with gRPC. diff --git a/src/core/lib/security/security_connector/ssl_utils_config.cc b/src/core/lib/security/security_connector/ssl_utils_config.cc deleted file mode 100644 index cf0d3811c49..00000000000 --- a/src/core/lib/security/security_connector/ssl_utils_config.cc +++ /dev/null @@ -1,32 +0,0 @@ -// -// -// Copyright 2019 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#include - -#include "src/core/lib/security/security_connector/ssl_utils_config.h" - -/// Config variable that points to the default SSL roots file. This file -/// must be a PEM encoded file with all the roots such as the one that can be -/// downloaded from https://pki.google.com/roots.pem. -GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "", - "Path to the default SSL roots file."); - -/// Config variable used as a flag to enable/disable loading system root -/// certificates from the OS trust store. -GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false, - "Disable loading system root certificates."); diff --git a/src/core/lib/security/security_connector/ssl_utils_config.h b/src/core/lib/security/security_connector/ssl_utils_config.h deleted file mode 100644 index 243a1971731..00000000000 --- a/src/core/lib/security/security_connector/ssl_utils_config.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// -// Copyright 2019 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_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H -#define GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H -#include - -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" - -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path); -GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots); - -#endif // GRPC_SRC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_UTILS_CONFIG_H diff --git a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc index 7c9b3109076..9a3ba475dd1 100644 --- a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +++ b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc @@ -30,6 +30,7 @@ #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/frame_protector/alts_crypter.h" #include "src/core/tsi/alts/frame_protector/frame_handler.h" diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index 2b37358466d..31b0303e917 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -42,7 +42,7 @@ #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" + #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/secure_fixture.h" #include "test/core/util/port.h" diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index ffbe8a88f06..37ee7154a24 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -727,3 +727,8 @@ cdef extern from "grpc/grpc_security_constants.h": ctypedef enum grpc_local_connect_type: UDS LOCAL_TCP + +cdef extern from "src/core/lib/config/config_vars.h" namespace "grpc_core": + cdef cppclass ConfigVars: + @staticmethod + void Reset() diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 05db7e3df9f..281cf8613f0 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -195,3 +195,7 @@ def compression_algorithm_name(grpc_compression_algorithm algorithm): grpc_compression_algorithm_name(algorithm, &name) # Let Cython do the right thing with string casting return name + + +def reset_grpc_config_vars(): + ConfigVars.Reset() diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 83b622e0b38..8e4d7956d1e 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -64,7 +64,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc', - 'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc', @@ -476,7 +475,10 @@ CORE_SOURCE_FILES = [ 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', + 'src/core/lib/config/config_vars.cc', + 'src/core/lib/config/config_vars_non_generated.cc', 'src/core/lib/config/core_configuration.cc', + 'src/core/lib/config/load_config.cc', 'src/core/lib/debug/event_log.cc', 'src/core/lib/debug/histogram_view.cc', 'src/core/lib/debug/stats.cc', @@ -552,7 +554,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gprpp/crash.cc', 'src/core/lib/gprpp/examine_stack.cc', 'src/core/lib/gprpp/fork.cc', - 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/linux/env.cc', 'src/core/lib/gprpp/load_file.cc', @@ -726,7 +727,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/security_connector/security_connector.cc', 'src/core/lib/security/security_connector/ssl/ssl_security_connector.cc', 'src/core/lib/security/security_connector/ssl_utils.cc', - 'src/core/lib/security/security_connector/ssl_utils_config.cc', 'src/core/lib/security/security_connector/tls/tls_security_connector.cc', 'src/core/lib/security/transport/client_auth_filter.cc', 'src/core/lib/security/transport/secure_endpoint.cc', @@ -838,6 +838,15 @@ CORE_SOURCE_FILES = [ 'third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc', 'third_party/abseil-cpp/absl/debugging/stacktrace.cc', 'third_party/abseil-cpp/absl/debugging/symbolize.cc', + 'third_party/abseil-cpp/absl/flags/commandlineflag.cc', + 'third_party/abseil-cpp/absl/flags/flag.cc', + 'third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc', + 'third_party/abseil-cpp/absl/flags/internal/flag.cc', + 'third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc', + 'third_party/abseil-cpp/absl/flags/internal/program_name.cc', + 'third_party/abseil-cpp/absl/flags/marshalling.cc', + 'third_party/abseil-cpp/absl/flags/reflection.cc', + 'third_party/abseil-cpp/absl/flags/usage_config.cc', 'third_party/abseil-cpp/absl/hash/internal/city.cc', 'third_party/abseil-cpp/absl/hash/internal/hash.cc', 'third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc', diff --git a/src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py b/src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py index f0365e15e78..f3e9a71a445 100644 --- a/src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py +++ b/src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py @@ -62,6 +62,7 @@ _BLACK_HOLE = "/test/BlackHole" @contextlib.contextmanager def _env(key: str, value: str): os.environ[key] = value + grpc._cython.cygrpc.reset_grpc_config_vars() yield del os.environ[key] diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index db4f7fc8945..0b313383663 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -31,9 +31,8 @@ #include #include -#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/gprpp/env.h" #include "src/core/lib/gprpp/host_port.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -137,7 +136,7 @@ int main(int argc, char** argv) { strcpy(root, "."); } if (argc == 2) { - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, argv[1]); + grpc_core::SetEnv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", argv[1]); } // figure out our test name tmp = lunder - 1; diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 9ce8034e535..735370b96c2 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -27,13 +27,10 @@ #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/event_engine/default_event_engine.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/work_serializer.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -101,9 +98,7 @@ TEST(DnsResolverTest, MainTest) { test_succeeds(dns, "dns:10.2.1.1:1234"); test_succeeds(dns, "dns:www.google.com"); test_succeeds(dns, "dns:///www.google.com"); - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (gpr_stricmp(resolver.get(), "native") == 0) { + if (grpc_core::ConfigVars::Get().DnsResolver() == "native") { test_fails(dns, "dns://8.8.8.8/8.8.8.8:8888"); } else { test_succeeds(dns, "dns://8.8.8.8/8.8.8.8:8888"); diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index ea1fc432ae4..3438295a4df 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -276,6 +276,7 @@ grpc_cc_test( "h2_ssl_cert_test.cc", ], external_deps = [ + "absl/types:optional", "gtest", "libcrypto", ], @@ -284,11 +285,11 @@ grpc_cc_test( "cq_verifier", "fixture_support", "ssl_test_data", + "//:config_vars", "//:gpr", "//:grpc", "//:grpc_public_hdrs", "//:grpc_security_base", - "//:tsi_ssl_credentials", "//src/core:channel_args", "//test/core/util:grpc_test_util", ], @@ -304,15 +305,18 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], - external_deps = ["gtest"], + external_deps = [ + "absl/types:optional", + "gtest", + ], language = "C++", deps = [ "cq_verifier", + "//:config_vars", "//:exec_ctx", "//:gpr", "//:grpc", "//:grpc_public_hdrs", - "//:tsi_ssl_credentials", "//src/core:channel_args", "//src/core:error", "//src/core:useful", @@ -330,15 +334,18 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], - external_deps = ["gtest"], + external_deps = [ + "absl/types:optional", + "gtest", + ], language = "C++", deps = [ "cq_verifier", + "//:config_vars", "//:exec_ctx", "//:gpr", "//:grpc", "//:grpc_public_hdrs", - "//:tsi_ssl_credentials", "//src/core:channel_args", "//src/core:error", "//src/core:useful", diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index e6c2d891ed2..8c37b7ae2f3 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -18,6 +18,8 @@ #include +#include "absl/types/optional.h" + #include #include "src/core/lib/channel/channel_args.h" @@ -29,11 +31,11 @@ #include #include +#include #include -#include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/secure_fixture.h" #include "test/core/util/test_config.h" @@ -56,7 +58,9 @@ int main(int argc, char** argv) { // force tracing on, with a value to force many // code paths in trace.c to be taken - GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); + grpc_core::ConfigVars::Overrides overrides; + overrides.trace = "doesnt-exist,http,all"; + grpc_core::ConfigVars::SetOverrides(overrides); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index bab337100ed..5180b79deaf 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -18,13 +18,15 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/iomgr/port.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/sockpair_fixture.h" @@ -46,8 +48,10 @@ int main(int argc, char** argv) { size_t i; // force tracing on, with a value to force many - // code paths in trace.c to be taken - GPR_GLOBAL_CONFIG_SET(grpc_trace, "doesnt-exist,http,all"); + // code paths in trace.cc to be taken + grpc_core::ConfigVars::Overrides overrides; + overrides.trace = "doesnt-exist,http,all"; + grpc_core::ConfigVars::SetOverrides(overrides); #ifdef GRPC_POSIX_SOCKET g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload_tls12.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload_tls12.cc index 8f8defb6888..9e9bb87bcdf 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload_tls12.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload_tls12.cc @@ -20,13 +20,15 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h" #include "test/core/util/test_config.h" @@ -50,8 +52,9 @@ int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - SslCredReloadFixture::CaCertPath()); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = SslCredReloadFixture::CaCertPath(); + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload_tls13.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload_tls13.cc index 572d467b17e..d2ee2ba7f3d 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload_tls13.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload_tls13.cc @@ -20,13 +20,15 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h" #include "test/core/util/test_config.h" @@ -50,8 +52,9 @@ int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - SslCredReloadFixture::CaCertPath()); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = SslCredReloadFixture::CaCertPath(); + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index 28514ae3dd3..b7a3866ef9b 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -20,6 +20,9 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include @@ -28,11 +31,10 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/load_file.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/proxy.h" #include "test/core/util/test_config.h" @@ -169,7 +171,10 @@ int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_tls12.cc b/test/core/end2end/fixtures/h2_ssl_tls12.cc index a50661aa557..252c3145f85 100644 --- a/test/core/end2end/fixtures/h2_ssl_tls12.cc +++ b/test/core/end2end/fixtures/h2_ssl_tls12.cc @@ -20,13 +20,15 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_ssl_tls_common.h" #include "test/core/util/test_config.h" @@ -48,8 +50,9 @@ int main(int argc, char** argv) { size_t i; grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - SslTlsFixture::CaCertPath()); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = SslTlsFixture::CaCertPath(); + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_tls13.cc b/test/core/end2end/fixtures/h2_ssl_tls13.cc index a68b2b81501..73d4793d524 100644 --- a/test/core/end2end/fixtures/h2_ssl_tls13.cc +++ b/test/core/end2end/fixtures/h2_ssl_tls13.cc @@ -20,13 +20,15 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_ssl_tls_common.h" #include "test/core/util/test_config.h" @@ -48,8 +50,9 @@ int main(int argc, char** argv) { size_t i; grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - SslTlsFixture::CaCertPath()); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = SslTlsFixture::CaCertPath(); + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); diff --git a/test/core/end2end/fixtures/h2_tls_certwatch_async_tls1_3.cc b/test/core/end2end/fixtures/h2_tls_certwatch_async_tls1_3.cc index f3065ae3b8a..feb6e196d6d 100644 --- a/test/core/end2end/fixtures/h2_tls_certwatch_async_tls1_3.cc +++ b/test/core/end2end/fixtures/h2_tls_certwatch_async_tls1_3.cc @@ -18,12 +18,14 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_tls_common.h" #include "test/core/util/test_config.h" @@ -46,7 +48,9 @@ static CoreTestConfiguration config = { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); grpc_end2end_tests(argc, argv, config); grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_tls_certwatch_sync_tls1_2.cc b/test/core/end2end/fixtures/h2_tls_certwatch_sync_tls1_2.cc index e96e67e195c..e35dc1aa332 100644 --- a/test/core/end2end/fixtures/h2_tls_certwatch_sync_tls1_2.cc +++ b/test/core/end2end/fixtures/h2_tls_certwatch_sync_tls1_2.cc @@ -18,12 +18,14 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_tls_common.h" #include "test/core/util/test_config.h" @@ -46,7 +48,9 @@ static CoreTestConfiguration config = { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); grpc_end2end_tests(argc, argv, config); grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_tls_simple.cc b/test/core/end2end/fixtures/h2_tls_simple.cc index a6906c48b02..0298fa10042 100644 --- a/test/core/end2end/fixtures/h2_tls_simple.cc +++ b/test/core/end2end/fixtures/h2_tls_simple.cc @@ -18,12 +18,14 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_tls_common.h" #include "test/core/util/test_config.h" @@ -46,7 +48,9 @@ static CoreTestConfiguration config = { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); grpc_end2end_tests(argc, argv, config); grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_tls_static_async_tls1_3.cc b/test/core/end2end/fixtures/h2_tls_static_async_tls1_3.cc index b9e4a9da8b5..a3f12e06130 100644 --- a/test/core/end2end/fixtures/h2_tls_static_async_tls1_3.cc +++ b/test/core/end2end/fixtures/h2_tls_static_async_tls1_3.cc @@ -18,12 +18,14 @@ #include #include +#include + +#include "absl/types/optional.h" #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/end2end/fixtures/h2_tls_common.h" #include "test/core/util/test_config.h" @@ -46,7 +48,9 @@ static CoreTestConfiguration config = { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc_end2end_tests_pre_init(); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); grpc_end2end_tests(argc, argv, config); grpc_shutdown(); diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 081d4c2f6df..de3bcc9cf1d 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -25,6 +25,7 @@ #include +#include "absl/types/optional.h" #include "gtest/gtest.h" #include @@ -38,9 +39,8 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/tmpfile.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/end2end_tests.h" @@ -276,7 +276,9 @@ int main(int argc, char** argv) { GPR_ASSERT(roots_file != nullptr); GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); fclose(roots_file); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename); + grpc_core::ConfigVars::Overrides config_overrides; + config_overrides.default_ssl_roots_file_path = roots_filename; + grpc_core::ConfigVars::SetOverrides(config_overrides); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 0f9784ef489..1aac4dfd8ff 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -22,6 +22,8 @@ #include +#include "absl/types/optional.h" + #include #include #include @@ -32,13 +34,12 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config_generic.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/load_file.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -291,7 +292,9 @@ TEST(H2SessionReuseTest, SingleReuse) { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc index 35d1877c263..1a367aa9b3b 100644 --- a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc +++ b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc @@ -22,6 +22,8 @@ #include +#include "absl/types/optional.h" + #include #include #include @@ -32,13 +34,12 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config_generic.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/load_file.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -323,8 +324,9 @@ TEST(H2TlsPeerPropertyExternalVerifier, PeerPropertyExternalVerifierTest) { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); - + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 905bf5c5f32..278fbd86409 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -21,6 +21,8 @@ #include #include +#include "absl/strings/string_view.h" + #include #include #include @@ -31,18 +33,13 @@ #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/port.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/end2end_tests.h" #include "test/core/util/test_config.h" -#ifdef GRPC_POSIX_SOCKET -#include "src/core/lib/iomgr/ev_posix.h" -#endif // GRPC_POSIX_SOCKET - static std::unique_ptr begin_test( const CoreTestConfiguration& config, const char* test_name, grpc_channel_args* client_args, grpc_channel_args* server_args) { @@ -132,11 +129,8 @@ static void test_keepalive_timeout(const CoreTestConfiguration& config) { // that the keepalive ping is never sent. static void test_read_delays_keepalive(const CoreTestConfiguration& config) { #ifdef GRPC_POSIX_SOCKET - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - // It is hard to get the timing right for the polling engine poll. - if ((0 == strcmp(poller.get(), "poll"))) { - return; - } + /* It is hard to get the timing right for the polling engine poll. */ + if (grpc_core::ConfigVars::Get().PollStrategy() == "poll") return; #endif // GRPC_POSIX_SOCKET const int kPingIntervalMS = 100; grpc_arg keepalive_arg_elems[3]; diff --git a/test/core/event_engine/posix/event_poller_posix_test.cc b/test/core/event_engine/posix/event_poller_posix_test.cc index f28b374306a..15700abb121 100644 --- a/test/core/event_engine/posix/event_poller_posix_test.cc +++ b/test/core/event_engine/posix/event_poller_posix_test.cc @@ -33,10 +33,10 @@ #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/port.h" @@ -67,14 +67,11 @@ #include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/dual_ref_counted.h" -#include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/gprpp/notification.h" #include "src/core/lib/gprpp/strerror.h" #include "test/core/event_engine/posix/posix_engine_test_utils.h" #include "test/core/util/port.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); - static gpr_mu g_mu; static grpc_event_engine::experimental::PosixEventPoller* g_event_poller = nullptr; @@ -713,10 +710,8 @@ TEST_F(EventPollerTest, TestMultipleHandles) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); gpr_mu_init(&g_mu); - grpc_core::UniquePtr poll_strategy = - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - auto strings = absl::StrSplit(poll_strategy.get(), ','); + auto poll_strategy = grpc_core::ConfigVars::Get().PollStrategy(); + auto strings = absl::StrSplit(poll_strategy, ','); if (std::find(strings.begin(), strings.end(), "none") != strings.end()) { // Skip the test entirely if poll strategy is none. return 0; diff --git a/test/core/event_engine/posix/posix_endpoint_test.cc b/test/core/event_engine/posix/posix_endpoint_test.cc index a2f5ce380c5..265b3c9ddcb 100644 --- a/test/core/event_engine/posix/posix_endpoint_test.cc +++ b/test/core/event_engine/posix/posix_endpoint_test.cc @@ -34,6 +34,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" @@ -43,8 +44,6 @@ #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/gprpp/dual_ref_counted.h" -#include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/notification.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/resource_quota/resource_quota.h" @@ -53,8 +52,6 @@ #include "test/core/event_engine/test_suite/posix/oracle_event_engine_posix.h" #include "test/core/util/port.h" -GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); - namespace grpc_event_engine { namespace experimental { @@ -335,10 +332,8 @@ INSTANTIATE_TEST_SUITE_P(PosixEndpoint, PosixEndpointTest, int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - grpc_core::UniquePtr poll_strategy = - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - auto strings = absl::StrSplit(poll_strategy.get(), ','); + auto poll_strategy = grpc_core::ConfigVars::Get().PollStrategy(); + auto strings = absl::StrSplit(poll_strategy, ','); if (std::find(strings.begin(), strings.end(), "none") != strings.end()) { // Skip the test entirely if poll strategy is none. return 0; diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index a9eedbcee9e..0b377b56c9e 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -54,37 +54,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "global_config_test", - srcs = ["global_config_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - uses_event_engine = False, - uses_polling = False, - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( - name = "global_config_env_test", - srcs = ["global_config_env_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - tags = ["no_windows"], # TODO(jtattermusch): fix the failure on windows - uses_event_engine = False, - uses_polling = False, - deps = [ - "//:gpr", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "bitset_test", srcs = ["bitset_test.cc"], diff --git a/test/core/gprpp/global_config_env_test.cc b/test/core/gprpp/global_config_env_test.cc deleted file mode 100644 index 917457edf13..00000000000 --- a/test/core/gprpp/global_config_env_test.cc +++ /dev/null @@ -1,127 +0,0 @@ -// -// -// Copyright 2019 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#include "src/core/lib/gprpp/global_config_env.h" - -#include - -#include "gtest/gtest.h" - -#include "src/core/lib/gprpp/env.h" -#include "src/core/lib/gprpp/memory.h" - -namespace { - -bool g_config_error_function_called; - -void ClearConfigErrorCalled() { g_config_error_function_called = false; } - -bool IsConfigErrorCalled() { return g_config_error_function_called; } - -// This function is for preventing the program from invoking -// an error handler due to configuration error and -// make test routines know whether there is error. -void FakeConfigErrorFunction(const char* /*error_message*/) { - g_config_error_function_called = true; -} - -class GlobalConfigEnvTest : public ::testing::Test { - protected: - void SetUp() override { ClearConfigErrorCalled(); } - void TearDown() override { EXPECT_FALSE(IsConfigErrorCalled()); } -}; - -} // namespace - -GPR_GLOBAL_CONFIG_DEFINE_BOOL(bool_var, true, ""); -GPR_GLOBAL_CONFIG_DEFINE_INT32(int32_var, 1234, ""); -GPR_GLOBAL_CONFIG_DEFINE_STRING(string_var, "Apple", ""); - -TEST_F(GlobalConfigEnvTest, BoolWithEnvTest) { - const char* bool_var_name = "BOOL_VAR"; - - grpc_core::UnsetEnv(bool_var_name); - EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); - - grpc_core::SetEnv(bool_var_name, "true"); - EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); - - grpc_core::SetEnv(bool_var_name, "false"); - EXPECT_FALSE(GPR_GLOBAL_CONFIG_GET(bool_var)); - - EXPECT_FALSE(IsConfigErrorCalled()); - - grpc_core::SetEnv(bool_var_name, ""); - GPR_GLOBAL_CONFIG_GET(bool_var); - EXPECT_TRUE(IsConfigErrorCalled()); - ClearConfigErrorCalled(); - - grpc_core::SetEnv(bool_var_name, "!"); - GPR_GLOBAL_CONFIG_GET(bool_var); - EXPECT_TRUE(IsConfigErrorCalled()); - ClearConfigErrorCalled(); -} - -TEST_F(GlobalConfigEnvTest, Int32WithEnvTest) { - const char* int32_var_name = "INT32_VAR"; - - grpc_core::UnsetEnv(int32_var_name); - EXPECT_EQ(1234, GPR_GLOBAL_CONFIG_GET(int32_var)); - - grpc_core::SetEnv(int32_var_name, "0"); - EXPECT_EQ(0, GPR_GLOBAL_CONFIG_GET(int32_var)); - - grpc_core::SetEnv(int32_var_name, "-123456789"); - EXPECT_EQ(-123456789, GPR_GLOBAL_CONFIG_GET(int32_var)); - - grpc_core::SetEnv(int32_var_name, "123456789"); - EXPECT_EQ(123456789, GPR_GLOBAL_CONFIG_GET(int32_var)); - - EXPECT_FALSE(IsConfigErrorCalled()); - - grpc_core::SetEnv(int32_var_name, "-1AB"); - GPR_GLOBAL_CONFIG_GET(int32_var); - EXPECT_TRUE(IsConfigErrorCalled()); - ClearConfigErrorCalled(); -} - -TEST_F(GlobalConfigEnvTest, StringWithEnvTest) { - const char* string_var_name = "STRING_VAR"; - grpc_core::UniquePtr value; - - grpc_core::UnsetEnv(string_var_name); - value = GPR_GLOBAL_CONFIG_GET(string_var); - EXPECT_EQ(0, strcmp(value.get(), "Apple")); - - grpc_core::SetEnv(string_var_name, "Banana"); - value = GPR_GLOBAL_CONFIG_GET(string_var); - EXPECT_EQ(0, strcmp(value.get(), "Banana")); - - grpc_core::SetEnv(string_var_name, ""); - value = GPR_GLOBAL_CONFIG_GET(string_var); - EXPECT_EQ(0, strcmp(value.get(), "")); -} - -int main(int argc, char** argv) { - // Not to abort the test when parsing error happens. - grpc_core::SetGlobalConfigEnvErrorFunction(&FakeConfigErrorFunction); - - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/test/core/gprpp/global_config_test.cc b/test/core/gprpp/global_config_test.cc deleted file mode 100644 index 26e2a20413a..00000000000 --- a/test/core/gprpp/global_config_test.cc +++ /dev/null @@ -1,61 +0,0 @@ -// -// -// Copyright 2019 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -#include "src/core/lib/gprpp/global_config.h" - -#include - -#include "gtest/gtest.h" - -#include "src/core/lib/gprpp/memory.h" - -GPR_GLOBAL_CONFIG_DECLARE_BOOL(bool_var); - -GPR_GLOBAL_CONFIG_DEFINE_BOOL(bool_var, false, ""); -GPR_GLOBAL_CONFIG_DEFINE_INT32(int32_var, 0, ""); -GPR_GLOBAL_CONFIG_DEFINE_STRING(string_var, "", ""); - -TEST(GlobalConfigTest, BoolTest) { - EXPECT_FALSE(GPR_GLOBAL_CONFIG_GET(bool_var)); - GPR_GLOBAL_CONFIG_SET(bool_var, true); - EXPECT_TRUE(GPR_GLOBAL_CONFIG_GET(bool_var)); -} - -TEST(GlobalConfigTest, Int32Test) { - EXPECT_EQ(0, GPR_GLOBAL_CONFIG_GET(int32_var)); - GPR_GLOBAL_CONFIG_SET(int32_var, 1024); - EXPECT_EQ(1024, GPR_GLOBAL_CONFIG_GET(int32_var)); -} - -TEST(GlobalConfigTest, StringTest) { - grpc_core::UniquePtr value; - - value = GPR_GLOBAL_CONFIG_GET(string_var); - EXPECT_EQ(0, strcmp(value.get(), "")); - - GPR_GLOBAL_CONFIG_SET(string_var, "Test"); - - value = GPR_GLOBAL_CONFIG_GET(string_var); - EXPECT_EQ(0, strcmp(value.get(), "Test")); -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/test/core/http/httpcli_test_util.cc b/test/core/http/httpcli_test_util.cc index 5a40521f2ed..763413cc373 100644 --- a/test/core/http/httpcli_test_util.cc +++ b/test/core/http/httpcli_test_util.cc @@ -20,15 +20,18 @@ #include +#include #include +#include "absl/strings/str_cat.h" +#include "absl/types/optional.h" + #include #include #include #include -#include "src/core/lib/gprpp/global_config_generic.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/util/port.h" #include "test/core/util/subprocess.h" @@ -77,10 +80,10 @@ HttpRequestTestServer StartHttpRequestTestServer(int argc, char** argv, if (use_ssl) { args.push_back(gpr_strdup("--ssl")); // Set the environment variable for the SSL certificate file - char* pem_file; - gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, pem_file); - gpr_free(pem_file); + ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = + absl::StrCat(root, "/src/core/tsi/test_creds/ca.pem"); + ConfigVars::SetOverrides(overrides); } gpr_log(GPR_INFO, "starting HttpRequest test server subprocess:"); for (size_t i = 0; i < args.size(); i++) { diff --git a/test/core/iomgr/buffer_list_test.cc b/test/core/iomgr/buffer_list_test.cc index 14bca99661b..2396ec5ac15 100644 --- a/test/core/iomgr/buffer_list_test.cc +++ b/test/core/iomgr/buffer_list_test.cc @@ -24,7 +24,6 @@ #include #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/global_config_generic.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/internal_errqueue.h" diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index 40e100ca93d..3db885ffeb1 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -34,7 +34,7 @@ #include #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" @@ -188,30 +188,21 @@ TEST(ResolveAddressUsingAresResolverPosixTest, MainTest) { // In case that there are more than one argument on the command line, // --resolver will always be the first one, so only parse the first argument // (other arguments may be unknown to cl) - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (strlen(resolver.get()) != 0) { - gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", - resolver.get()); - } + grpc_core::ConfigVars::Overrides overrides; if (resolver_type == "native") { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "native"); + overrides.dns_resolver = "native"; } else if (resolver_type == "ares") { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + overrides.dns_resolver = "ares"; } else { gpr_log(GPR_ERROR, "--resolver was not set to ares or native"); ASSERT_TRUE(false); } + grpc_core::ConfigVars::SetOverrides(overrides); grpc_init(); { grpc_core::ExecCtx exec_ctx; test_named_and_numeric_scope_ids(); - // c-ares resolver doesn't support UDS (ability for native DNS resolver - // to handle this is only expected to be used by servers, which - // unconditionally use the native DNS resolver). - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); } grpc_shutdown(); } diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index befd3b0b9b8..2e32d903bd4 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -34,7 +34,7 @@ #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/sync.h" @@ -548,7 +548,9 @@ int main(int argc, char** argv) { } else { GPR_ASSERT(0); } - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, g_resolver_type); + grpc_core::ConfigVars::Overrides overrides; + overrides.dns_resolver = g_resolver_type; + grpc_core::ConfigVars::SetOverrides(overrides); ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(&argc, argv); const auto result = RUN_ALL_TESTS(); diff --git a/test/core/security/grpc_tls_credentials_options_test.cc b/test/core/security/grpc_tls_credentials_options_test.cc index 4908f85ffc5..3ab8ca671ee 100644 --- a/test/core/security/grpc_tls_credentials_options_test.cc +++ b/test/core/security/grpc_tls_credentials_options_test.cc @@ -25,11 +25,11 @@ #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/tls/tls_credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/lib/security/security_connector/tls/tls_security_connector.h" #include "test/core/util/test_config.h" #include "test/core/util/tls_utils.h" @@ -568,7 +568,9 @@ TEST_F(GrpcTlsCredentialsOptionsTest, int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); ::testing::InitGoogleTest(&argc, argv); grpc_init(); int ret = RUN_ALL_TESTS(); diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index 247445018f3..e7e5d47aa5a 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -28,13 +28,13 @@ #include #include +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/security_connector/ssl_utils.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" @@ -664,9 +664,12 @@ static void test_default_ssl_roots(void) { fwrite(roots_for_env_var, 1, strlen(roots_for_env_var), roots_env_var_file); fclose(roots_env_var_file); - // First let's get the root through the override: set the env to an invalid - // value. - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); + grpc_core::ConfigVars::Overrides overrides; + + // First let's get the root through the override: override the config to an + // invalid value. + overrides.default_ssl_roots_file_path = ""; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); @@ -675,19 +678,21 @@ static void test_default_ssl_roots(void) { ASSERT_STREQ(roots_contents, roots_for_override_api); gpr_free(roots_contents); - // Now let's set the env var: We should get the contents pointed value - // instead. - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, - roots_env_var_file_path); + // Now let's set the config: We should get the contents pointed value + // instead + overrides.default_ssl_roots_file_path = roots_env_var_file_path; + grpc_core::ConfigVars::SetOverrides(overrides); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); ASSERT_STREQ(roots_contents, roots_for_env_var); gpr_free(roots_contents); - // Now reset the env var. We should fall back to the value overridden using + // Now reset the config. We should fall back to the value overridden using // the api. - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, ""); + overrides.default_ssl_roots_file_path = ""; + grpc_core::ConfigVars::SetOverrides(overrides); + grpc_set_ssl_roots_override_callback(override_roots_success); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); @@ -696,7 +701,8 @@ static void test_default_ssl_roots(void) { // Now setup a permanent failure for the overridden roots and we should get // an empty slice. - GPR_GLOBAL_CONFIG_SET(grpc_not_use_system_ssl_roots, true); + overrides.not_use_system_ssl_roots = true; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting(); ASSERT_TRUE(GRPC_SLICE_IS_EMPTY(roots)); diff --git a/test/core/security/tls_security_connector_test.cc b/test/core/security/tls_security_connector_test.cc index f4cce75e25e..6323fe2bc09 100644 --- a/test/core/security/tls_security_connector_test.cc +++ b/test/core/security/tls_security_connector_test.cc @@ -29,6 +29,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/iomgr/load_file.h" @@ -36,7 +37,6 @@ #include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h" #include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h" #include "src/core/lib/security/credentials/tls/tls_credentials.h" -#include "src/core/lib/security/security_connector/ssl_utils_config.h" #include "src/core/tsi/transport_security.h" #include "test/core/util/test_config.h" #include "test/core/util/tls_utils.h" @@ -1169,7 +1169,9 @@ TEST_F(TlsSecurityConnectorTest, int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); - GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, CA_CERT_PATH); + grpc_core::ConfigVars::Overrides overrides; + overrides.default_ssl_roots_file_path = CA_CERT_PATH; + grpc_core::ConfigVars::SetOverrides(overrides); ::testing::InitGoogleTest(&argc, argv); grpc_init(); int ret = RUN_ALL_TESTS(); diff --git a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc index 3ecf4227bad..b1fc3b3a4f2 100644 --- a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc +++ b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc @@ -29,6 +29,8 @@ #include +#include "absl/types/optional.h" + #include #include #include @@ -38,10 +40,9 @@ #include #include -#include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/global_config_generic.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/sync.h" #include "test/core/util/port.h" @@ -355,7 +356,9 @@ int main(int argc, char** argv) { // Make sure that we will have an active poller on all client-side fd's that // are capable of sending settings frames with window updates etc., even in // the case that we don't have an active RPC operation on the fd. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_core::chttp2::g_test_only_transport_target_window_estimates_mocker = new TransportTargetWindowEstimatesMocker(); grpc::testing::TestEnvironment env(&argc, argv); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index e508fd721b2..76682e93a33 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -37,6 +37,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/iomgr/port.h" @@ -447,8 +448,7 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { #ifdef GRPC_POSIX_SOCKET_EV // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { + if (grpc_core::ConfigVars::Get().PollStrategy() == "poll") { poller_slowdown_factor = 2; } #endif // GRPC_POSIX_SOCKET_EV @@ -1971,7 +1971,9 @@ INSTANTIATE_TEST_SUITE_P(AsyncEnd2endServerTryCancel, int main(int argc, char** argv) { // Change the backup poll interval from 5s to 100ms to speed up the // ReconnectChannel test - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 100); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 100; + grpc_core::ConfigVars::SetOverrides(overrides); grpc::testing::TestEnvironment env(&argc, argv); ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index c11793d734a..67bfd88be7b 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -55,6 +55,7 @@ #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/env.h" @@ -3061,14 +3062,16 @@ TEST_P(WeightedRoundRobinParamTest, Basic) { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); + grpc::testing::TestEnvironment env(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); #endif - grpc::testing::TestEnvironment env(&argc, argv); grpc_init(); grpc::testing::ConnectionAttemptInjector::Init(); const auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c856e146d9c..6749a5c0a8e 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -42,6 +42,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/env.h" #include "src/core/lib/iomgr/iomgr.h" @@ -909,8 +910,7 @@ TEST_P(End2endTest, ReconnectChannel) { // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" #ifdef GRPC_POSIX_SOCKET_EV - grpc_core::UniquePtr poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy); - if (0 == strcmp(poller.get(), "poll")) { + if (grpc_core::ConfigVars::Get().PollStrategy() == "poll") { poller_slowdown_factor = 2; } #endif // GRPC_POSIX_SOCKET_EV @@ -2246,8 +2246,10 @@ std::vector CreateTestScenarios(bool use_proxy, std::vector scenarios; std::vector credentials_types; - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, - kClientChannelBackupPollIntervalMs); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = + kClientChannelBackupPollIntervalMs; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 9a0b86d833e..1dd9681e4cb 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -46,6 +46,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/env.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -375,7 +376,9 @@ class GrpclbEnd2endTest : public ::testing::Test { static void SetUpTestSuite() { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/rls_end2end_test.cc b/test/cpp/end2end/rls_end2end_test.cc index c6045c2bb65..e75f021f0d2 100644 --- a/test/cpp/end2end/rls_end2end_test.cc +++ b/test/cpp/end2end/rls_end2end_test.cc @@ -43,6 +43,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/env.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/gprpp/time.h" @@ -158,7 +159,9 @@ class FakeResolverResponseGeneratorWrapper { class RlsEnd2endTest : public ::testing::Test { protected: static void SetUpTestSuite() { - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); grpc_core::CoreConfiguration::RegisterBuilder( grpc_core::RegisterFixedAddressLoadBalancingPolicy); grpc_init(); diff --git a/test/cpp/end2end/server_load_reporting_end2end_test.cc b/test/cpp/end2end/server_load_reporting_end2end_test.cc index cd8d3477c73..77d58702717 100644 --- a/test/cpp/end2end/server_load_reporting_end2end_test.cc +++ b/test/cpp/end2end/server_load_reporting_end2end_test.cc @@ -31,6 +31,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/proto/grpc/lb/v1/load_reporter.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -203,6 +204,8 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides config_overrides; + config_overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(config_overrides); return RUN_ALL_TESTS(); } diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index e4bd5d30bc8..8f6dde14b40 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -50,6 +50,7 @@ #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -124,7 +125,9 @@ class ServiceConfigEnd2endTest : public ::testing::Test { static void SetUpTestSuite() { // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); } void SetUp() override { diff --git a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc index 005f41d190d..461824a4488 100644 --- a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc @@ -25,6 +25,7 @@ #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/lib/config/config_vars.h" #include "test/cpp/end2end/connection_attempt_injector.h" #include "test/cpp/end2end/xds/xds_end2end_test_lib.h" @@ -1726,7 +1727,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_cluster_type_end2end_test.cc b/test/cpp/end2end/xds/xds_cluster_type_end2end_test.cc index 5eaf8e71c3c..b67cfb756dd 100644 --- a/test/cpp/end2end/xds/xds_cluster_type_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_cluster_type_end2end_test.cc @@ -27,6 +27,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/env.h" #include "src/core/lib/resolver/server_address.h" #include "src/proto/grpc/testing/xds/v3/aggregate_cluster.grpc.pb.h" @@ -663,7 +664,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_core_end2end_test.cc b/test/cpp/end2end/xds/xds_core_end2end_test.cc index b496a3c422a..0ccbca39f12 100644 --- a/test/cpp/end2end/xds/xds_core_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_core_end2end_test.cc @@ -23,6 +23,7 @@ #include "absl/strings/str_cat.h" #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "test/core/util/scoped_env_var.h" #include "test/cpp/end2end/xds/xds_end2end_test_lib.h" @@ -1366,7 +1367,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_csds_end2end_test.cc b/test/cpp/end2end/xds/xds_csds_end2end_test.cc index 554c0742b20..540f64cb901 100644 --- a/test/cpp/end2end/xds/xds_csds_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_csds_end2end_test.cc @@ -27,6 +27,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/cpp/client/secure_credentials.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/endpoint.grpc.pb.h" @@ -714,7 +715,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_end2end_test.cc b/test/cpp/end2end/xds/xds_end2end_test.cc index e2c5a303bde..33c592275f8 100644 --- a/test/cpp/end2end/xds/xds_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_end2end_test.cc @@ -68,6 +68,7 @@ #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/time_precise.h" @@ -2951,7 +2952,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_fault_injection_end2end_test.cc b/test/cpp/end2end/xds/xds_fault_injection_end2end_test.cc index 9b6e53249a2..4307b9da28d 100644 --- a/test/cpp/end2end/xds/xds_fault_injection_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_fault_injection_end2end_test.cc @@ -20,6 +20,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/fault.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/http_connection_manager.grpc.pb.h" @@ -568,7 +569,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_outlier_detection_end2end_test.cc b/test/cpp/end2end/xds/xds_outlier_detection_end2end_test.cc index 153eaf7bd9e..a1228a116ad 100644 --- a/test/cpp/end2end/xds/xds_outlier_detection_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_outlier_detection_end2end_test.cc @@ -21,6 +21,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/fault.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/outlier_detection.grpc.pb.h" @@ -1122,7 +1123,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_override_host_end2end_test.cc b/test/cpp/end2end/xds/xds_override_host_end2end_test.cc index b6b4272ce85..a3053dd51e5 100644 --- a/test/cpp/end2end/xds/xds_override_host_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_override_host_end2end_test.cc @@ -25,6 +25,7 @@ #include "absl/strings/str_split.h" #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/match.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/outlier_detection.grpc.pb.h" @@ -277,7 +278,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc b/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc index 28545a55a0d..b3defad5336 100644 --- a/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_ring_hash_end2end_test.cc @@ -28,6 +28,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/env.h" #include "src/proto/grpc/testing/xds/v3/aggregate_cluster.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/cluster.grpc.pb.h" @@ -1165,7 +1166,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_rls_end2end_test.cc b/test/cpp/end2end/xds/xds_rls_end2end_test.cc index 95cfdacfbcc..655cabeacda 100644 --- a/test/cpp/end2end/xds/xds_rls_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_rls_end2end_test.cc @@ -22,6 +22,7 @@ #include "absl/strings/str_cat.h" #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gprpp/env.h" #include "src/proto/grpc/lookup/v1/rls.grpc.pb.h" #include "src/proto/grpc/lookup/v1/rls.pb.h" @@ -208,7 +209,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_routing_end2end_test.cc b/test/cpp/end2end/xds/xds_routing_end2end_test.cc index 1b61749ffcc..2785ce54994 100644 --- a/test/cpp/end2end/xds/xds_routing_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_routing_end2end_test.cc @@ -21,6 +21,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/proto/grpc/testing/xds/v3/fault.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/router.grpc.pb.h" #include "test/cpp/end2end/xds/xds_end2end_test_lib.h" @@ -2401,7 +2402,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/end2end/xds/xds_wrr_end2end_test.cc b/test/cpp/end2end/xds/xds_wrr_end2end_test.cc index a04262b53ba..82a6be694fd 100644 --- a/test/cpp/end2end/xds/xds_wrr_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_wrr_end2end_test.cc @@ -26,6 +26,7 @@ #include #include "src/core/ext/filters/client_channel/backup_poller.h" +#include "src/core/lib/config/config_vars.h" #include "src/proto/grpc/testing/xds/v3/client_side_weighted_round_robin.grpc.pb.h" #include "src/proto/grpc/testing/xds/v3/wrr_locality.grpc.pb.h" #include "test/core/util/scoped_env_var.h" @@ -99,7 +100,9 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // Make the backup poller poll very frequently in order to pick up // updates from all the subchannels's FDs. - GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1); + grpc_core::ConfigVars::Overrides overrides; + overrides.client_channel_backup_poll_interval_ms = 1; + grpc_core::ConfigVars::SetOverrides(overrides); #if TARGET_OS_IPHONE // Workaround Apple CFStream bug grpc_core::SetEnv("grpc_cfstream", "0"); diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index 6186964fed7..f0f2c581544 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -33,9 +33,9 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/host_port.h" @@ -842,13 +842,9 @@ TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) { } // namespace int main(int argc, char** argv) { - grpc_core::UniquePtr resolver = - GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver); - if (strlen(resolver.get()) == 0) { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); - } else if (strcmp("ares", resolver.get()) != 0) { - gpr_log(GPR_INFO, "GRPC_DNS_RESOLVER != ares: %s.", resolver.get()); - } + grpc_core::ConfigVars::Overrides overrides; + overrides.dns_resolver = "ares"; + grpc_core::ConfigVars::SetOverrides(overrides); grpc::testing::TestEnvironment env(&argc, argv); ::testing::InitGoogleTest(&argc, argv); auto result = RUN_ALL_TESTS(); diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index ebb542e4c29..c2da75a13d1 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -33,8 +33,8 @@ #include #include -#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" @@ -187,7 +187,9 @@ void TestCancelActiveDNSQuery(ArgsStruct* args) { class CancelDuringAresQuery : public ::testing::Test { protected: static void SetUpTestSuite() { - GPR_GLOBAL_CONFIG_SET(grpc_dns_resolver, "ares"); + grpc_core::ConfigVars::Overrides overrides; + overrides.dns_resolver = "ares"; + grpc_core::ConfigVars::SetOverrides(overrides); // Sanity check the time that it takes to run the test // including the teardown time (the teardown // part of the test involves cancelling the DNS query, diff --git a/tools/codegen/core/gen_config_vars.py b/tools/codegen/core/gen_config_vars.py new file mode 100755 index 00000000000..00b63e25352 --- /dev/null +++ b/tools/codegen/core/gen_config_vars.py @@ -0,0 +1,266 @@ +#!/usr/bin/env python3 + +# Copyright 2023 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. + +from __future__ import print_function + +import collections +import ctypes +import datetime +import json +import math +import os +import re +import sys + +import yaml + +with open('src/core/lib/config/config_vars.yaml') as f: + attrs = yaml.load(f.read(), Loader=yaml.FullLoader) + +error = False +today = datetime.date.today() +two_quarters_from_now = today + datetime.timedelta(days=180) +for attr in attrs: + if 'name' not in attr: + print("config has no name: %r" % attr) + error = True + continue + if 'experiment' in attr['name'] and attr['name'] != 'experiments': + print('use experiment system for experiments') + error = True + if 'description' not in attr: + print("no description for %s" % attr['name']) + error = True + if 'default' not in attr: + print("no default for %s" % attr['name']) + error = True + +if error: + sys.exit(1) + + +def c_str(s, encoding='ascii'): + if s is None: + return '""' + if isinstance(s, str): + s = s.encode(encoding) + result = '' + for c in s: + c = chr(c) if isinstance(c, int) else c + if not (32 <= ord(c) < 127) or c in ('\\', '"'): + result += '\\%03o' % ord(c) + else: + result += c + return '"' + result + '"' + + +def snake_to_pascal(s): + return ''.join(x.capitalize() for x in s.split('_')) + + +# utility: print a big comment block into a set of files +def put_banner(files, banner): + for f in files: + for line in banner: + print('// %s' % line, file=f) + print(file=f) + + +def put_copyright(file): + # copy-paste copyright notice from this file + with open(sys.argv[0]) as my_source: + copyright = [] + for line in my_source: + if line[0] != '#': + break + for line in my_source: + if line[0] == '#': + copyright.append(line) + break + for line in my_source: + if line[0] != '#': + break + copyright.append(line) + put_banner([file], [line[2:].rstrip() for line in copyright]) + + +RETURN_TYPE = { + "int": "int32_t", + "string": "absl::string_view", + "bool": "bool", +} + +MEMBER_TYPE = { + "int": "int32_t", + "string": "std::string", + "bool": "bool", +} + +SORT_ORDER_FOR_PACKING = {"int": 0, "bool": 1, "string": 2} + + +def bool_default_value(x, name): + if x == True: + return "true" + if x == False: + return "false" + if isinstance(x, str) and x.startswith("$"): + return x[1:] + return x + + +def int_default_value(x, name): + if isinstance(x, str) and x.startswith("$"): + return x[1:] + return x + + +def string_default_value(x, name): + if x is None: + return "\"\"" + if x.startswith("$"): + return x[1:] + return c_str(x) + + +DEFAULT_VALUE = { + "int": int_default_value, + "bool": bool_default_value, + "string": string_default_value, +} + +TO_STRING = { + "int": "$", + "bool": "$?\"true\":\"false\"", + "string": "\"\\\"\", absl::CEscape($), \"\\\"\"", +} + +attrs_in_packing_order = sorted(attrs, + key=lambda a: SORT_ORDER_FOR_PACKING[a['type']]) + +with open('src/core/lib/config/config_vars.h', 'w') as H: + put_copyright(H) + + put_banner([H], [ + "", "Automatically generated by tools/codegen/core/gen_config_vars.py", + "" + ]) + + print("#ifndef GRPC_CORE_LIB_CONFIG_CONFIG_VARS_H", file=H) + print("#define GRPC_CORE_LIB_CONFIG_CONFIG_VARS_H", file=H) + print(file=H) + print("#include ", file=H) + print(file=H) + print("#include ", file=H) + print("#include ", file=H) + print("#include ", file=H) + print("#include \"absl/strings/string_view.h\"", file=H) + print("#include \"absl/strings/str_cat.h\"", file=H) + print("#include \"absl/types/optional.h\"", file=H) + print(file=H) + print("namespace grpc_core {", file=H) + print(file=H) + print("class ConfigVars {", file=H) + print(" public:", file=H) + print(" struct Overrides {", file=H) + for attr in attrs_in_packing_order: + print(" absl::optional<%s> %s;" % + (MEMBER_TYPE[attr['type']], attr['name']), + file=H) + print(" };", file=H) + print(" ConfigVars(const ConfigVars&) = delete;", file=H) + print(" ConfigVars& operator=(const ConfigVars&) = delete;", file=H) + print(" // Get the core configuration; if it does not exist, create it.", + file=H) + print(" static const ConfigVars& Get() {", file=H) + print(" auto* p = config_vars_.load(std::memory_order_acquire);", file=H) + print(" if (p != nullptr) return *p;", file=H) + print(" return Load();", file=H) + print(" }", file=H) + print(" static void SetOverrides(const Overrides& overrides);", file=H) + print(" // Drop the config vars. Users must ensure no other threads are", + file=H) + print(" // accessing the configuration.", file=H) + print(" static void Reset();", file=H) + print(" std::string ToString() const;", file=H) + for attr in attrs: + for line in attr['description'].splitlines(): + print(" // %s" % line, file=H) + print(" %s %s() const { return %s_; }" % + (RETURN_TYPE[attr['type']], snake_to_pascal( + attr['name']), attr['name']), + file=H) + print(" private:", file=H) + print(" explicit ConfigVars(const Overrides& overrides);", file=H) + print(" static const ConfigVars& Load();", file=H) + print(" static std::atomic config_vars_;", file=H) + for attr in attrs_in_packing_order: + print(" %s %s_;" % (MEMBER_TYPE[attr['type']], attr['name']), file=H) + print("};", file=H) + print(file=H) + print("} // namespace grpc_core", file=H) + print(file=H) + print("#endif // GRPC_CORE_LIB_CONFIG_CONFIG_VARS_H", file=H) + +with open('src/core/lib/config/config_vars.cc', 'w') as C: + put_copyright(C) + + put_banner([C], [ + "", "Automatically generated by tools/codegen/core/gen_config_vars.py", + "" + ]) + + print("#include ", file=C) + print("#include \"src/core/lib/config/config_vars.h\"", file=C) + print("#include \"src/core/lib/config/load_config.h\"", file=C) + print("#include \"absl/strings/escaping.h\"", file=C) + print("#include \"absl/flags/flag.h\"", file=C) + print(file=C) + + for attr in attrs: + if 'prelude' in attr: + print(attr['prelude'], file=C) + + for attr in attrs: + print("ABSL_FLAG(absl::optional<%s>, %s, absl::nullopt, %s);" % + (MEMBER_TYPE[attr["type"]], 'grpc_' + attr['name'], + c_str(attr['description'])), + file=C) + print(file=C) + print("namespace grpc_core {", file=C) + print(file=C) + print("ConfigVars::ConfigVars(const Overrides& overrides) :", file=C) + print(",".join("%s_(LoadConfig(FLAGS_grpc_%s, overrides.%s, %s))" % + (attr['name'], attr['name'], attr['name'], + DEFAULT_VALUE[attr['type']](attr['default'], attr['name'])) + for attr in attrs_in_packing_order), + file=C) + print("{}", file=C) + print(file=C) + print("std::string ConfigVars::ToString() const {", file=C) + print(" return absl::StrCat(", file=C) + for i, attr in enumerate(attrs): + if i: + print(",", file=C) + print(c_str(", " + attr['name'] + ": "), file=C) + else: + print(c_str(attr['name'] + ": "), file=C) + print(",", + TO_STRING[attr['type']].replace("$", attr['name'] + "_"), + file=C) + print(");}", file=C) + print(file=C) + print("}", file=C) diff --git a/tools/distrib/fix_build_deps.py b/tools/distrib/fix_build_deps.py index df5ff056886..beb8730b771 100755 --- a/tools/distrib/fix_build_deps.py +++ b/tools/distrib/fix_build_deps.py @@ -68,6 +68,8 @@ EXTERNAL_DEPS = { 'absl/debugging:symbolize', 'absl/flags/flag.h': 'absl/flags:flag', + 'absl/flags/marshalling.h': + 'absl/flags:marshalling', 'absl/flags/parse.h': 'absl/flags:parse', 'absl/functional/any_invocable.h': @@ -435,30 +437,56 @@ for dirname in [ "test/core/transport/chaotic_good", ]: parsing_path = dirname - exec( - open('%sBUILD' % (dirname + '/' if dirname else ''), 'r').read(), { - 'load': lambda filename, *args: None, - 'licenses': lambda licenses: None, - 'package': lambda **kwargs: None, - 'exports_files': lambda files, visibility=None: None, - 'config_setting': lambda **kwargs: None, - 'selects': FakeSelects(), - 'python_config_settings': lambda **kwargs: None, - 'grpc_cc_binary': grpc_cc_library, - 'grpc_cc_library': grpc_cc_library, - 'grpc_cc_test': grpc_cc_library, - 'grpc_fuzzer': grpc_cc_library, - 'grpc_proto_fuzzer': grpc_cc_library, - 'select': lambda d: d["//conditions:default"], - 'glob': lambda files: None, - 'grpc_end2end_tests': lambda: None, - 'grpc_upb_proto_library': lambda name, **kwargs: None, - 'grpc_upb_proto_reflection_library': lambda name, **kwargs: None, - 'grpc_generate_one_off_targets': lambda: None, - 'grpc_package': lambda **kwargs: None, - 'filegroup': lambda name, **kwargs: None, - 'sh_library': lambda name, **kwargs: None, - }, {}) + build_file = '%sBUILD' % (dirname + '/' if dirname else '') + try: + exec( + open(build_file, 'r').read(), { + 'load': + lambda filename, *args: None, + 'licenses': + lambda licenses: None, + 'package': + lambda **kwargs: None, + 'exports_files': + lambda files, visibility=None: None, + 'config_setting': + lambda **kwargs: None, + 'selects': + FakeSelects(), + 'python_config_settings': + lambda **kwargs: None, + 'grpc_cc_binary': + grpc_cc_library, + 'grpc_cc_library': + grpc_cc_library, + 'grpc_cc_test': + grpc_cc_library, + 'grpc_fuzzer': + grpc_cc_library, + 'grpc_proto_fuzzer': + grpc_cc_library, + 'select': + lambda d: d["//conditions:default"], + 'glob': + lambda files: None, + 'grpc_end2end_tests': + lambda: None, + 'grpc_upb_proto_library': + lambda name, **kwargs: None, + 'grpc_upb_proto_reflection_library': + lambda name, **kwargs: None, + 'grpc_generate_one_off_targets': + lambda: None, + 'grpc_package': + lambda **kwargs: None, + 'filegroup': + lambda name, **kwargs: None, + 'sh_library': + lambda name, **kwargs: None, + }, {}) + except Exception as e: + print("Error parsing %s" % build_file) + raise e parsing_path = None if args.whats_left: diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 4a41380df9c..ce5cd2c2c88 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1158,8 +1158,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h \ @@ -2022,8 +2020,13 @@ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/message_compress.h \ +src/core/lib/config/config_vars.cc \ +src/core/lib/config/config_vars.h \ +src/core/lib/config/config_vars_non_generated.cc \ src/core/lib/config/core_configuration.cc \ src/core/lib/config/core_configuration.h \ +src/core/lib/config/load_config.cc \ +src/core/lib/config/load_config.h \ src/core/lib/debug/event_log.cc \ src/core/lib/debug/event_log.h \ src/core/lib/debug/histogram_view.cc \ @@ -2165,11 +2168,6 @@ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/examine_stack.h \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/fork.h \ -src/core/lib/gprpp/global_config.h \ -src/core/lib/gprpp/global_config_custom.h \ -src/core/lib/gprpp/global_config_env.cc \ -src/core/lib/gprpp/global_config_env.h \ -src/core/lib/gprpp/global_config_generic.h \ src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/linux/env.cc \ @@ -2539,8 +2537,6 @@ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.h \ src/core/lib/security/security_connector/ssl_utils.cc \ src/core/lib/security/security_connector/ssl_utils.h \ -src/core/lib/security/security_connector/ssl_utils_config.cc \ -src/core/lib/security/security_connector/ssl_utils_config.h \ src/core/lib/security/security_connector/tls/tls_security_connector.cc \ src/core/lib/security/security_connector/tls/tls_security_connector.h \ src/core/lib/security/transport/auth_filters.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 22bc220dc85..e34a60f5534 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -966,8 +966,6 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \ -src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ @@ -1800,8 +1798,13 @@ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/message_compress.h \ +src/core/lib/config/config_vars.cc \ +src/core/lib/config/config_vars.h \ +src/core/lib/config/config_vars_non_generated.cc \ src/core/lib/config/core_configuration.cc \ src/core/lib/config/core_configuration.h \ +src/core/lib/config/load_config.cc \ +src/core/lib/config/load_config.h \ src/core/lib/debug/event_log.cc \ src/core/lib/debug/event_log.h \ src/core/lib/debug/histogram_view.cc \ @@ -1945,11 +1948,6 @@ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/examine_stack.h \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/fork.h \ -src/core/lib/gprpp/global_config.h \ -src/core/lib/gprpp/global_config_custom.h \ -src/core/lib/gprpp/global_config_env.cc \ -src/core/lib/gprpp/global_config_env.h \ -src/core/lib/gprpp/global_config_generic.h \ src/core/lib/gprpp/host_port.cc \ src/core/lib/gprpp/host_port.h \ src/core/lib/gprpp/linux/env.cc \ @@ -2320,8 +2318,6 @@ src/core/lib/security/security_connector/ssl/ssl_security_connector.cc \ src/core/lib/security/security_connector/ssl/ssl_security_connector.h \ src/core/lib/security/security_connector/ssl_utils.cc \ src/core/lib/security/security_connector/ssl_utils.h \ -src/core/lib/security/security_connector/ssl_utils_config.cc \ -src/core/lib/security/security_connector/ssl_utils_config.h \ src/core/lib/security/security_connector/tls/tls_security_connector.cc \ src/core/lib/security/security_connector/tls/tls_security_connector.h \ src/core/lib/security/transport/auth_filters.h \ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 6068109881c..21925f63b13 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3269,52 +3269,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "global_config_env_test", - "platforms": [ - "linux", - "mac", - "posix" - ], - "uses_polling": false - }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "global_config_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false,