diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index cc9506f606..085c2c2823 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -594,18 +594,24 @@ 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: - 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) 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 update_edgezone_aggregator_config(self): """ Update cable length configuration in ConfigDB for T0 neighbor interfaces diff --git a/tests/db_migrator_input/appl_db/routes_migrate_expected.json b/tests/db_migrator_input/appl_db/routes_migrate_expected.json index 5cad371c31..7f48e64e40 100644 --- a/tests/db_migrator_input/appl_db/routes_migrate_expected.json +++ b/tests/db_migrator_input/appl_db/routes_migrate_expected.json @@ -2,11 +2,13 @@ "ROUTE_TABLE:192.168.104.0/25": { "nexthop": "10.0.0.57,10.0.0.59,10.0.0.61,10.0.0.63", "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104", - "weight": "" + "weight": "", + "protocol": "" }, "ROUTE_TABLE:20c0:fe28:0:80::/64": { - "nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e", - "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104", - "weight": "" + "nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e", + "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104", + "weight": "", + "protocol": "" } } diff --git a/tests/db_migrator_input/appl_db/routes_migrate_input.json b/tests/db_migrator_input/appl_db/routes_migrate_input.json index 7249488cd6..3b93a36cf6 100644 --- a/tests/db_migrator_input/appl_db/routes_migrate_input.json +++ b/tests/db_migrator_input/appl_db/routes_migrate_input.json @@ -4,7 +4,7 @@ "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104" }, "ROUTE_TABLE:20c0:fe28:0:80::/64": { - "nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e", - "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104" + "nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e", + "ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104" } } diff --git a/tests/db_migrator_test.py b/tests/db_migrator_test.py index c06bb11d11..d06034a285 100644 --- a/tests/db_migrator_test.py +++ b/tests/db_migrator_test.py @@ -551,7 +551,7 @@ def test_migrate_loopback_int(self): diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True) assert not diff -class TestWarmUpgrade_without_route_weights(object): +class TestWarmUpgrade_without_required_attributes(object): @classmethod def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "2" @@ -562,7 +562,7 @@ def teardown_class(cls): dbconnector.dedicated_dbs['CONFIG_DB'] = None dbconnector.dedicated_dbs['APPL_DB'] = None - def test_migrate_weights_for_nexthops(self): + 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')