-
Notifications
You must be signed in to change notification settings - Fork 661
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
Support golden config in db migrator #3076
Conversation
scripts/db_migrator.py
Outdated
with open(GOLDEN_CFG_FILE) as f: | ||
golden_data = json.load(f) | ||
if namespace is None: | ||
self.minigraph_data = golden_data |
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.
It's confusing to change the meaning of "minigraph_data". Suggest make it immutable, and create new var for new purpose.
If both GOLDEN_CFG_FILE and MINIGRAPH_FILE exists, the table inside GOLDEN_CFG_FILE will override table from MINIGRAPH_FILE. Please check with @wen587 and try reuse this override logic. #Closed
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.
As comment
|
||
def update_config(current_config, config_input): | ||
""" | ||
Override current config with golden config |
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.
scripts/db_migrator.py
Outdated
# this is to avoid duplicating the hardcoded these values in db_migrator | ||
self.config_src_data = None | ||
if self.__minigraph_data: | ||
self.config_src_data = self.__minigraph_data |
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.
This is shallow copy. So any future change on right side will also appear on left side.
I understand it is not efficient to make minigraph_data
immutable. So instead, you can call it config_src_data
, and override it.
__xxx
convention does not help your case, it is just make the member super private. #Closed
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.
Fixed
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.
For reused function, add an argument to update_config, and update_config will use deepcopy by default, but db migrator will use shallow copy.
For db migrator, add a method to generate config_src_data. golden_config_data and minigraph_data are local variables, so it's impossible to alter them and then we can prevent unintended change.
What I did Need to support golden config in db migrator. How I did it If there's golden config json, read from golden config instead of minigraph. And db migrator will use golden config data to generate new configuration. How to verify it Run unit test.
Cherry-pick PR to 202311: #3136 |
What I did Need to support golden config in db migrator. How I did it If there's golden config json, read from golden config instead of minigraph. And db migrator will use golden config data to generate new configuration. How to verify it Run unit test.
What I did
Need to support golden config in db migrator.
How I did it
If there's golden config json, read from golden config instead of minigraph.
And db migrator will use golden config data to generate new configuration.
How to verify it
Run unit test.
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)