Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version in db_migrator for PORT_QOS_MAP|global #2289

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix db_migrator version for PORT_QOS_MAP|global
bingwang-ms committed Aug 2, 2022
commit 669460d04b5b286915265ecf6387e1f10d60c654
39 changes: 25 additions & 14 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
@@ -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'
@@ -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()

@@ -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):
@@ -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):
4 changes: 2 additions & 2 deletions scripts/mellanox_buffer_migrator.py
Original file line number Diff line number Diff line change
@@ -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",
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_5"
"VERSION": "version_3_0_4"
},
"PORT_QOS_MAP|Ethernet0": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
2 changes: 1 addition & 1 deletion tests/db_migrator_input/config_db/qos_map_table_input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_3_0_4"
"VERSION": "version_1_0_6"
},
"PORT_QOS_MAP|Ethernet0": {
"dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]",
2 changes: 2 additions & 0 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
@@ -400,6 +400,7 @@ def test_global_dscp_to_tc_map_migrator(self):

diff = DeepDiff(resulting_table, expected_table, ignore_order=True)
assert not diff
assert dbmgtr.configDB.get_table('VERSIONS') == expected_db.cfgdb.get_table('VERSIONS')

# Check port_qos_map|global is not generated on mellanox asic
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'qos_map_table_global_input')
@@ -409,4 +410,5 @@ def test_global_dscp_to_tc_map_migrator(self):
dbmgtr_mlnx.migrate()
resulting_table = dbmgtr_mlnx.configDB.get_table('PORT_QOS_MAP')
assert resulting_table == {}
assert dbmgtr.configDB.get_table('VERSIONS') == expected_db.cfgdb.get_table('VERSIONS')