Skip to content

Commit 0d7fc5b

Browse files
stepanblyschakpdhruv-marvell
authored andcommitted
[db_migrator] add required "protocol" field in ROUTE_TABLE (sonic-net#2766)
- What I did I added requires "protocol" field due to fpmsyncd reconcile logic (WarmRestartHelper class) requires old fvs keys to match new fvs. - How I did it Add "protocol" field in db migration. - How to verify it Upgrade from older branch to new image with supported FIB pending. The field was added by sonic-net/sonic-swss#2551. Signed-off-by: Stepan Blyschak <[email protected]>
1 parent f45cff7 commit 0d7fc5b

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

scripts/db_migrator.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -594,18 +594,24 @@ def migrate_route_table(self):
594594
Handle route table migration. Migrations handled:
595595
1. 'weight' attr in ROUTE object was introduced 202205 onwards.
596596
Upgrade from older branch to 202205 will require this 'weight' attr to be added explicitly
597+
2. 'protocol' attr in ROUTE introduced in 202305 onwards.
598+
WarmRestartHelper reconcile logic requires to have "protocol" field in the old dumped ROUTE_TABLE.
597599
"""
598600
route_table = self.appDB.get_table("ROUTE_TABLE")
599601
for route_prefix, route_attr in route_table.items():
602+
if type(route_prefix) == tuple:
603+
# IPv6 route_prefix is returned from db as tuple
604+
route_key = "ROUTE_TABLE:" + ":".join(route_prefix)
605+
else:
606+
# IPv4 route_prefix is returned from db as str
607+
route_key = "ROUTE_TABLE:{}".format(route_prefix)
608+
600609
if 'weight' not in route_attr:
601-
if type(route_prefix) == tuple:
602-
# IPv6 route_prefix is returned from db as tuple
603-
route_key = "ROUTE_TABLE:" + ":".join(route_prefix)
604-
else:
605-
# IPv4 route_prefix is returned from db as str
606-
route_key = "ROUTE_TABLE:{}".format(route_prefix)
607610
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')
608611

612+
if 'protocol' not in route_attr:
613+
self.appDB.set(self.appDB.APPL_DB, route_key, 'protocol', '')
614+
609615
def update_edgezone_aggregator_config(self):
610616
"""
611617
Update cable length configuration in ConfigDB for T0 neighbor interfaces

tests/db_migrator_input/appl_db/routes_migrate_expected.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"ROUTE_TABLE:192.168.104.0/25": {
33
"nexthop": "10.0.0.57,10.0.0.59,10.0.0.61,10.0.0.63",
44
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104",
5-
"weight": ""
5+
"weight": "",
6+
"protocol": ""
67
},
78
"ROUTE_TABLE:20c0:fe28:0:80::/64": {
8-
"nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e",
9-
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104",
10-
"weight": ""
9+
"nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e",
10+
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104",
11+
"weight": "",
12+
"protocol": ""
1113
}
1214
}

tests/db_migrator_input/appl_db/routes_migrate_input.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104"
55
},
66
"ROUTE_TABLE:20c0:fe28:0:80::/64": {
7-
"nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e",
8-
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104"
7+
"nexthop": "fc00::72,fc00::76,fc00::7a,fc00::7e",
8+
"ifname" : "PortChannel101,PortChannel102,PortChannel103,PortChannel104"
99
}
1010
}

tests/db_migrator_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def test_migrate_loopback_int(self):
551551
diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True)
552552
assert not diff
553553

554-
class TestWarmUpgrade_without_route_weights(object):
554+
class TestWarmUpgrade_without_required_attributes(object):
555555
@classmethod
556556
def setup_class(cls):
557557
os.environ['UTILITIES_UNIT_TESTING'] = "2"
@@ -562,7 +562,7 @@ def teardown_class(cls):
562562
dbconnector.dedicated_dbs['CONFIG_DB'] = None
563563
dbconnector.dedicated_dbs['APPL_DB'] = None
564564

565-
def test_migrate_weights_for_nexthops(self):
565+
def test_migrate_weights_protocol_for_nexthops(self):
566566
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'routes_migrate_input')
567567
dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'routes_migrate_input')
568568

0 commit comments

Comments
 (0)