1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-15 05:57:23 +03:00

F #4985: Use rsync instead rdiff (#342)

This commit is contained in:
Jan Orel 2020-10-21 17:13:09 +02:00 committed by GitHub
parent 34aa09fbe7
commit 9254faebf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 60 deletions

View File

@ -42,7 +42,6 @@ MKSWAP=${MKSWAP:-mkswap}
QEMU_IMG=${QEMU_IMG:-qemu-img}
RADOS=${RADOS:-rados}
RBD=${RBD:-rbd}
RDIFF=${RDIFF:-rdiff}
READLINK=${READLINK:-readlink}
RM=${RM:-rm}
CP=${CP:-cp}
@ -190,8 +189,8 @@ function retry_if
break
done
echo $TERR >&2
echo $TSTD
[ -n "$TERR" ] && echo $TERR >&2
[ -n "$TSTD" ] && echo $TSTD
return $RC
}

View File

@ -154,12 +154,8 @@ EOF
)
fi
ssh_forward ssh_exec_and_log $REPLICA_HOST "$CLONE_CMD" \
"Error copying $SRC to $DST"
# Create uncopressed base image copy on REPLICA for recovery snapshots
# and upload it's signature to the DST host
# Prepare uncopressed base image copy on REPLICA for recovery snapshots
# to speedup first rsync
if [ -n "$RECOVERY_SNAPSHOT_FREQ" ]; then
SNAP_DIR="$REPLICA_RECOVERY_SNAPS_DIR/$VMID"
@ -170,23 +166,16 @@ if [ -n "$RECOVERY_SNAPSHOT_FREQ" ]; then
cd $SNAP_DIR
if file $SRC_PATH | grep -q QCOW; then
qemu-img convert -O qcow2 $SRC_PATH ${DST_FILE}.base
qemu-img convert -O qcow2 $SRC_PATH ${DST_FILE}.recovery_snapshot
else
cp $SRC_PATH ${DST_FILE}.base
cp $SRC_PATH ${DST_FILE}.recovery_snapshot
fi
rm -f ${DST_FILE}.sign
$RDIFF signature ${DST_FILE}.base ${DST_FILE}.sign
tar -cSf - ${DST_FILE}.sign | \
ssh $REPLICA_SSH_OPTS ${REPLICA_STORAGE_IP:-$DST_HOST} "tar xSf - -C $DST_DIR"
EOF
)
ssh_forward ssh_exec_and_log "$REPLICA_HOST" "$BASE_SIGN_CMD" \
"Error computing or uploading base image or signature"
fi
ssh_forward ssh_exec_and_log $REPLICA_HOST "$CLONE_CMD" \
"Error copying $SRC to $DST"
if [ -n "$RESIZE_CMD" ]; then
ssh_exec_and_log "$DST_HOST" "$RESIZE_CMD" \

View File

@ -33,7 +33,6 @@ source ${DRIVER_PATH}/../../scripts_common.sh
mkdir -p "${DISK_PATH}.snap"
SNAP_PATH="${DISK_PATH}.snap/recovery_snapshot"
DISK_NAME="$(basename $DISK_PATH)"
VM_DIR="$(dirname $DISK_PATH)"
if [ -f $SNAP_PATH ]; then
SNAP_OLD=$(stat -c "%Y" $SNAP_PATH)
@ -52,27 +51,9 @@ retry_if "active block job" 3 5\
virsh -q -c ${LIBVIRT_URI} blockcopy one-${VMID} \
--path ${DISK_PATH} --dest $SNAP_PATH --wait --finish
cd $VM_DIR
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
if [ ! -f "$DISK_NAME.sign" ]; then
tar --transform="flags=r;s|${DISK_NAME}.snap/recovery_snapshot|${DISK_NAME}.recovery_snapshot|" \
-cSf - ${DISK_NAME}.snap/recovery_snapshot | \
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
RC=$?
else
rm -f "$DISK_NAME.snap/recovery_snapshot.rdiff"
rsync -q $SNAP_PATH \
$REPLICA_HOST:$REPLICA_RECOVERY_SNAPS_DIR/$VMID/${DISK_NAME}.recovery_snapshot > /dev/null
$RDIFF delta "$DISK_NAME.sign" "$DISK_NAME.snap/recovery_snapshot" \
"$DISK_NAME.snap/recovery_snapshot.rdiff"
tar --transform="flags=r;s|${DISK_NAME}.snap/recovery_snapshot.rdiff|${DISK_NAME}.rdiff|" \
-cSf - ${DISK_NAME}.snap/recovery_snapshot.rdiff | \
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
RC=$?
fi
if [ "$RC" = "0" ]; then
stat -c "%c" $DISK_NAME.snap/recovery_snapshot
fi
stat -c "%Y" $SNAP_PATH

View File

@ -96,7 +96,8 @@ function rsync_img_to_replica {
local LOCK_TIMEOUT="${REPLICA_COPY_LOCK_TIMEOUT:-600}"
local DST_DIR=$(dirname $IMG_PATH)
ssh_make_path $REPLICA_HOST $DST_DIR "replica"
ssh_exec_and_log $REPLICA_HOST \
"mkdir -p $DST_DIR; echo replica > $DST_DIR/.monitor"
# sync to replica, include .md5sum and .snap dir
LOCK="$REPLICA_HOST-${IMG_PATH//\//-}"
@ -173,7 +174,6 @@ function clean_cache() {
# ------------------------------------------------------------------------------
# Checks if recovery snapshot exists for given VM/DISK,
# If there is a newer image base and snap.rdiff it restores snapshot
# ------------------------------------------------------------------------------
function recovery_snap_exists() {
REPLICA_RECOVERY_SNAPS_DIR="/var/lib/one/datastores/replica_snaps"
@ -181,20 +181,6 @@ function recovery_snap_exists() {
local DISK=$2
SNAP_PATH="${REPLICA_RECOVERY_SNAPS_DIR}/$DISK.recovery_snapshot"
BASE_IMG_PATH="${REPLICA_RECOVERY_SNAPS_DIR}/$DISK.base"
RDIFF_PATH="${REPLICA_RECOVERY_SNAPS_DIR}/$DISK.rdiff"
SNAP_EXISTS_CMD=$(cat <<EOF
if [ "$SNAP_PATH" -nt "$RDIFF_PATH" ] ; then
true
elif [ "$RDIFF_PATH" -nt "$SNAP_PATH" ] && [ -e "$BASE_IMG_PATH" ]; then
rm -f "$SNAP_PATH"
$RDIFF patch "$BASE_IMG_PATH" "$RDIFF_PATH" "$SNAP_PATH"
true
else
false
fi
EOF
)
ssh "$REPLICA_HOST" "$SNAP_EXISTS_CMD"
ssh "$REPLICA_HOST" "test -f \"$SNAP_PATH\""
}