Skip to content

Commit 7ca3147

Browse files
authored
[db_migrator] Set docker_routing_config_mode to the value obtained from minigraph parser (#2890)
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: #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.
1 parent ff380e0 commit 7ca3147

File tree

47 files changed

+77
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+77
-45
lines changed

scripts/db_migrator.py

+18
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ def migrate_feature_timer(self):
613613
config['delayed'] = state
614614
config.pop('has_timer')
615615
self.configDB.set_entry('FEATURE', feature, config)
616+
616617
def migrate_route_table(self):
617618
"""
618619
Handle route table migration. Migrations handled:
@@ -636,6 +637,21 @@ def migrate_route_table(self):
636637
if 'protocol' not in route_attr:
637638
self.appDB.set(self.appDB.APPL_DB, route_key, 'protocol', '')
638639

640+
def migrate_routing_config_mode(self):
641+
# DEVICE_METADATA - synchronous_mode entry
642+
if not self.minigraph_data or 'DEVICE_METADATA' not in self.minigraph_data:
643+
return
644+
device_metadata_old = self.configDB.get_entry('DEVICE_METADATA', 'localhost')
645+
device_metadata_new = self.minigraph_data['DEVICE_METADATA']['localhost']
646+
# overwrite the routing-config-mode as per minigraph parser
647+
# Criteria for update:
648+
# if config mode is missing in base OS or if base and target modes are not same
649+
# Eg. in 201811 mode is "unified", and in newer branches mode is "separated"
650+
if ('docker_routing_config_mode' not in device_metadata_old and 'docker_routing_config_mode' in device_metadata_new) or \
651+
(device_metadata_old.get('docker_routing_config_mode') != device_metadata_new.get('docker_routing_config_mode')):
652+
device_metadata_old['docker_routing_config_mode'] = device_metadata_new.get('docker_routing_config_mode')
653+
self.configDB.set_entry('DEVICE_METADATA', 'localhost', device_metadata_old)
654+
639655
def update_edgezone_aggregator_config(self):
640656
"""
641657
Update cable length configuration in ConfigDB for T0 neighbor interfaces
@@ -1057,6 +1073,8 @@ def common_migration_ops(self):
10571073

10581074
# Updating edgezone aggregator cable length config for T0 devices
10591075
self.update_edgezone_aggregator_config()
1076+
# update FRR config mode based on minigraph parser on target image
1077+
self.migrate_routing_config_mode()
10601078

10611079
def migrate(self):
10621080
version = self.get_version()

tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@
681681
"DEVICE_METADATA|localhost": {
682682
"hwsku": "ACS-MSN2700",
683683
"default_bgp_status": "up",
684-
"docker_routing_config_mode": "unified",
684+
"docker_routing_config_mode": "separated",
685685
"hostname": "sonic",
686686
"platform": "x86_64-mlnx_msn2700-r0",
687687
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@
681681
"DEVICE_METADATA|localhost": {
682682
"hwsku": "ACS-MSN2700",
683683
"default_bgp_status": "up",
684-
"docker_routing_config_mode": "unified",
684+
"docker_routing_config_mode": "separated",
685685
"hostname": "sonic",
686686
"platform": "x86_64-mlnx_msn2700-r0",
687687
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@
762762
"bgp_asn": "65100",
763763
"buffer_model": "dynamic",
764764
"deployment_id": "1",
765-
"docker_routing_config_mode": "unified"
765+
"docker_routing_config_mode": "separated"
766766
},
767767
"LOSSLESS_TRAFFIC_PATTERN|AZURE": {
768768
"small_packet_percentage": "100",

tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@
761761
"bgp_asn": "65100",
762762
"buffer_model": "dynamic",
763763
"deployment_id": "1",
764-
"docker_routing_config_mode": "unified",
764+
"docker_routing_config_mode": "separated",
765765
"synchronous_mode": "enable"
766766
},
767767
"LOSSLESS_TRAFFIC_PATTERN|AZURE": {

tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_expected.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
},
2323
"CONSOLE_SWITCH|console_mgmt": {
2424
"enabled": "no"
25-
}
26-
}
25+
},
26+
"DEVICE_METADATA|localhost": {
27+
"docker_routing_config_mode": "separated"
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2+
"DEVICE_METADATA|localhost": {
3+
"docker_routing_config_mode": "unified"
4+
}
25
}
36

