Skip to content
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

[action] [PR:3068] [db_migrator]Remove route migration (#3068) #3085

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,28 +614,6 @@ def migrate_feature_timer(self):
config.pop('has_timer')
self.configDB.set_entry('FEATURE', feature, config)

def migrate_route_table(self):
"""
Handle route table migration. Migrations handled:
1. 'weight' attr in ROUTE object was introduced 202205 onwards.
Upgrade from older branch to 202205 will require this 'weight' attr to be added explicitly
2. 'protocol' attr in ROUTE introduced in 202305 onwards.
WarmRestartHelper reconcile logic requires to have "protocol" field in the old dumped ROUTE_TABLE.
"""
route_table = self.appDB.get_table("ROUTE_TABLE")
for route_prefix, route_attr in route_table.items():
if type(route_prefix) == tuple:
# IPv6 route_prefix is returned from db as tuple
route_key = "ROUTE_TABLE:" + ":".join(route_prefix)
else:
# IPv4 route_prefix is returned from db as str
route_key = "ROUTE_TABLE:{}".format(route_prefix)

if 'weight' not in route_attr:
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')

if 'protocol' not in route_attr:
self.appDB.set(self.appDB.APPL_DB, route_key, 'protocol', '')

def migrate_routing_config_mode(self):
# DEVICE_METADATA - synchronous_mode entry
Expand Down Expand Up @@ -1079,8 +1057,6 @@ def common_migration_ops(self):
else:
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))

self.migrate_route_table()

# Updating edgezone aggregator cable length config for T0 devices
self.update_edgezone_aggregator_config()
# update FRR config mode based on minigraph parser on target image
Expand Down
14 changes: 0 additions & 14 deletions tests/db_migrator_input/appl_db/routes_migrate_expected.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/db_migrator_input/appl_db/routes_migrate_input.json

This file was deleted.

35 changes: 0 additions & 35 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,41 +600,6 @@ def test_migrate_loopback_int(self):
diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True)
assert not diff

class TestWarmUpgrade_without_required_attributes(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "2"

@classmethod
def teardown_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "0"
dbconnector.dedicated_dbs['CONFIG_DB'] = None
dbconnector.dedicated_dbs['APPL_DB'] = None

def test_migrate_weights_protocol_for_nexthops(self):
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'routes_migrate_input')
dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'routes_migrate_input')

import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.migrate()
dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'routes_migrate_expected')
expected_db = Db()

# verify migrated appDB
expected_appl_db = SonicV2Connector(host='127.0.0.1')
expected_appl_db.connect(expected_appl_db.APPL_DB)
expected_keys = expected_appl_db.keys(expected_appl_db.APPL_DB, "ROUTE_TABLE:*")
expected_keys.sort()
resulting_keys = dbmgtr.appDB.keys(dbmgtr.appDB.APPL_DB, "ROUTE_TABLE:*")
resulting_keys.sort()
assert expected_keys == resulting_keys
for key in expected_keys:
resulting_keys = dbmgtr.appDB.get_all(dbmgtr.appDB.APPL_DB, key)
expected_keys = expected_appl_db.get_all(expected_appl_db.APPL_DB, key)
diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True)
assert not diff

class TestWarmUpgrade_T0_EdgeZoneAggregator(object):
@classmethod
def setup_class(cls):
Expand Down
Loading