From 476b66ac369a1f94015e7a2ea6c2542f13ce5515 Mon Sep 17 00:00:00 2001 From: Ray Chan Date: Mon, 13 Jan 2025 05:50:28 +0800 Subject: [PATCH] Avoid repeated restart snap service. (#386) The snap service will be restarted at the config_changed event, so it's not necessary to restart in the strategy class. --- src/hw_tools.py | 1 - tests/unit/test_hw_tools.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/hw_tools.py b/src/hw_tools.py index 6c35a05..0a43cf8 100644 --- a/src/hw_tools.py +++ b/src/hw_tools.py @@ -252,7 +252,6 @@ def _create_custom_metrics(self) -> None: try: shutil.copy(self.metric_file, self.snap_common) self.snap_client.set({"dcgm-exporter-metrics-file": self.metric_file.name}) - self.snap_client.restart(reload=True) except Exception as err: # pylint: disable=broad-except logger.error("Failed to configure custom DCGM metrics: %s", err) raise err diff --git a/tests/unit/test_hw_tools.py b/tests/unit/test_hw_tools.py index 75cb869..cf9340b 100644 --- a/tests/unit/test_hw_tools.py +++ b/tests/unit/test_hw_tools.py @@ -1214,7 +1214,6 @@ def test_dcgm_create_custom_metrics(dcgm_exporter_strategy, mock_shutil_copy, mo dcgm_exporter_strategy.snap_client.set.assert_called_once_with( {"dcgm-exporter-metrics-file": "dcgm_metrics.csv"} ) - dcgm_exporter_strategy.snap_client.restart.assert_called_once_with(reload=True) def test_dcgm_create_custom_metrics_copy_fail(