Skip to content

Commit

Permalink
unzip archive on the server before running workload
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Sep 28, 2023
1 parent a69bacb commit 2005e0c
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions cmd/cloudexec/user_data.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,12 @@ cleanup() {
update_state "failed"
fi

echo "Uploading results..."
# shellcheck disable=SC2310
s3cmd put -r ~/output/* "s3://${BUCKET_NAME}/job-${JOB_ID}/output/" || true # proceed to destroy droplet on error

echo "Uploading logs..."
# shellcheck disable=SC2310
s3cmd put /var/log/cloud-init-output.log "s3://${BUCKET_NAME}/job-${JOB_ID}/logs/" || true # proceed to destroy droplet on error
if [ -n "$(ls -A ~/output/)" ]; then
echo "Uploading results..."
s3cmd put -r ~/output/* "s3://${BUCKET_NAME}/job-${JOB_ID}/output/" || true # proceed to destroy droplet on error
else
echo "Skipping results upload, no files found in ~/ouput"
fi

if [[ -s ${stdout_log} ]]; then
echo
Expand All @@ -150,6 +149,13 @@ cleanup() {
echo "No error logs generated"
fi

if [[ -s "/var/log/cloud-init-output.log" ]]; then
echo "Uploading logs..."
s3cmd put /var/log/cloud-init-output.log "s3://${BUCKET_NAME}/job-${JOB_ID}/logs/"
else
echo "No logs to upload.."
fi

echo
echo "Destroying droplet..."
THIS_DROPLET_ID=$(curl -s http://169.254.169.254/metadata/v1/id)
Expand Down Expand Up @@ -195,11 +201,22 @@ echo "Running setup..."
mkdir -p ~/output
eval "${SETUP_COMMANDS}"

echo "Downloading inputs..."
s3cmd get -r "s3://${BUCKET_NAME}/job-${JOB_ID}/input" ~/
echo "Downloading input archive..."
s3cmd get -r "s3://${BUCKET_NAME}/job-${JOB_ID}/input.zip" ~/
if [[ ! -s ~/input.zip ]]; then
echo "Error: Failed to download input archive"
exit 1
fi

echo "Unzipping input archive..."
ls -l ~/
ls -l ~/input.zip
xxd ~/input.zip | head -n 10
unzip ~/input.zip -d ~/
ls ~/
ls ~/input
if [[ ! -d ~/input ]]; then
echo "Error: Failed to download inputs directory"
echo "Error: Failed to unzip inputs directory"
exit 1
fi

Expand Down

0 comments on commit 2005e0c

Please sign in to comment.