From 7390124654ac56e3bff793527ee6f4ef05972d12 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Thu, 31 Jan 2019 20:35:38 +0100 Subject: [PATCH] B #2767: Fixes into create/update of .monitor for local DS monitoring (#2873) --- src/mad/sh/scripts_common.sh | 21 ++++++++++++++++----- src/tm_mad/ceph/clone | 2 +- src/tm_mad/ceph/ln | 2 +- src/tm_mad/ssh/mv | 13 ++++++++++++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 1f540b323a..2124ea5383 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -460,12 +460,23 @@ function ssh_make_path { SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null < "\$(dirname $2)/.monitor" - fi +if [ ! -d $2 ]; then + mkdir -p $2 +fi + +# create or update .monitor content +if [ -n "$3" ]; then + MONITOR_FN="\$(dirname $2)/.monitor" + + 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 fi EOF` SSH_EXEC_RC=$? diff --git a/src/tm_mad/ceph/clone b/src/tm_mad/ceph/clone index 6c4705926f..888059eb2a 100755 --- a/src/tm_mad/ceph/clone +++ b/src/tm_mad/ceph/clone @@ -118,7 +118,7 @@ if [ -n "$EC_POOL_NAME" ]; then fi if [ "${TYPE}" = 'FILE' ]; then - ssh_make_path $DST_HOST $DST_DIR + ssh_make_path $DST_HOST $DST_DIR 'ssh' CLONE_CMD=$(cat </dev/null || : +fi +EOF +) + +MONITOR=$(ssh_monitor_and_log "$SRC_HOST" "$MONITOR_CMD" 'Get .monitor') + +ssh_make_path "$DST_HOST" "$DST_PATH" "$MONITOR" log "Moving $SRC to $DST"