tests/db_migrator_input/config_db/empty-config-expected.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"VERSION": "version_3_0_3"
44
},
55
"DEVICE_METADATA|localhost": {
6-
"synchronous_mode": "enable"
6+
"synchronous_mode": "enable",
7+
"docker_routing_config_mode": "separated"
78
}
89
}

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@
735735
"bgp_asn": "65100",
736736
"buffer_model": "traditional",
737737
"deployment_id": "1",
738-
"docker_routing_config_mode": "unified"
738+
"docker_routing_config_mode": "separated"
739739
},
740740
"PORT|Ethernet0": {
741741
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@
734734
"bgp_asn": "65100",
735735
"buffer_model": "traditional",
736736
"deployment_id": "1",
737-
"docker_routing_config_mode": "unified",
737+
"docker_routing_config_mode": "separated",
738738
"synchronous_mode": "enable"
739739
},
740740
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@
828828
"bgp_asn": "65100",
829829
"buffer_model": "traditional",
830830
"deployment_id": "1",
831-
"docker_routing_config_mode": "unified"
831+
"docker_routing_config_mode": "separated"
832832
},
833833
"PORT|Ethernet0": {
834834
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@
827827
"bgp_asn": "65100",
828828
"buffer_model": "traditional",
829829
"deployment_id": "1",
830-
"docker_routing_config_mode": "unified",
830+
"docker_routing_config_mode": "separated",
831831
"synchronous_mode": "enable"
832832
},
833833
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@
740740
"bgp_asn": "65100",
741741
"buffer_model": "traditional",
742742
"deployment_id": "1",
743-
"docker_routing_config_mode": "unified"
743+
"docker_routing_config_mode": "separated"
744744
},
745745
"PORT|Ethernet0": {
746746
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@
739739
"bgp_asn": "65100",
740740
"buffer_model": "traditional",
741741
"deployment_id": "1",
742-
"docker_routing_config_mode": "unified",
742+
"docker_routing_config_mode": "separated",
743743
"synchronous_mode": "enable"
744744
},
745745
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@
833833
"bgp_asn": "65100",
834834
"buffer_model": "traditional",
835835
"deployment_id": "1",
836-
"docker_routing_config_mode": "unified"
836+
"docker_routing_config_mode": "separated"
837837
},
838838
"PORT|Ethernet0": {
839839
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@
832832
"bgp_asn": "65100",
833833
"buffer_model": "traditional",
834834
"deployment_id": "1",
835-
"docker_routing_config_mode": "unified",
835+
"docker_routing_config_mode": "separated",
836836
"synchronous_mode": "enable"
837837
},
838838
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@
735735
"bgp_asn": "65100",
736736
"buffer_model": "traditional",
737737
"deployment_id": "1",
738-
"docker_routing_config_mode": "unified"
738+
"docker_routing_config_mode": "separated"
739739
},
740740
"PORT|Ethernet0": {
741741
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@
734734
"bgp_asn": "65100",
735735
"buffer_model": "traditional",
736736
"deployment_id": "1",
737-
"docker_routing_config_mode": "unified",
737+
"docker_routing_config_mode": "separated",
738738
"synchronous_mode": "enable"
739739
},
740740
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@
828828
"bgp_asn": "65100",
829829
"buffer_model": "traditional",
830830
"deployment_id": "1",
831-
"docker_routing_config_mode": "unified"
831+
"docker_routing_config_mode": "separated"
832832
},
833833
"PORT|Ethernet0": {
834834
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@
827827
"bgp_asn": "65100",
828828
"buffer_model": "traditional",
829829
"deployment_id": "1",
830-
"docker_routing_config_mode": "unified",
830+
"docker_routing_config_mode": "separated",
831831
"synchronous_mode": "enable"
832832
},
833833
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@
735735
"bgp_asn": "65100",
736736
"buffer_model": "traditional",
737737
"deployment_id": "1",
738-
"docker_routing_config_mode": "unified"
738+
"docker_routing_config_mode": "separated"
739739
},
740740
"PORT|Ethernet0": {
741741
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@
734734
"bgp_asn": "65100",
735735
"buffer_model": "traditional",
736736
"deployment_id": "1",
737-
"docker_routing_config_mode": "unified",
737+
"docker_routing_config_mode": "separated",
738738
"synchronous_mode": "enable"
739739
},
740740
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@
828828
"bgp_asn": "65100",
829829
"buffer_model": "traditional",
830830
"deployment_id": "1",
831-
"docker_routing_config_mode": "unified"
831+
"docker_routing_config_mode": "separated"
832832
},
833833
"PORT|Ethernet0": {
834834
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@
827827
"bgp_asn": "65100",
828828
"buffer_model": "traditional",
829829
"deployment_id": "1",
830-
"docker_routing_config_mode": "unified",
830+
"docker_routing_config_mode": "separated",
831831
"synchronous_mode": "enable"
832832
},
833833
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@
740740
"bgp_asn": "65100",
741741
"buffer_model": "traditional",
742742
"deployment_id": "1",
743-
"docker_routing_config_mode": "unified"
743+
"docker_routing_config_mode": "separated"
744744
},
745745
"PORT|Ethernet0": {
746746
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@
739739
"bgp_asn": "65100",
740740
"buffer_model": "traditional",
741741
"deployment_id": "1",
742-
"docker_routing_config_mode": "unified",
742+
"docker_routing_config_mode": "separated",
743743
"synchronous_mode": "enable"
744744
},
745745
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@
833833
"bgp_asn": "65100",
834834
"buffer_model": "traditional",
835835
"deployment_id": "1",
836-
"docker_routing_config_mode": "unified"
836+
"docker_routing_config_mode": "separated"
837837
},
838838
"PORT|Ethernet0": {
839839
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@
832832
"bgp_asn": "65100",
833833
"buffer_model": "traditional",
834834
"deployment_id": "1",
835-
"docker_routing_config_mode": "unified",
835+
"docker_routing_config_mode": "separated",
836836
"synchronous_mode": "enable"
837837
},
838838
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@
726726
"DEVICE_METADATA|localhost": {
727727
"hwsku": "Mellanox-SN2700",
728728
"default_bgp_status": "up",
729-
"docker_routing_config_mode": "unified",
729+
"docker_routing_config_mode": "separated",
730730
"hostname": "sonic",
731731
"platform": "x86_64-mlnx_msn2700-r0",
732732
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@
726726
"DEVICE_METADATA|localhost": {
727727
"hwsku": "Mellanox-SN2700",
728728
"default_bgp_status": "up",
729-
"docker_routing_config_mode": "unified",
729+
"docker_routing_config_mode": "separated",
730730
"hostname": "sonic",
731731
"platform": "x86_64-mlnx_msn2700-r0",
732732
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@
828828
"bgp_asn": "65100",
829829
"buffer_model": "traditional",
830830
"deployment_id": "1",
831-
"docker_routing_config_mode": "unified"
831+
"docker_routing_config_mode": "separated"
832832
},
833833
"PORT|Ethernet0": {
834834
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@
827827
"bgp_asn": "65100",
828828
"buffer_model": "traditional",
829829
"deployment_id": "1",
830-
"docker_routing_config_mode": "unified",
830+
"docker_routing_config_mode": "separated",
831831
"synchronous_mode": "enable"
832832
},
833833
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@
740740
"bgp_asn": "65100",
741741
"buffer_model": "traditional",
742742
"deployment_id": "1",
743-
"docker_routing_config_mode": "unified"
743+
"docker_routing_config_mode": "separated"
744744
},
745745
"PORT|Ethernet0": {
746746
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@
739739
"bgp_asn": "65100",
740740
"buffer_model": "traditional",
741741
"deployment_id": "1",
742-
"docker_routing_config_mode": "unified",
742+
"docker_routing_config_mode": "separated",
743743
"synchronous_mode": "enable"
744744
},
745745
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@
833833
"bgp_asn": "65100",
834834
"buffer_model": "traditional",
835835
"deployment_id": "1",
836-
"docker_routing_config_mode": "unified"
836+
"docker_routing_config_mode": "separated"
837837
},
838838
"PORT|Ethernet0": {
839839
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@
832832
"bgp_asn": "65100",
833833
"buffer_model": "traditional",
834834
"deployment_id": "1",
835-
"docker_routing_config_mode": "unified",
835+
"docker_routing_config_mode": "separated",
836836
"synchronous_mode": "enable"
837837
},
838838
"PORT|Ethernet0": {

tests/db_migrator_input/config_db/non-default-config-expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@
754754
"DEVICE_METADATA|localhost": {
755755
"hwsku": "ACS-MSN2700",
756756
"default_bgp_status": "up",
757-
"docker_routing_config_mode": "unified",
757+
"docker_routing_config_mode": "separated",
758758
"hostname": "sonic",
759759
"platform": "x86_64-mlnx_msn2700-r0",
760760
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/non-default-config-input.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730
"DEVICE_METADATA|localhost": {
731731
"hwsku": "ACS-MSN2700",
732732
"default_bgp_status": "up",
733-
"docker_routing_config_mode": "unified",
733+
"docker_routing_config_mode": "separated",
734734
"hostname": "sonic",
735735
"platform": "x86_64-mlnx_msn2700-r0",
736736
"mac": "00:01:02:03:04:00",

tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"bgp_asn": "65100",
208208
"buffer_model": "dynamic",
209209
"deployment_id": "1",
210-
"docker_routing_config_mode": "unified"
210+
"docker_routing_config_mode": "separated"
211211
},
212212
"PORT|Ethernet0": {
213213
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-input.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"bgp_asn": "65100",
124124
"buffer_model": "dynamic",
125125
"deployment_id": "1",
126-
"docker_routing_config_mode": "unified"
126+
"docker_routing_config_mode": "separated"
127127
},
128128
"PORT|Ethernet0": {
129129
"lanes": "0,1,2,3",

tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
"bgp_asn": "65100",
204204
"buffer_model": "dynamic",
205205
"deployment_id": "1",
206-
"docker_routing_config_mode": "unified"
206+
"docker_routing_config_mode": "separated"
207207
},
208208
"PORT|Ethernet0": {
209209
"lanes": "0,1,2,3",

0 commit comments

Comments
 (0)