Skip to content

Commit

Permalink
Fix version in db_migrator for PORT_QOS_MAP|global (#2289)
Browse files Browse the repository at this point in the history
* Fix db_migrator version for PORT_QOS_MAP|global
  • Loading branch information
bingwang-ms committed Aug 3, 2022
1 parent 92b889b commit c6794b5
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 51 deletions.
39 changes: 25 additions & 14 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, namespace, socket=None):
none-zero values.
build: sequentially increase within a minor version domain.
"""
self.CURRENT_VERSION = 'version_3_0_6'
self.CURRENT_VERSION = 'version_3_0_5'

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -617,13 +617,13 @@ def version_1_0_6(self):
abandon_method = self.mellanox_buffer_migrator.mlnx_abandon_pending_buffer_configuration
append_method = self.mellanox_buffer_migrator.mlnx_append_item_on_pending_configuration_list

if self.mellanox_buffer_migrator.mlnx_migrate_buffer_pool_size('version_1_0_6', 'version_3_0_0') \
and self.mellanox_buffer_migrator.mlnx_migrate_buffer_profile('version_1_0_6', 'version_3_0_0') \
if self.mellanox_buffer_migrator.mlnx_migrate_buffer_pool_size('version_1_0_6', 'version_2_0_0') \
and self.mellanox_buffer_migrator.mlnx_migrate_buffer_profile('version_1_0_6', 'version_2_0_0') \
and (not self.mellanox_buffer_migrator.mlnx_is_buffer_model_dynamic() or \
self.migrate_config_db_buffer_tables_for_dynamic_calculation(speed_list, cable_len_list, '0', abandon_method, append_method)) \
and self.mellanox_buffer_migrator.mlnx_flush_new_buffer_configuration() \
and self.prepare_dynamic_buffer_for_warm_reboot(buffer_pools, buffer_profiles, buffer_pgs):
self.set_version('version_3_0_0')
self.set_version('version_2_0_0')
else:
self.prepare_dynamic_buffer_for_warm_reboot()

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

self.set_version('version_3_0_0')
self.set_version('version_2_0_0')

return 'version_2_0_0'

def version_2_0_0(self):
"""
Version 2_0_0
"""
log.log_info('Handling version_2_0_0')
self.migrate_port_qos_map_global()
self.set_version('version_2_0_1')
return 'version_2_0_1'

def version_2_0_1(self):
"""
Version 2_0_1.
This is the latest version for 202012 branch
"""
log.log_info('Handling version_2_0_1')
self.set_version('version_3_0_0')
return 'version_3_0_0'

def version_3_0_0(self):
Expand Down Expand Up @@ -694,21 +712,14 @@ def version_3_0_4(self):
if 'pfc_enable' in v:
v['pfcwd_sw_enable'] = v['pfc_enable']
self.configDB.set_entry('PORT_QOS_MAP', k, v)
self.set_version('version_3_0_5')
return 'version_3_0_5'

def version_3_0_5(self):
"""
Version 3_0_5
"""
log.log_info('Handling version_3_0_5')
self.migrate_port_qos_map_global()
return 'version_3_0_6'

def version_3_0_6(self):
"""
Current latest version. Nothing to do here.
"""
log.log_info('Handling version_3_0_6')
log.log_info('Handling version_3_0_5')
return None

def get_version(self):
Expand Down
4 changes: 2 additions & 2 deletions scripts/mellanox_buffer_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ def __init__(self, configDB, appDB, stateDB):
"spc2_3800-d24c52_t1_pool_shp", "spc2_3800-d28c50_t1_pool_shp"],
}
},
"version_3_0_0": {
# Version 3.0.0 is introduced for dynamic buffer calculation
"version_2_0_0": {
# Version 2.0.0 is introduced for dynamic buffer calculation
#
"pool_mapped_from_old_version": {
"spc1_t0_pool": "spc1_pool",
Expand Down
32 changes: 16 additions & 16 deletions tests/db_migrator_input/config_db/qos_map_table_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
"VERSION": "version_3_0_5"
},
"PORT_QOS_MAP|Ethernet0": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"dscp_to_tc_map": "AZURE",
"pfc_enable": "3,4",
"pfcwd_sw_enable": "3,4",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet100": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"dscp_to_tc_map": "AZURE",
"pfc_enable": "3,4",
"pfcwd_sw_enable": "3,4",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet92": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"dscp_to_tc_map": "AZURE",
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet96": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"dscp_to_tc_map": "AZURE",
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_6"
"VERSION": "version_2_0_1"
},
"DSCP_TO_TC_MAP|AZURE": {
"0": "0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_5"
"VERSION": "version_2_0_0"
},
"DSCP_TO_TC_MAP|AZURE": {
"0": "0",
Expand Down
32 changes: 16 additions & 16 deletions tests/db_migrator_input/config_db/qos_map_table_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
"VERSION": "version_3_0_4"
},
"PORT_QOS_MAP|Ethernet0": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"dscp_to_tc_map": "AZURE",
"pfc_enable": "3,4",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet100": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"dscp_to_tc_map": "AZURE",
"pfc_enable": "3,4",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet92": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"dscp_to_tc_map": "AZURE",
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
},
"PORT_QOS_MAP|Ethernet96": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
"tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
"tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]"
"dscp_to_tc_map": "AZURE",
"pfc_to_queue_map": "AZURE",
"tc_to_pg_map": "AZURE",
"tc_to_queue_map": "AZURE"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,6 @@
"admin_status": "up"
},
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_4"
"VERSION": "version_3_0_5"
}
}

0 comments on commit c6794b5

Please sign in to comment.