Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] Move global config alongside core configuration #30788

Merged
merged 71 commits into from
Mar 17, 2023

Conversation

ctiller
Copy link
Member

@ctiller ctiller commented Aug 29, 2022

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.

Automated fix for refs/heads/environmental-pollution
@ctiller ctiller added the release notes: no Indicates if PR should not be in release notes label Sep 19, 2022
Automated fix for refs/heads/environmental-pollution
@@ -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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One drawback of centralizing the definition of these config params is that it will be less obvious when there are no longer any users of a given parameter and it can be removed. Just as one example, prior to this PR, when we eventually remove this backup poller, this parameter would have been removed at the same time; with this PR, it might be easier to forget. Is there a reasonable way we can have some automated check for this kind of thing?

This isn't a blocker, but would be good to add some check for this if we have a reasonable way to do so.

test/core/security/security_connector_test.cc Outdated Show resolved Hide resolved
test/cpp/end2end/rls_end2end_test.cc Outdated Show resolved Hide resolved
test/cpp/end2end/server_load_reporting_end2end_test.cc Outdated Show resolved Hide resolved
@@ -55,9 +55,14 @@ int main(int argc, char** argv) {

grpc::testing::TestEnvironment env(&argc, argv);
grpc_end2end_tests_pre_init();
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some leftover cruft from a merge.

Copy link
Contributor

@gnossen gnossen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct Cython the first try? Impossible.

LGTM to the src/python/**/* changes.

@ctiller ctiller enabled auto-merge (squash) March 17, 2023 22:56
@ctiller ctiller merged commit b7a8330 into grpc:master Mar 17, 2023
@jtattermusch
Copy link
Contributor

This very likely break the ObjC bazel test:

It started failing right after this PR got merged:
https://source.cloud.google.com/results/invocations/48b5072d-16e2-4b81-827b-c16763a8fd38/log

In file included from src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm:44:
In file included from ./src/core/lib/security/credentials/credentials.h:43:
In file included from ./src/core/lib/security/security_connector/security_connector.h:37:
In file included from ./src/core/lib/iomgr/closure.h:34:
In file included from ./src/core/lib/iomgr/error.h:38:
./src/core/lib/slice/slice_internal.h:82:10: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  return absl::HashOf(grpc_core::StringViewFromSlice(s));
  ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm:122:25: error: use of undeclared identifier 'grpc_default_ssl_roots_file_path'
  GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename);

In fact, this was correctly indicated by the "ObjC Bazel Test" presubmit test (which is red on this PR).
https://source.cloud.google.com/results/invocations/b1d333dd-f5aa-4d49-a0dd-4e0ef0f52923

jtattermusch added a commit that referenced this pull request Mar 20, 2023
ctiller pushed a commit that referenced this pull request Mar 20, 2023
…2659)

Reverts #30788

(it breaks grpc_objc_bazel_test (see
#30788 (comment)) and
also seems to be breaking some other internal stuff).
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Mar 20, 2023
XuanWang-Amos pushed a commit to XuanWang-Amos/grpc that referenced this pull request May 1, 2023
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`.

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
XuanWang-Amos pushed a commit to XuanWang-Amos/grpc that referenced this pull request May 1, 2023
…pc#32659)

Reverts grpc#30788

(it breaks grpc_objc_bazel_test (see
grpc#30788 (comment)) and
also seems to be breaking some other internal stuff).
wanlin31 pushed a commit that referenced this pull request May 18, 2023
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`.

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
wanlin31 pushed a commit that referenced this pull request May 18, 2023
…2659)

Reverts #30788

(it breaks grpc_objc_bazel_test (see
#30788 (comment)) and
also seems to be breaking some other internal stuff).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants