-
Notifications
You must be signed in to change notification settings - Fork 664
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
[generic-config-updater] Handling empty tables while sorting a patch #1923
[generic-config-updater] Handling empty tables while sorting a patch #1923
Conversation
This pull request introduces 1 alert when merging e47e186b1b0996ca108e8bc95bcf28853404cf75 into 4bcaa60 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 5984d0fcbdbb3258e241a885875be32e306de01b into 00b6045 - view on LGTM.com new alerts:
|
38fd9a2
to
31fe18a
Compare
# Validate target config does not have empty tables since they do not show up in ConfigDb | ||
self.logger.log_notice("Validating target config does not have empty tables, " \ | ||
"since they do not show up in ConfigDb.") | ||
has_empty_tables, empty_tables = self.config_wrapper.has_empty_tables(target_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.
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.
updated
|
||
def _validate_table(self, table, config): | ||
is_empty = table in config and not(config[table]) | ||
return not(is_empty) |
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.
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 will look like this:
def _validate_table(self, table, config):
return table not in config or config[table]
This means the table is either not in config, or table has content. Why does this mean the table is not empty? It will take future developer a while to understand it. I think it is easier to have a flag is_empty
and revert the flag on return.
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.
Either way is okay to me.
Could you add function level comment "the only invalid case is if table exist and is empty"?
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.
[offline discussion] will update and add a small 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.
updated
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 comments
What I did
Fixing issue #1908
How I did it
NoEmptyTableMoveValidator
UpperLevelMoveExtender
which produces eitherDeleteInsteadOfReplaceMoveExtender
The generators/validators are documented in the
PatchSorter.py
, check the documentation out.How to verify it
unit-test
Previous command output (if the output of a command-line utility has changed)
The above error occurs because post the update, the whole
DEVICE_METADATA
table is deleted, not just showing as empty i.e."DEVICE_METADATA": {}
New command output (if the output of a command-line utility has changed)