clone-node: port both slowdisk extract fixes from clone-backup (EXDEV transform + script-file listener)
Same duplicated listener code, same two latent bugs. Not exercised today (de-32 target has SLOWDISK=False) but any clone to a SLOWDISK=True host would have failed identically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -200,6 +200,7 @@ setup_slowdisk_structure() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
SLOWDISK_TRANSFORMS=""
|
||||
echo "Setting up SLOWDISK structure for $key"
|
||||
echo " Static size: $((static_size_kb / 1024))MB"
|
||||
echo " Static paths: ${#static_paths[@]}"
|
||||
@@ -229,6 +230,9 @@ setup_slowdisk_structure() {
|
||||
local slowdisk_path="${slowdisk_base}/rpc_${key}__data_${path//\//__}"
|
||||
local target_path="${volume_path}/${path}"
|
||||
local target_dir=$(dirname "$target_path")
|
||||
# tar cannot extract through a cross-device dir symlink (EXDEV) - rewrite
|
||||
# member paths to land directly on /slowdisk (same fix as clone-backup).
|
||||
SLOWDISK_TRANSFORMS+=" --transform='s|^\\(\\./\\)\\?var/lib/docker/volumes/rpc_${key}/_data/${path}|slowdisk/rpc_${key}__data_${path//\//__}|'"
|
||||
|
||||
# Create parent directories in volume
|
||||
$SSH_CMD "$DEST_HOST" "mkdir -p '$target_dir'"
|
||||
@@ -299,7 +303,7 @@ transfer_volume() {
|
||||
# Use --skip-old-files to avoid overwriting existing symlinks/directories
|
||||
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
|
||||
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
|
||||
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
|
||||
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink${SLOWDISK_TRANSFORMS}"
|
||||
echo "SLOWDISK structure ready, will extract respecting symlinks"
|
||||
else
|
||||
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
|
||||
@@ -338,12 +342,14 @@ transfer_volume() {
|
||||
|
||||
# Start listener in screen session with proper escaping
|
||||
# Use tar_extract_opts which may include --skip-old-files for SLOWDISK mode
|
||||
$SSH_CMD "$DEST_HOST" "
|
||||
screen -dmS transfer_${key} bash -c '
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err
|
||||
echo \$? > /tmp/transfer_${key}.done
|
||||
'
|
||||
"
|
||||
# Script-file listener: tar_extract_opts may carry quoted --transform args
|
||||
# that no inline bash -c quoting survives (same fix as clone-backup).
|
||||
$SSH_CMD "$DEST_HOST" "cat > /tmp/transfer_${key}.sh && chmod +x /tmp/transfer_${key}.sh" <<LISTENER
|
||||
#!/bin/bash
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err
|
||||
echo \$? > /tmp/transfer_${key}.done
|
||||
LISTENER
|
||||
$SSH_CMD "$DEST_HOST" "screen -dmS transfer_${key} /tmp/transfer_${key}.sh"
|
||||
|
||||
# Give it time to start
|
||||
sleep 2
|
||||
@@ -359,13 +365,12 @@ transfer_volume() {
|
||||
|
||||
# Use nohup with proper backgrounding
|
||||
# Use tar_extract_opts which may include --skip-old-files for SLOWDISK mode
|
||||
$SSH_CMD "$DEST_HOST" "
|
||||
nohup bash -c '
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err
|
||||
echo \$? > /tmp/transfer_${key}.done
|
||||
' > /tmp/transfer_${key}.log 2>&1 < /dev/null &
|
||||
echo \$! > /tmp/transfer_${key}.pid
|
||||
"
|
||||
$SSH_CMD "$DEST_HOST" "cat > /tmp/transfer_${key}.sh && chmod +x /tmp/transfer_${key}.sh" <<LISTENER
|
||||
#!/bin/bash
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err
|
||||
echo \$? > /tmp/transfer_${key}.done
|
||||
LISTENER
|
||||
$SSH_CMD "$DEST_HOST" "nohup /tmp/transfer_${key}.sh > /tmp/transfer_${key}.log 2>&1 < /dev/null & echo \$! > /tmp/transfer_${key}.pid"
|
||||
|
||||
sleep 2
|
||||
|
||||
@@ -479,7 +484,7 @@ transfer_volume_ssh() {
|
||||
if setup_slowdisk_structure "$key" "$static_size_kb" "${static_paths[@]}"; then
|
||||
# and --keep-directory-symlink so tar extracts THROUGH the pre-created dir symlinks
|
||||
# instead of trying to mkdir over them (which fails with 'Cannot mkdir: File exists')
|
||||
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink"
|
||||
tar_extract_opts="-xf - -C / --skip-old-files --keep-directory-symlink${SLOWDISK_TRANSFORMS}"
|
||||
echo "SLOWDISK structure ready, will extract respecting symlinks"
|
||||
else
|
||||
echo "Warning: Failed to setup SLOWDISK structure, falling back to normal extraction"
|
||||
|
||||
Reference in New Issue
Block a user