Skip to content

Commit 19615e3

Browse files
authored
Fixing db_migrator for Feature table (#1674)
#### 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
1 parent d1c1c61 commit 19615e3

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

scripts/db_migrator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ def migrate_feature_table(self):
180180
'''
181181
feature_table = self.configDB.get_table('FEATURE')
182182
for feature, config in feature_table.items():
183-
state = config.pop('status', 'disabled')
184-
config['state'] = state
185-
self.configDB.set_entry('FEATURE', feature, config)
183+
state = config.get('status')
184+
if state is not None:
185+
config['state'] = state
186+
config.pop('status')
187+
self.configDB.set_entry('FEATURE', feature, config)
186188

187189
container_feature_table = self.configDB.get_table('CONTAINER_FEATURE')
188190
for feature, config in container_feature_table.items():

tests/db_migrator_input/config_db/feature-expected.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
"high_mem_alert": "disabled",
88
"state": "enabled"
99
},
10+
"FEATURE|syncd": {
11+
"auto_restart": "enabled",
12+
"has_global_scope": "False",
13+
"has_per_asic_scope": "True",
14+
"has_timer": "False",
15+
"high_mem_alert": "disabled",
16+
"state": "enabled"
17+
},
1018
"FEATURE|telemetry": {
1119
"auto_restart": "enabled",
1220
"has_global_scope": "False",

tests/db_migrator_input/config_db/feature-input.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
},
1010
"FEATURE|telemetry": {
1111
"status": "enabled"
12+
},
13+
"FEATURE|syncd": {
14+
"state": "enabled"
1215
}
1316
}

tests/db_migrator_input/init_cfg.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
"high_mem_alert": "disabled",
99
"state": "enabled"
1010
},
11+
"syncd": {
12+
"auto_restart": "enabled",
13+
"has_global_scope": "False",
14+
"has_per_asic_scope": "True",
15+
"has_timer": "False",
16+
"high_mem_alert": "disabled",
17+
"state": "enabled"
18+
},
1119
"telemetry": {
1220
"auto_restart": "disabled",
1321
"has_global_scope": "False",

0 commit comments

Comments
 (0)