Skip to content

Commit

Permalink
Handle fc delay status removal in new version
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak committed Jan 3, 2025
1 parent cbd441f commit 4560bd7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
18 changes: 17 additions & 1 deletion scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,20 @@ def update_edgezone_aggregator_config(self):
# Set new cable length values
self.configDB.set(self.configDB.CONFIG_DB, "CABLE_LENGTH|AZURE", intf, EDGEZONE_AGG_CABLE_LENGTH)

def migrate_config_db_flex_counter_delay_status(self):
"""
Migrate "FLEX_COUNTER_TABLE|*": { "value": { "FLEX_COUNTER_DELAY_STATUS": "false" } }
Set FLEX_COUNTER_DELAY_STATUS true in case of fast-reboot
"""

flex_counter_objects = self.configDB.get_keys('FLEX_COUNTER_TABLE')
for obj in flex_counter_objects:
flex_counter = self.configDB.get_entry('FLEX_COUNTER_TABLE', obj)
delay_status = flex_counter.get('FLEX_COUNTER_DELAY_STATUS')
if delay_status is None or delay_status == 'false':
flex_counter['FLEX_COUNTER_DELAY_STATUS'] = 'true'
self.configDB.mod_entry('FLEX_COUNTER_TABLE', obj, flex_counter)

def migrate_flex_counter_delay_status_removal(self):
"""
Remove FLEX_COUNTER_DELAY_STATUS field.
Expand Down Expand Up @@ -1168,6 +1182,8 @@ def version_4_0_2(self):
Version 4_0_2.
"""
log.log_info('Handling version_4_0_2')
if self.stateDB.keys(self.stateDB.STATE_DB, "FAST_REBOOT|system"):
self.migrate_config_db_flex_counter_delay_status()

self.set_version('version_4_0_3')
return 'version_4_0_3'
Expand Down Expand Up @@ -1245,6 +1261,7 @@ def version_202505_01(self):
master branch until 202505 branch is created.
"""
log.log_info('Handling version_202505_01')
self.migrate_flex_counter_delay_status_removal()
return None

def get_version(self):
Expand Down Expand Up @@ -1298,7 +1315,6 @@ def common_migration_ops(self):

self.migrate_tacplus()
self.migrate_aaa()
self.migrate_flex_counter_delay_status_removal()

def migrate(self):
version = self.get_version()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_202411_01"
"VERSION": "version_4_0_3"
},
"FLEX_COUNTER_TABLE|ACL": {
"FLEX_COUNTER_STATUS": "enable",
Expand Down
20 changes: 10 additions & 10 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def test_warm_upgrade_t0_edgezone_aggregator_same_cable_length(self):
assert not diff


class TestFastUpgrade(object):
class TestFastUpgrade_to_4_0_3(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "2"
Expand All @@ -761,16 +761,16 @@ def check_config_db(self, result, expected):
for table in self.config_db_tables_to_verify:
assert result.get_table(table) == expected.get_table(table)

def test_fast_reboot_upgrade_fc(self):
db_before_migrate = 'cross_branch_upgrade_flex_counters_input'
db_after_migrate = 'cross_branch_upgrade_flex_counters_expected'
def test_fast_reboot_upgrade_to_4_0_3(self):
db_before_migrate = 'cross_branch_upgrade_to_4_0_3_input'
db_after_migrate = 'cross_branch_upgrade_to_4_0_3_expected'
device_info.get_sonic_version_info = get_sonic_version_info_mlnx
db = self.mock_dedicated_config_db(db_before_migrate)
import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.migrate()
expected_db = self.mock_dedicated_config_db(db_after_migrate)
advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_202411_01')
advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_4_0_3')
assert not self.check_config_db(dbmgtr.configDB, expected_db.cfgdb)
assert dbmgtr.CURRENT_VERSION == expected_db.cfgdb.get_entry('VERSIONS', 'DATABASE')['VERSION'], '{} {}'.format(dbmgtr.CURRENT_VERSION, dbmgtr.get_version())

Expand Down Expand Up @@ -936,13 +936,13 @@ def test_dns_nameserver_migrator_minigraph(self):
dbmgtr.config_src_data = {
'GNMI': {
'gnmi': {
"client_auth": "true",
"log_level": "2",
"client_auth": "true",
"log_level": "2",
"port": "50052"
},
},
'certs': {
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key",
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key",
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer"
}
}
Expand Down

0 comments on commit 4560bd7

Please sign in to comment.