Skip to content

Commit c6794b5

Browse files
authored
Fix version in db_migrator for PORT_QOS_MAP|global (#2289)
* Fix db_migrator version for PORT_QOS_MAP|global
1 parent 92b889b commit c6794b5

7 files changed

+62
-51
lines changed

scripts/db_migrator.py

+25-14
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, namespace, socket=None):
4444
none-zero values.
4545
build: sequentially increase within a minor version domain.
4646
"""
47-
self.CURRENT_VERSION = 'version_3_0_6'
47+
self.CURRENT_VERSION = 'version_3_0_5'
4848

4949
self.TABLE_NAME = 'VERSIONS'
5050
self.TABLE_KEY = 'DATABASE'
@@ -617,13 +617,13 @@ def version_1_0_6(self):
617617
abandon_method = self.mellanox_buffer_migrator.mlnx_abandon_pending_buffer_configuration
618618
append_method = self.mellanox_buffer_migrator.mlnx_append_item_on_pending_configuration_list
619619

620-
if self.mellanox_buffer_migrator.mlnx_migrate_buffer_pool_size('version_1_0_6', 'version_3_0_0') \
621-
and self.mellanox_buffer_migrator.mlnx_migrate_buffer_profile('version_1_0_6', 'version_3_0_0') \
620+
if self.mellanox_buffer_migrator.mlnx_migrate_buffer_pool_size('version_1_0_6', 'version_2_0_0') \
621+
and self.mellanox_buffer_migrator.mlnx_migrate_buffer_profile('version_1_0_6', 'version_2_0_0') \
622622
and (not self.mellanox_buffer_migrator.mlnx_is_buffer_model_dynamic() or \
623623
self.migrate_config_db_buffer_tables_for_dynamic_calculation(speed_list, cable_len_list, '0', abandon_method, append_method)) \
624624
and self.mellanox_buffer_migrator.mlnx_flush_new_buffer_configuration() \
625625
and self.prepare_dynamic_buffer_for_warm_reboot(buffer_pools, buffer_profiles, buffer_pgs):
626-
self.set_version('version_3_0_0')
626+
self.set_version('version_2_0_0')
627627
else:
628628
self.prepare_dynamic_buffer_for_warm_reboot()
629629

@@ -632,8 +632,26 @@ def version_1_0_6(self):
632632
self.configDB.set_entry('DEVICE_METADATA', 'localhost', metadata)
633633
log.log_notice('Setting buffer_model to traditional')
634634

635-
self.set_version('version_3_0_0')
635+
self.set_version('version_2_0_0')
636636

637+
return 'version_2_0_0'
638+
639+
def version_2_0_0(self):
640+
"""
641+
Version 2_0_0
642+
"""
643+
log.log_info('Handling version_2_0_0')
644+
self.migrate_port_qos_map_global()
645+
self.set_version('version_2_0_1')
646+
return 'version_2_0_1'
647+
648+
def version_2_0_1(self):
649+
"""
650+
Version 2_0_1.
651+
This is the latest version for 202012 branch
652+
"""
653+
log.log_info('Handling version_2_0_1')
654+
self.set_version('version_3_0_0')
637655
return 'version_3_0_0'
638656

639657
def version_3_0_0(self):
@@ -694,21 +712,14 @@ def version_3_0_4(self):
694712
if 'pfc_enable' in v:
695713
v['pfcwd_sw_enable'] = v['pfc_enable']
696714
self.configDB.set_entry('PORT_QOS_MAP', k, v)
715+
self.set_version('version_3_0_5')
697716
return 'version_3_0_5'
698717

699718
def version_3_0_5(self):
700-
"""
701-
Version 3_0_5
702-
"""
703-
log.log_info('Handling version_3_0_5')
704-
self.migrate_port_qos_map_global()
705-
return 'version_3_0_6'
706-
707-
def version_3_0_6(self):
708719
"""
709720
Current latest version. Nothing to do here.
710721
"""
711-
log.log_info('Handling version_3_0_6')
722+
log.log_info('Handling version_3_0_5')
712723
return None
713724

714725
def get_version(self):

scripts/mellanox_buffer_migrator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ def __init__(self, configDB, appDB, stateDB):
480480
"spc2_3800-d24c52_t1_pool_shp", "spc2_3800-d28c50_t1_pool_shp"],
481481
}
482482
},
483-
"version_3_0_0": {
484-
# Version 3.0.0 is introduced for dynamic buffer calculation
483+
"version_2_0_0": {
484+
# Version 2.0.0 is introduced for dynamic buffer calculation
485485
#
486486
"pool_mapped_from_old_version": {
487487
"spc1_t0_pool": "spc1_pool",

tests/db_migrator_input/config_db/qos_map_table_expected.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
"VERSION": "version_3_0_5"
44
},
55
"PORT_QOS_MAP|Ethernet0": {
6-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
6+
"dscp_to_tc_map": "AZURE",
77
"pfc_enable": "3,4",
88
"pfcwd_sw_enable": "3,4",
9-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
10-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
11-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
9+
"pfc_to_queue_map": "AZURE",
10+
"tc_to_pg_map": "AZURE",
11+
"tc_to_queue_map": "AZURE"
1212
},
1313
"PORT_QOS_MAP|Ethernet100": {
14-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
14+
"dscp_to_tc_map": "AZURE",
1515
"pfc_enable": "3,4",
1616
"pfcwd_sw_enable": "3,4",
17-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
18-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
19-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
17+
"pfc_to_queue_map": "AZURE",
18+
"tc_to_pg_map": "AZURE",
19+
"tc_to_queue_map": "AZURE"
2020
},
2121
"PORT_QOS_MAP|Ethernet92": {
22-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
23-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
24-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
25-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
22+
"dscp_to_tc_map": "AZURE",
23+
"pfc_to_queue_map": "AZURE",
24+
"tc_to_pg_map": "AZURE",
25+
"tc_to_queue_map": "AZURE"
2626
},
2727
"PORT_QOS_MAP|Ethernet96": {
28-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
29-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
30-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
31-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
28+
"dscp_to_tc_map": "AZURE",
29+
"pfc_to_queue_map": "AZURE",
30+
"tc_to_pg_map": "AZURE",
31+
"tc_to_queue_map": "AZURE"
3232
}
3333
}
3434

tests/db_migrator_input/config_db/qos_map_table_global_expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"VERSIONS|DATABASE": {
3-
"VERSION": "version_3_0_6"
3+
"VERSION": "version_2_0_1"
44
},
55
"DSCP_TO_TC_MAP|AZURE": {
66
"0": "0",

tests/db_migrator_input/config_db/qos_map_table_global_input.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"VERSIONS|DATABASE": {
3-
"VERSION": "version_3_0_5"
3+
"VERSION": "version_2_0_0"
44
},
55
"DSCP_TO_TC_MAP|AZURE": {
66
"0": "0",

tests/db_migrator_input/config_db/qos_map_table_input.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
"VERSION": "version_3_0_4"
44
},
55
"PORT_QOS_MAP|Ethernet0": {
6-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
6+
"dscp_to_tc_map": "AZURE",
77
"pfc_enable": "3,4",
8-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
9-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
10-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
8+
"pfc_to_queue_map": "AZURE",
9+
"tc_to_pg_map": "AZURE",
10+
"tc_to_queue_map": "AZURE"
1111
},
1212
"PORT_QOS_MAP|Ethernet100": {
13-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
13+
"dscp_to_tc_map": "AZURE",
1414
"pfc_enable": "3,4",
15-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
16-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
17-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
15+
"pfc_to_queue_map": "AZURE",
16+
"tc_to_pg_map": "AZURE",
17+
"tc_to_queue_map": "AZURE"
1818
},
1919
"PORT_QOS_MAP|Ethernet92": {
20-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
21-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
22-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
23-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
20+
"dscp_to_tc_map": "AZURE",
21+
"pfc_to_queue_map": "AZURE",
22+
"tc_to_pg_map": "AZURE",
23+
"tc_to_queue_map": "AZURE"
2424
},
2525
"PORT_QOS_MAP|Ethernet96": {
26-
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
27-
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
28-
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
29-
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
26+
"dscp_to_tc_map": "AZURE",
27+
"pfc_to_queue_map": "AZURE",
28+
"tc_to_pg_map": "AZURE",
29+
"tc_to_queue_map": "AZURE"
3030
}
3131
}

tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,6 @@
20432043
"admin_status": "up"
20442044
},
20452045
"VERSIONS|DATABASE": {
2046-
"VERSION": "version_3_0_4"
2046+
"VERSION": "version_3_0_5"
20472047
}
20482048
}

0 commit comments

Comments
 (0)