From d8ffce23ffb67598cc3fdaa82075db6001c99288 Mon Sep 17 00:00:00 2001 From: "Chandan Kumar (raukadah)" Date: Thu, 3 Apr 2025 19:15:13 +0530 Subject: [PATCH] Use mkdir -p while creating prometheus directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Re-run, prometheus directory exists and the run fails with mkdir: cannot create directory ‘/etc/prometheus’: File exists. Or when we use sg_core plugin with their prothemeus config file, It also creates prometheus config directory. Then again prometheus devstack plugin fails with same error. In order to fix it, use mkdir -p while creating prometheus directory. It will ignore error if parent exists. Depends-On: https://review.opendev.org/c/openstack/watcher/+/946230 Change-Id: Ie82346577d836d61c5ca986614e431adbf216d6d Signed-off-by: Chandan Kumar (raukadah) --- devstack/lib/prometheus | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devstack/lib/prometheus b/devstack/lib/prometheus index c74193a..67d687c 100644 --- a/devstack/lib/prometheus +++ b/devstack/lib/prometheus @@ -37,7 +37,8 @@ function install_prometheus { function configure_prometheus { # Configure prometheus - sudo mkdir /etc/prometheus + + sudo mkdir -p /etc/prometheus sudo chown $(whoami):$(whoami) /etc/prometheus # Copy User's prometheus config @@ -50,7 +51,7 @@ function configure_prometheus { sudo cat /etc/prometheus/$(basename ${PROMETHEUS_CONFIG_FILE}) # Create data directory - sudo mkdir ${PROMETHEUS_DATA_DIRECTORY} + sudo mkdir -p ${PROMETHEUS_DATA_DIRECTORY} sudo chown $(whoami):$(whoami) ${PROMETHEUS_DATA_DIRECTORY} }