Unify and improve config option registration code #5234
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to unify and make all the config registration code more consistent - aka so it exposes / utilizes the same API.
I only started to dig into since I started a bunch of test errors like that recently - https://gist.github.com/Kami/fcfa62f1ae7f0b84cd3981ecd6f5fe37.
It looks like there is some kind of race with config option registration which likely depends on the import ordering or similar. Either this issue has been there for a long time already (not so unlikely) or some recent code changes re-arranged the imports or similar which started to trigger this issue more often (I did quickly check git history without much success., but I could have also missed something)
Sadly most of the config modules itself have import time side affects (options are registered on import) which is bad. Fixing / improving that would likely be a very deep rabbit hole since tons of existing code and tests relies on this behavior.
So with this PR I'm really just trying to unify the code and gets tests to pass consistently. Keep in mind that registering the same options multiple times should not be and it's not fatal so if we ignore such errors it's OK (well, it's not prefect, but it's compromise - an alternative is much larger code change which could likely takes many days to even weeks).