[Mellanox] fix sysfs reading that gets garbage end of line using strip (#17830)

- Why I did it
when reading sysfs fd upon python poller events, there's end of line garbage like "# 012" (without space between the 2 parts) trailing the real value of 1 or 0

- How I did it
using python strip() to remove end of line

- How to verify it
run the CMIS host management feature on a switch
wait few minutes until switch completes boot up sequence including CMIS host manager
then disconnect or reconnect a port to create a poller event
This commit is contained in:
dbarashinvd 2024-02-05 19:39:55 +02:00 committed by GitHub
parent 529031210f
commit 0aacc1f28e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
# Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -280,13 +280,10 @@ class ModulesMgmtTask(threading.Thread):
self.fds_events_count_dict[module_obj.port_num][fd_name] += 1
try:
module_fd.seek(0)
val = module_fd.read()
val = module_fd.read().strip()
logger.log_info("dynamic detection got module_obj {} with port {} from fd number {} path {} val {} count {}"
.format(module_obj, module_obj.port_num, fd, module_fd_path
, val, self.fds_events_count_dict[module_obj.port_num]))
# workaround for garbage received after the 0 or 1 value of sysfs i.e. 0#012 or 1#012
if len(val) > 1:
val = val[0]
if self.is_dummy_event(int(val), module_obj):
logger.log_info(f"dynamic detection dummy event port {module_obj.port_num} from fd number {fd}")
continue