From 66e78174a7269cccc3da97b2b0f3846b69d6b8e7 Mon Sep 17 00:00:00 2001 From: DavidZagury <32644413+DavidZagury@users.noreply.github.com> Date: Tue, 13 Jul 2021 10:12:05 +0300 Subject: [PATCH] [pcied] Fix pcied failure to load due to 'pcied NameError: name 'self' is not defined' (#198) Fix Azure/sonic-buildimage#7993 - Fixes wrong log line when Pcie module does not exists that causes the pcied daemon to enter FATAL state. - Change log level of line "Failed to load platform Pcie module" to notice since this is not an error flow, this is part of the normal loading flow we expect when a vendor didn't supply a Pcie class. --- sonic-pcied/scripts/pcied | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sonic-pcied/scripts/pcied b/sonic-pcied/scripts/pcied index 7265063ff894..f88f159d1f64 100644 --- a/sonic-pcied/scripts/pcied +++ b/sonic-pcied/scripts/pcied @@ -10,7 +10,7 @@ import signal import sys import threading -from sonic_py_common import daemon_base, device_info +from sonic_py_common import daemon_base, device_info, logger from swsscommon import swsscommon # @@ -35,6 +35,8 @@ PCIEUTIL_LOAD_ERROR = 2 platform_pcieutil = None +log = logger.Logger(SYSLOG_IDENTIFIER) + exit_code = 0 # wrapper functions to call the platform api @@ -45,12 +47,12 @@ def load_platform_pcieutil(): from sonic_platform.pcie import Pcie _platform_pcieutil = Pcie(platform_path) except ImportError as e: - self.log_error("Failed to load platform Pcie module. Error : {}".format(str(e)), True) + log.log_notice("Failed to load platform Pcie module. Error : {}, Fallback to default module".format(str(e)), True) try: from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil _platform_pcieutil = PcieUtil(platform_path) except ImportError as e: - self.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) + log.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True) return _platform_pcieutil def read_id_file(device_name):