From 8cf5506700a7bcd396282c4fcf3b137ab9440b33 Mon Sep 17 00:00:00 2001 From: David Esparza Date: Mon, 16 Oct 2023 15:57:57 -0600 Subject: [PATCH] metrics: fixes common.sh function to always return true This PR corrects the init env() helper function, to make that systemctl always returns true when enumerating masked services, and preventing the test from failing Fixes: #8242 Signed-off-by: David Esparza (cherry picked from commit 4f9681b411c56f542ad471f43038c7764173b30f) Signed-off-by: Greg Kurz --- tests/metrics/lib/common.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index 8ec227a80..e42a596ac 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -175,7 +175,7 @@ function init_env() clean_env_ctr # restart docker only if it is not masked by systemd - docker_masked="$(systemctl list-unit-files --state=masked | grep -c docker)" + docker_masked="$(systemctl list-unit-files --state=masked | grep -c docker)" || true if [ "${docker_masked}" -eq 0 ]; then sudo systemctl restart docker fi @@ -191,7 +191,7 @@ function init_env() # killed to start test with clean environment. function kill_processes_before_start() { - docker_masked="$(systemctl list-unit-files --state=masked | grep -c "${DOCKER_EXE}")" + docker_masked="$(systemctl list-unit-files --state=masked | grep -c "${DOCKER_EXE}")" || true if [ "${docker_masked}" -eq 0 ]; then DOCKER_PROCS=$(sudo "${DOCKER_EXE}" ps -q)