Skip to content

Commit

Permalink
Merge pull request #13 from CALeDNA/develop
Browse files Browse the repository at this point in the history
delete VM if setup fails
  • Loading branch information
hector-baez authored Nov 15, 2023
2 parents 4cd0850 + dcf0fb3 commit 115d3f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main/setup_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SECURITY=""
VOLUME=""
VMNAME="chunk"
VMNUMBER=0
SETUP_CONFIG="/home/ubuntu/t-rex-monitor/vm_vars.sh"
while getopts "u:f:i:k:j:n:m:b:s:w:v:c:" opt; do
case $opt in
u) USER="$OPTARG"
Expand All @@ -35,7 +36,7 @@ while getopts "u:f:i:k:j:n:m:b:s:w:v:c:" opt; do
;;
v) VOLUME="$OPTARG"
;;
c) SSHCONFIG="$OPTARG" # SSH config file: /home/ubuntu/.ssh/config
c) SSHCONFIG="$OPTARG" # SSH config file: $HOME/.ssh/config
;;
esac
done
Expand All @@ -55,7 +56,8 @@ fi
START=$VMNUMBER
END=$(( VMNUMBER + NUMINSTANCES))

source ${JSCRED}
source $JSCRED
source $SETUP_CONFIG


# create and start an instance
Expand Down Expand Up @@ -119,6 +121,10 @@ do

if [[ $elapsed -ge 300 ]]; then
echo "Timeout: SSH not ready after 5 minutes on $VMNAME$chunk."
echo "Deleting server $VMNAME$chunk..."
./dismantle_instance.sh -j $JSCRED -h hostnames -m $VMNAME$chunk -c $SSHCONFIG -d $DATASOURCE
# del ip in case it wasn't attached
openstack server remove floating ip $VMNAME$chunk $ip_address
break
fi

Expand Down

0 comments on commit 115d3f2

Please sign in to comment.