[generic-config-updater] Handling empty tables while sorting a patch#1923
[generic-config-updater] Handling empty tables while sorting a patch#1923ghooo merged 4 commits intosonic-net:masterfrom
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) |
|
|
||
| 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.
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.
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.
[offline discussion] will update and add a small comment
What I did
Fixing issue #1908
How I did it
NoEmptyTableMoveValidatorUpperLevelMoveExtenderwhich produces eitherDeleteInsteadOfReplaceMoveExtenderThe 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_METADATAtable is deleted, not just showing as empty i.e."DEVICE_METADATA": {}New command output (if the output of a command-line utility has changed)