Skip to content

Commit

Permalink
[db_migrator] Set docker_routing_config_mode to the value obtained fr…
Browse files Browse the repository at this point in the history
…om minigraph parser (#2890) (#2922)

MSFT ADO: 24419953

This is to fix a bug where warm upgrade from old image (eg. 20181130) to new image (eg. 202012) does not update docker_routing_config_mode to the new config expected the target OS.

For eg., in 201811 DEVICE_METADATA.localhost.docker_routing_config_mode is set to unified.
After upgrade to 202012 the value is not changed. However, the expectation in newer images is that the value is separated.

The move from unified to separated was done as part of an old change: sonic-net/sonic-buildimage#2961

However, migration logic was not updated since then. Because of this miss, cross-branch warm-upgrade from 201811 to 2020212 to 202305 to latest will always keep the setting as unified.

How I did it
Added a common migration logic: update docker_routing_config_mode to the value from minigraph parser.

How to verify it
Added a new unit test. Updated old unit tests.
  • Loading branch information
vaibhavhd authored Aug 10, 2023
1 parent 9986464 commit bef3ffe
Show file tree
Hide file tree
Showing 47 changed files with 76 additions and 45 deletions.
17 changes: 17 additions & 0 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,21 @@ def migrate_route_table(self):
route_key = "ROUTE_TABLE:{}".format(route_prefix)
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')

def migrate_routing_config_mode(self):
# DEVICE_METADATA - synchronous_mode entry
if not self.minigraph_data or 'DEVICE_METADATA' not in self.minigraph_data:
return
device_metadata_old = self.configDB.get_entry('DEVICE_METADATA', 'localhost')
device_metadata_new = self.minigraph_data['DEVICE_METADATA']['localhost']
# overwrite the routing-config-mode as per minigraph parser
# Criteria for update:
# if config mode is missing in base OS or if base and target modes are not same
# Eg. in 201811 mode is "unified", and in newer branches mode is "separated"
if ('docker_routing_config_mode' not in device_metadata_old and 'docker_routing_config_mode' in device_metadata_new) or \
(device_metadata_old.get('docker_routing_config_mode') != device_metadata_new.get('docker_routing_config_mode')):
device_metadata_old['docker_routing_config_mode'] = device_metadata_new.get('docker_routing_config_mode')
self.configDB.set_entry('DEVICE_METADATA', 'localhost', device_metadata_old)

def update_edgezone_aggregator_config(self):
"""
Update cable length configuration in ConfigDB for T0 neighbor interfaces
Expand Down Expand Up @@ -985,6 +1000,8 @@ def common_migration_ops(self):

# 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
self.migrate_routing_config_mode()

def migrate(self):
version = self.get_version()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "ACS-MSN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "ACS-MSN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@
"bgp_asn": "65100",
"buffer_model": "dynamic",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"LOSSLESS_TRAFFIC_PATTERN|AZURE": {
"small_packet_percentage": "100",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@
"bgp_asn": "65100",
"buffer_model": "dynamic",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"LOSSLESS_TRAFFIC_PATTERN|AZURE": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
},
"CONSOLE_SWITCH|console_mgmt": {
"enabled": "no"
}
}
},
"DEVICE_METADATA|localhost": {
"docker_routing_config_mode": "separated"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"DEVICE_METADATA|localhost": {
"docker_routing_config_mode": "unified"
}
}

3 changes: 2 additions & 1 deletion tests/db_migrator_input/config_db/empty-config-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"VERSION": "version_3_0_3"
},
"DEVICE_METADATA|localhost": {
"synchronous_mode": "enable"
"synchronous_mode": "enable",
"docker_routing_config_mode": "separated"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "Mellanox-SN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "Mellanox-SN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@
"bgp_asn": "65100",
"buffer_model": "traditional",
"deployment_id": "1",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"synchronous_mode": "enable"
},
"PORT|Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "ACS-MSN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
"DEVICE_METADATA|localhost": {
"hwsku": "ACS-MSN2700",
"default_bgp_status": "up",
"docker_routing_config_mode": "unified",
"docker_routing_config_mode": "separated",
"hostname": "sonic",
"platform": "x86_64-mlnx_msn2700-r0",
"mac": "00:01:02:03:04:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"bgp_asn": "65100",
"buffer_model": "dynamic",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"bgp_asn": "65100",
"buffer_model": "dynamic",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"bgp_asn": "65100",
"buffer_model": "dynamic",
"deployment_id": "1",
"docker_routing_config_mode": "unified"
"docker_routing_config_mode": "separated"
},
"PORT|Ethernet0": {
"lanes": "0,1,2,3",
Expand Down
Loading

0 comments on commit bef3ffe

Please sign in to comment.