1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

B #5923: Fix DS migration for fs_lvm* (#2246)

This commit is contained in:
Christian González 2022-07-22 09:35:45 +02:00 committed by GitHub
parent 94fc17c36a
commit 47cb7b891e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 27 deletions

View File

@ -122,11 +122,23 @@ EOF
)
LOCK="tm-fs_lvm-${DST_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${SRC_HOST}" "${CREATE_CMD}" \
exclusive "${LOCK}" 120 ssh_exec_and_log "${DST_HOST}" "${CREATE_CMD}" \
"Error creating LV named ${LV_NAME}"
# activate src volume (on DST)
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${SRC_DEV}"
EOF
)
LOCK="tm-fs_lvm-${SRC_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${DST_HOST}" "${CMD}" \
"Error deactivating disk ${SRC_PATH}"
# copy volume data
ssh_exec_and_log "$SRC_HOST" \
ssh_exec_and_log "$DST_HOST" \
"${DD} if=${SRC_DEV} of=${DST_DEV} bs=${DD_BLOCK_SIZE:-64k}" \
"Error copying ${SRC} to ${DST}"
@ -144,20 +156,21 @@ EOF
LOCK="tm-fs_lvm-${SRC_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${SRC_HOST}" "${DELETE_CMD}" \
"Error deleting old LV ${SRC_DEV}"
fi
else
# activate
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${DST_DEV}"
# activate
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${DST_DEV}"
hostname -f >"${DST_DIR}/.host" || :
hostname -f >"${DST_DIR}/.host" || :
EOF
)
ssh_exec_and_log "$DST_HOST" "$CMD" \
"Error activating disk $DST_PATH"
ssh_exec_and_log "$DST_HOST" "$CMD" \
"Error activating disk $DST_PATH"
fi
exit 0
fi

View File

@ -122,11 +122,23 @@ EOF
)
LOCK="tm-fs_lvm-${DST_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${SRC_HOST}" "${CREATE_CMD}" \
exclusive "${LOCK}" 120 ssh_exec_and_log "${DST_HOST}" "${CREATE_CMD}" \
"Error creating LV named ${LV_NAME}"
# activate src volume (on DST)
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${SRC_DEV}"
EOF
)
LOCK="tm-fs_lvm-${SRC_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${DST_HOST}" "${CMD}" \
"Error deactivating disk ${SRC_PATH}"
# copy volume data
ssh_exec_and_log "$SRC_HOST" \
ssh_exec_and_log "$DST_HOST" \
"${DD} if=${SRC_DEV} of=${DST_DEV} bs=${DD_BLOCK_SIZE:-64k}" \
"Error copying ${SRC} to ${DST}"
@ -144,21 +156,20 @@ EOF
LOCK="tm-fs_lvm-${SRC_DS_SYS_ID}.lock"
exclusive "${LOCK}" 120 ssh_exec_and_log "${SRC_HOST}" "${DELETE_CMD}" \
"Error deleting old LV ${SRC_DEV}"
fi
else
# activate
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${DST_DEV}"
# activate
CMD=$(cat <<EOF
set -ex -o pipefail
${SYNC}
${SUDO} ${LVSCAN}
${SUDO} ${LVCHANGE} -ay "${DST_DEV}"
hostname -f >"${DST_DIR}/.host" || :
hostname -f >"${DST_DIR}/.host" || :
EOF
)
ssh_exec_and_log "$DST_HOST" "$CMD" \
"Error activating disk $DST_PATH"
ssh_exec_and_log "$DST_HOST" "$CMD" \
"Error activating disk $DST_PATH"
fi
fi
# After managing LV de/activation on different hosts, transfer normal files