From 30f691a06b254ccf459f9c82a206247430d58b71 Mon Sep 17 00:00:00 2001 From: Douglas Henrique Koerich Date: Fri, 30 Sep 2022 18:04:32 -0300 Subject: [PATCH] [PTP] Fix startup crash with bad override. During tests with the ptp-notification app it was observed that a bad override could crash the startup script of ptptracking (notification service). This minor change fixes that. Test Plan: PASS: Build and deploy new ptptracking image PASS: Startup of ptptracking container Story: 2010056 Task: 46496 Signed-off-by: Douglas Henrique Koerich Change-Id: I659e0e1bc812cca73b34079f4cf207a91843dfdc --- .../scripts/init/ptptracking_start.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/stx-ptp-notification-helm/stx-ptp-notification-helm/helm-charts/ptp-notification/resources/scripts/init/ptptracking_start.py b/stx-ptp-notification-helm/stx-ptp-notification-helm/helm-charts/ptp-notification/resources/scripts/init/ptptracking_start.py index 3ba47cb..56ef9d2 100644 --- a/stx-ptp-notification-helm/stx-ptp-notification-helm/helm-charts/ptp-notification/resources/scripts/init/ptptracking_start.py +++ b/stx-ptp-notification-helm/stx-ptp-notification-helm/helm-charts/ptp-notification/resources/scripts/init/ptptracking_start.py @@ -55,20 +55,22 @@ OS_CLOCK_POLL_FREQ_SECONDS = os.environ.get("OS_CLOCK_POLL_FREQ_SECONDS", 2) OVERALL_HOLDOVER_SECONDS = os.environ.get("OVERALL_HOLDOVER_SECONDS", 30) OVERALL_POLL_FREQ_SECONDS = os.environ.get("OVERALL_POLL_FREQ_SECONDS", 2) +PHC2SYS_CONFIG = None +PHC2SYS_SERVICE_NAME = None if os.environ.get("PHC2SYS_SERVICE_NAME").lower() == "false": LOG.info("OS Clock tracking disabled.") - PHC2SYS_CONFIG = None else: - PHC2SYS_CONFIG = glob.glob("/ptp/ptpinstance/phc2sys-*") - if len(PHC2SYS_CONFIG) == 0: + PHC2SYS_CONFIGS = glob.glob("/ptp/ptpinstance/phc2sys-*") + if len(PHC2SYS_CONFIGS) == 0: LOG.warning("No phc2sys config found.") - PHC2SYS_CONFIG = None - elif len(PHC2SYS_CONFIG) > 1: - LOG.warning("Multiple phc2sys instances found, selecting %s" % PHC2SYS_CONFIG[0]) - PHC2SYS_CONFIG = PHC2SYS_CONFIG[0] - pattern = '(?<=/ptp/ptpinstance/phc2sys-).*(?=.conf)' - match = re.search(pattern, PHC2SYS_CONFIG) - PHC2SYS_SERVICE_NAME = match.group() + else: + PHC2SYS_CONFIG = PHC2SYS_CONFIGS[0] + if len(PHC2SYS_CONFIGS) > 1: + LOG.warning("Multiple phc2sys instances found, selecting %s" % + PHC2SYS_CONFIG) + pattern = '(?<=/ptp/ptpinstance/phc2sys-).*(?=.conf)' + match = re.search(pattern, PHC2SYS_CONFIG) + PHC2SYS_SERVICE_NAME = match.group() PTP4L_CONFIGS = [] PTP4L_INSTANCES = []