-
Notifications
You must be signed in to change notification settings - Fork 961
Fix config hierarchy #3512
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
Fix config hierarchy #3512
Conversation
…eter and skip the db stuff Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…or the merging functionality Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
| from sqlalchemy import and_, update | ||
| import json | ||
| import copy | ||
| from typing import List, Any, Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pylint] reported by reviewdog 🐶
W0611: Unused List imported from typing (unused-import)
|
I also tested this by running Augur before and after this change. Before I observed that the augur_collection_monitor task was failing every 30 seconds (as seen in Flower) with the same exception about the missing config key. Afterwards, i see these tasks succeeding again |
Signed-off-by: Adrian Edwards <17362949+MoralCode@users.noreply.github.com>
shlokgilda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
sgoggins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR corrects a bug that was introduced with the config hierarchy PR in #3378
The bug was that I was using python's builtin
update()function to attempt to merge the configs from different sources together (represented as nested dicts). However,update()only updates one level of the dictionary, meaning that the sections were being correctly merged, but the values within each section were just being replaced with the values present in the highest priority config item in the stack, rather than being merged.This means that values were not correctly "propagating up" thorugh holes in the config. For example, if a value was not present in the database, attempts to retrieve config based on all sources would only return what was in the database, failing to populate any values present in other sources (such as the hardcoded defaults) when they were missing from the database.
In place of
update()this PR uses a recursive function found on StackOverflow. Since these config objects are small, this recursive solution should be an acceptable tradeoff. If the config objects start getting really big and/or really nested (hundreds of items) then maybe it should be re-considered, but this scenario doesnt seem especially likely.This PR fixes #3476
Notes for Reviewers
This was tested with a unit test. to run it without causing a ton of errors from all the tests that still have failing database fixtures, run
uv run pytest tests/test_classes/. The unit test is written to purposely not use the database or any database mocks or fixtures so it can be run in more situations (hopefully making the tests easier to run even if they break again in future)Signed commits