Skip to content

Commit

Permalink
Fixing db_migrator for Feature table (#1674)
Browse files Browse the repository at this point in the history
#### What I did
Fixing db_migrator.py for FEATURE table. In case of version_unknown, all versions' migrator APIs would be invoked which will also invoke the feature_table migration. Without the field check for 'status' the current logic will set it 'disabled' and will set 'state' field too to be 'disabled' which will in turn disable all the features bringing down the system.

#### How I did it
Added check to migrate only if 'status' field is present.

#### How to verify it
Install the image through onie and confirm if services are up
  • Loading branch information
dgsudharsan committed Jun 17, 2021
1 parent d1c1c61 commit 19615e3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ def migrate_feature_table(self):
'''
feature_table = self.configDB.get_table('FEATURE')
for feature, config in feature_table.items():
state = config.pop('status', 'disabled')
config['state'] = state
self.configDB.set_entry('FEATURE', feature, config)
state = config.get('status')
if state is not None:
config['state'] = state
config.pop('status')
self.configDB.set_entry('FEATURE', feature, config)

container_feature_table = self.configDB.get_table('CONTAINER_FEATURE')
for feature, config in container_feature_table.items():
Expand Down
8 changes: 8 additions & 0 deletions tests/db_migrator_input/config_db/feature-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"high_mem_alert": "disabled",
"state": "enabled"
},
"FEATURE|syncd": {
"auto_restart": "enabled",
"has_global_scope": "False",
"has_per_asic_scope": "True",
"has_timer": "False",
"high_mem_alert": "disabled",
"state": "enabled"
},
"FEATURE|telemetry": {
"auto_restart": "enabled",
"has_global_scope": "False",
Expand Down
3 changes: 3 additions & 0 deletions tests/db_migrator_input/config_db/feature-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
},
"FEATURE|telemetry": {
"status": "enabled"
},
"FEATURE|syncd": {
"state": "enabled"
}
}
8 changes: 8 additions & 0 deletions tests/db_migrator_input/init_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
"high_mem_alert": "disabled",
"state": "enabled"
},
"syncd": {
"auto_restart": "enabled",
"has_global_scope": "False",
"has_per_asic_scope": "True",
"has_timer": "False",
"high_mem_alert": "disabled",
"state": "enabled"
},
"telemetry": {
"auto_restart": "disabled",
"has_global_scope": "False",
Expand Down

0 comments on commit 19615e3

Please sign in to comment.