Skip to content

Commit bb0612a

Browse files
Support for single ASIC VOQ Fixed-Systems (#24163)
Fixed system single asic VOQs do not have chassis app DB How I did it updated a function that checks for chassis to include if the voq is a fixed system swss.sh cleanup function is updated to check for chassis app db first
1 parent fbfd224 commit bb0612a

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

files/scripts/swss.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,19 @@ function clean_up_chassis_db_tables()
240240
{
241241

242242
switch_type=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'switch_type'`
243+
platform=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'platform'`
243244

244245
# Run clean up only in swss running for voq switches
245246
if is_chassis_supervisor || [[ $switch_type != 'voq' ]]; then
246247
return
247248
fi
248249

250+
chassis_config="/usr/share/sonic/device/$platform/chassisdb.conf"
251+
if [ ! -e $chassis_config ]; then
252+
debug "No chassis config found"
253+
return
254+
fi
255+
249256
until [[ $($SONIC_DB_CLI CHASSIS_APP_DB PING | grep -c True) -gt 0 ]]; do
250257
sleep 1
251258
done

src/sonic-py-common/sonic_py_common/device_info.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
NAMESPACE_PATH_GLOB = "/run/netns/*"
3838
ASIC_CONF_FILENAME = "asic.conf"
3939
PLATFORM_ENV_CONF_FILENAME = "platform_env.conf"
40+
CHASSIS_DB_CONF_FILENAME = "chassisdb.conf"
4041
FRONTEND_ASIC_SUB_ROLE = "FrontEnd"
4142
BACKEND_ASIC_SUB_ROLE = "BackEnd"
4243
VS_PLATFORM = "x86_64-kvm_x86_64-r0"
@@ -243,6 +244,29 @@ def get_platform_env_conf_file_path():
243244
return None
244245

245246

247+
def get_chassis_db_conf_file_path():
248+
"""
249+
Retrieves the path to the Chassis DB configuration file on the device
250+
251+
Returns:
252+
A string containing the path to the Chassis DB configuration file on success,
253+
None on failure
254+
"""
255+
chassis_db_conf_path_candidates = []
256+
257+
chassis_db_conf_path_candidates.append(os.path.join(CONTAINER_PLATFORM_PATH, CHASSIS_DB_CONF_FILENAME))
258+
259+
platform = get_platform()
260+
if platform:
261+
chassis_db_conf_path_candidates.append(os.path.join(HOST_DEVICE_PATH, platform, CHASSIS_DB_CONF_FILENAME))
262+
263+
for chassis_db_conf_file_path in chassis_db_conf_path_candidates:
264+
if os.path.isfile(chassis_db_conf_file_path):
265+
return chassis_db_conf_file_path
266+
267+
return None
268+
269+
246270
def get_path_to_platform_dir():
247271
"""
248272
Retreives the paths to the device's platform directory
@@ -590,9 +614,19 @@ def is_multi_npu():
590614
return (num_npus > 1)
591615

592616

617+
def is_chassis_config_absent():
618+
chassis_db_conf_file_path = get_chassis_db_conf_file_path()
619+
if chassis_db_conf_file_path is None:
620+
return True
621+
622+
return False
623+
624+
593625
def is_voq_chassis():
594626
switch_type = get_platform_info().get('switch_type')
595-
return True if switch_type and (switch_type == 'voq' or switch_type == 'fabric') else False
627+
single_voq = is_chassis_config_absent()
628+
629+
return bool(switch_type and (switch_type == 'voq' or switch_type == 'fabric') and not single_voq)
596630

597631

598632
def is_packet_chassis():

src/sonic-py-common/tests/device_info_test.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,43 +120,57 @@ def test_get_sonic_version(self, mock_isfile):
120120
# Assert the file was read only once
121121
open_mocked.assert_called_once_with(device_info.SONIC_VERSION_YAML_PATH)
122122

123+
@mock.patch("sonic_py_common.device_info.is_chassis_config_absent")
123124
@mock.patch("sonic_py_common.device_info.get_platform_info")
124125
@mock.patch("sonic_py_common.device_info.is_disaggregated_chassis")
125-
def test_is_chassis(self, mock_is_disaggregated_chassis, mock_platform_info):
126+
def test_is_chassis(self, mock_is_disaggregated_chassis, mock_platform_info, mock_is_chassis_config_absent):
126127
mock_platform_info.return_value = {"switch_type": "npu"}
127128
mock_is_disaggregated_chassis.return_value = False
129+
mock_is_chassis_config_absent.return_value = False
128130
assert device_info.is_chassis() == False
129131
assert device_info.is_voq_chassis() == False
130132
assert device_info.is_packet_chassis() == False
131133

132134
mock_platform_info.return_value = {"switch_type": "voq"}
133135
mock_is_disaggregated_chassis.return_value = False
136+
mock_is_chassis_config_absent.return_value = False
134137
assert device_info.is_voq_chassis() == True
135138
assert device_info.is_packet_chassis() == False
136139
assert device_info.is_chassis() == True
137140

138141
mock_platform_info.return_value = {"switch_type": "voq"}
139142
mock_is_disaggregated_chassis.return_value = True
143+
mock_is_chassis_config_absent.return_value = False
140144
assert device_info.is_voq_chassis() == True
141145
assert device_info.is_packet_chassis() == False
142146
assert device_info.is_chassis() == False
143147

148+
mock_platform_info.return_value = {"switch_type": "voq"}
149+
mock_is_disaggregated_chassis.return_value = False
150+
mock_is_chassis_config_absent.return_value = True
151+
assert device_info.is_voq_chassis() == False
152+
assert device_info.is_packet_chassis() == False
153+
assert device_info.is_chassis() == False
154+
144155
mock_platform_info.return_value = {"switch_type": "chassis-packet"}
145156
mock_is_disaggregated_chassis.return_value = False
157+
mock_is_chassis_config_absent.return_value = False
146158
assert device_info.is_voq_chassis() == False
147159
assert device_info.is_packet_chassis() == True
148160
assert device_info.is_chassis() == True
149161

150162
mock_platform_info.return_value = {"switch_type": "dummy-sup",
151163
"asic_type": "vs"}
152164
mock_is_disaggregated_chassis.return_value = False
165+
mock_is_chassis_config_absent.return_value = False
153166
assert device_info.is_voq_chassis() == False
154167
assert device_info.is_packet_chassis() == False
155168
assert device_info.is_virtual_chassis() == True
156169
assert device_info.is_chassis() == True
157170

158171
mock_platform_info.return_value = {}
159172
mock_is_disaggregated_chassis.return_value = False
173+
mock_is_chassis_config_absent.return_value = False
160174
assert device_info.is_voq_chassis() == False
161175
assert device_info.is_packet_chassis() == False
162176
assert device_info.is_chassis() == False

0 commit comments

Comments
 (0)