From 163d900e63324a371708dc2854f237758a08d204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Tue, 12 Apr 2022 17:33:21 +0200 Subject: [PATCH] B #5765: Fix local monitoring (.monitor) (#1937) --- src/mad/sh/scripts_common.sh | 69 +++++++++++++++++++++++++++--------- src/tm_mad/ceph/clone | 2 ++ src/tm_mad/ceph/clone.ssh | 3 +- src/tm_mad/ceph/ln.ssh | 3 +- src/tm_mad/fs_lvm/clone | 2 ++ src/tm_mad/fs_lvm_ssh/clone | 2 ++ src/tm_mad/qcow2/clone | 1 + src/tm_mad/qcow2/clone.ssh | 3 +- src/tm_mad/qcow2/ln.ssh | 3 +- src/tm_mad/ssh/clone | 3 +- src/tm_mad/ssh/clone.replica | 5 +-- src/tm_mad/ssh/mv | 3 +- 12 files changed, 74 insertions(+), 25 deletions(-) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index a13f160c6f..43039be15c 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -577,23 +577,6 @@ set -e -o pipefail if [ ! -d $2 ]; then mkdir -p $2 fi - -MONITOR_FN="\$(dirname $2)/.monitor" - -# create or update .monitor content -if [ -n "$3" ]; then - MONITOR='' - if [ -f "\\${MONITOR_FN}" ]; then - MONITOR="\\$(cat "\\${MONITOR_FN}" 2>/dev/null)" - fi - - if [ "x\\${MONITOR}" != "x$3" ]; then - echo "$3" > "\\${MONITOR_FN}" - fi -else - # remove .monitor file (to avoid errors on driver change) - rm -f "\\${MONITOR_FN}" -fi EOF` SSH_EXEC_RC=$? @@ -604,6 +587,58 @@ EOF` fi } +# Enables local monitoring for host $2 and DS $1, by creating the corresponding +# .monitor file containing the $3 ( the driver name) (e.g ssh) +function enable_local_monitoring +{ + SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null </dev/null)" +fi + +if [ "x\\${MONITOR}" != "x$3" ]; then + echo "$3" > "\\${MONITOR_FN}" +fi +EOF` + + SSH_EXEC_RC=$? + + if [ $SSH_EXEC_RC -ne 0 ]; then + error_message "Error creating $2/.monitor at $1: $SSH_EXEC_ERR" + + exit $SSH_EXEC_RC + fi +} + +# Disables local monitoring for host $2 and DS $1, by removing the corresponding +# .monitor file +function disable_local_monitoring +{ + SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <