From 76d515c2907e00a2f11117a8323d26fa3db08392 Mon Sep 17 00:00:00 2001 From: Cole Walker Date: Thu, 29 Aug 2024 10:43:08 -0400 Subject: [PATCH] Handle missing sysfs path for in-tree ice driver The in-tree ice driver version 6.6.40-stx.2 does not provide the debugfs path used for monitoring the GNSS state. This commit provides the following changes to support this driver: 1: Update the k8s daemonset to mount the /sys/kernel/debug path instead of /sys/kernel/debug/ice. The "ice" directory is not present using the in-tree driver, so mounting the parent directory allows the containers to be properly started and can then check if the "ice" directory is present at runtime 2: Update the startup script for the v2 container to check for the existence of the ice debugfs directory. If it is not present, disable GNSS tracking in ptp-notification 3: Update the path used by GNSS monitoring to match the changed mount path in the daemonset so that GNSS monitoring can proceed when the path is present Currently, GNSS time sources and monitoring cannot be used with the in-tree driver. GNSS time sources require configuring the system to use the out-of-tree ice driver. Test plan: Pass: Verify helm chart and container build Pass: Verify ptp-notification deployment using the in-tree ice driver, ensure that GNSS tracking is automatically disabled when debugfs is not present Pass: Verify ptp-notification deployment using the out-of-tree ice driver, ensure that GNSS tracking is operational when debugfs is present Story: 2011056 Task: 50940 Signed-off-by: Cole Walker Change-Id: I73859408cf5655b58ebe2a1a78f407496c3380dd --- .../resources/scripts/init/ptptracking_start_v2.py | 6 ++++++ .../ptp-notification/templates/daemonset.yaml | 2 +- .../trackingfunctionsdk/common/helpers/cgu_handler.py | 2 +- .../trackingfunctionsdk/tests/test_cgu_handler.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/resources/scripts/init/ptptracking_start_v2.py b/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/resources/scripts/init/ptptracking_start_v2.py index dc97320..33a0790 100644 --- a/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/resources/scripts/init/ptptracking_start_v2.py +++ b/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/resources/scripts/init/ptptracking_start_v2.py @@ -11,6 +11,8 @@ import logging import os import re +from pathlib import Path + from trackingfunctionsdk.common.helpers import log_helper from trackingfunctionsdk.common.helpers import constants from trackingfunctionsdk.services.daemon import DaemonControl @@ -85,8 +87,12 @@ else: GNSS_CONFIGS = [] GNSS_INSTANCES = [] +ice_debugfs = Path("/ice/ice/") if os.environ.get("TS2PHC_SERVICE_NAME").lower() == "false": LOG.info("GNSS instance tracking disabled.") +elif not ice_debugfs.is_dir(): + LOG.info("Ice driver debugfs is not present, GNSS instance tracking disabled.") + os.environ["TS2PHC_SERVICE_NAME"] = "false" else: GNSS_CONFIGS = glob.glob(constants.TS2PHC_CONFIG_PATH + "ts2phc-*") LOG.debug('Looked for ts2phc configuration file(s) in %s, found %d' diff --git a/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/templates/daemonset.yaml b/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/templates/daemonset.yaml index ce261dd..e2b1773 100644 --- a/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/templates/daemonset.yaml +++ b/helm-charts/custom/ptp-notification-helm/ptp-notification-helm/ptp-notification/templates/daemonset.yaml @@ -349,7 +349,7 @@ spec: type: Directory - name: ice hostPath: - path: /sys/kernel/debug/ice/ + path: /sys/kernel/debug/ type: Directory - name: proc hostPath: diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py index 2e413f6..9287eca 100644 --- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/cgu_handler.py @@ -65,7 +65,7 @@ class CguHandler: def get_cgu_path_from_pci_addr(self): # Search for a cgu file using the given pci address - cgu_path = "/ice/" + self.pci_addr + "/cgu" + cgu_path = "/ice/ice/" + self.pci_addr + "/cgu" if os.path.exists(cgu_path): LOG.debug("PCI address %s has cgu path %s" % (self.pci_addr, cgu_path)) diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py index 9da9bdc..43c9d16 100644 --- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_cgu_handler.py @@ -55,7 +55,7 @@ class CguHandlerTests(unittest.TestCase): read_data='PCI_SLOT_NAME=0000:18:00.0') as mock_open: self.testCguHandler.convert_nmea_serialport_to_pci_addr() self.testCguHandler.get_cgu_path_from_pci_addr() - self.assertEqual(self.testCguHandler.cgu_path, "/ice/0000:18:00.0/cgu") + self.assertEqual(self.testCguHandler.cgu_path, "/ice/ice/0000:18:00.0/cgu") mock_path.exists.return_value = False with self.assertRaises(FileNotFoundError):