Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion aliases
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@ function nom-cp() {
[ $MAIN ] && RSYNC=true
[ ! $MAIN ] && [ "$RSYNC_BRANCHES" ] && RSYNC=true

[ $RSYNC ] && { set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e; }
echo "$@"

if [ $RSYNC ]; then
# Parse host:path from rsync destination and mkdir -p via ssh,
# since rsync won't create intermediate directories on its own.
local RSYNC_DEST="${@: -1}"
if [[ "$RSYNC_DEST" == *:* ]]; then
local RSYNC_HOST="${RSYNC_DEST%%:*}" # strip longest match of :* from end
local RSYNC_DIR="$(dirname "${RSYNC_DEST#*:}")" # strip shortest match of *: from start
ssh "$RSYNC_HOST" "mkdir -p '$RSYNC_DIR'"
fi
set +e; set -x; rsync "$@"; RSYNC_EXIT=$?; set +x; set -e
fi

# this is a special exception project where we DONT want to ALSO copy file to nomad deploy
[ $MAIN ] && [ "$JOB" = "ia-petabox" ] && [ ! $NOM_CP_PETABOX_MAIN ] && exit 0
Expand All @@ -132,6 +144,10 @@ function nom-cp() {
return
fi

# Create destination directory inside the container before piping the file in
local REST_DIR=$(dirname "$REST")
[ "$REST_DIR" != "." ] && nomad alloc exec -task $TASK "$ALLOC" sh -c "mkdir -p '$REST_DIR'"

# HinD updated nomad clusters w/ latest nomad seem to *not* get the stdin close properly
# (and thus hang). So timeout/kill after 2s :( tracey 2024/3 )
set +e
Expand Down