Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit e007cd0

Browse files
dmiusDmitry
authored andcommitted
Fix PR remarks
1 parent 2b556b1 commit e007cd0

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

nancy_run.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function check_path() {
118118
# None
119119
#######################################
120120
function create_ec2_docker_machine() {
121-
msg "Attempt to create a docker machine in zone $7 with price $3..."
121+
msg "Attempt to create a docker machine in region $7 with price $3..."
122122
docker-machine create --driver=amazonec2 \
123123
--amazonec2-request-spot-instance \
124124
--amazonec2-instance-type=$2 \
@@ -571,19 +571,19 @@ if [[ "$RUN_ON" == "aws" ]]; then
571571
fi
572572
elif [[ "$RUN_ON" == "localhost" ]]; then
573573
if [[ ! -z ${AWS_KEYPAIR_NAME+x} ]] || [[ ! -z ${AWS_SSH_KEY_PATH+x} ]] ; then
574-
err "ERROR: options '--aws-keypair-name' and '--aws-ssh-key-path' must be used with '--run on aws'."
574+
err "ERROR: options '--aws-keypair-name' and '--aws-ssh-key-path' must be used with '--run-on aws'."
575575
exit 1
576576
fi
577577
if [[ ! -z ${AWS_EC2_TYPE+x} ]]; then
578-
err "ERROR: option '--aws-ec2-type' must be used with '--run on aws'."
578+
err "ERROR: option '--aws-ec2-type' must be used with '--run-on aws'."
579579
exit 1
580580
fi
581581
if [[ ! -z ${AWS_EBS_VOLUME_SIZE+x} ]]; then
582-
err "ERROR: option '--aws-ebs-volume-size' must be used with '--run on aws'."
582+
err "ERROR: option '--aws-ebs-volume-size' must be used with '--run-on aws'."
583583
exit 1
584584
fi
585585
if [[ ! -z ${AWS_REGION+x} ]]; then
586-
err "ERROR: option '--aws-region' must be used with '--run on aws'."
586+
err "ERROR: option '--aws-region' must be used with '--run-on aws'."
587587
exit 1
588588
fi
589589
else
@@ -747,8 +747,9 @@ fi
747747

748748
if [[ "$RUN_ON" == "aws" ]]; then
749749
if [[ ! -z ${AWS_EBS_VOLUME_SIZE+x} ]]; then
750-
if ! [[ $AWS_EBS_VOLUME_SIZE =~ '^[0-9]+$' ]] ; then
751-
err "ERROR: --ebs-volume-size must be integer."
750+
re='^[0-9]+$'
751+
if ! [[ $AWS_EBS_VOLUME_SIZE =~ $re ]] ; then
752+
err "ERROR: --aws-ebs-volume-size must be integer."
752753
exit 1
753754
fi
754755
else
@@ -825,18 +826,19 @@ elif [[ "$RUN_ON" == "aws" ]]; then
825826
region="${region/\"/}"
826827
minprice="${minprice/\"/}"
827828
minprice="${minprice/\"/}"
828-
zone=${region: -1}
829-
msg "Min price from history: $minprice in $region (zone: $zone)"
829+
AWS_ZONE=${region: -1}
830+
AWS_REGION=${region:: -1}
831+
msg "Min price from history: $minprice in $region (zone: $AWS_ZONE)"
830832
multiplier="1.01"
831833
price=$(echo "$minprice * $multiplier" | bc -l)
832834
msg "Increased price: $price"
833835
EC2_PRICE=$price
834-
if [ -z $zone ]; then
835-
zone='a' #default zone
836+
if [[ -z $AWS_ZONE ]]; then
837+
AWS_ZONE='a' #default zone
836838
fi
837839

838840
create_ec2_docker_machine $DOCKER_MACHINE $AWS_EC2_TYPE $EC2_PRICE \
839-
60 $AWS_KEYPAIR_NAME $AWS_SSH_KEY_PATH $AWS_REGION $zone;
841+
60 $AWS_KEYPAIR_NAME $AWS_SSH_KEY_PATH $AWS_REGION $AWS_ZONE;
840842
status=$(wait_ec2_docker_machine_ready "$DOCKER_MACHINE" true)
841843
if [[ "$status" == "price-too-low" ]]; then
842844
msg "Price $price is too low for $AWS_EC2_TYPE instance. Getting the up-to-date value from the error message..."
@@ -864,7 +866,7 @@ elif [[ "$RUN_ON" == "aws" ]]; then
864866
DOCKER_MACHINE="${DOCKER_MACHINE//_/-}"
865867
#try start docker machine name with new price
866868
create_ec2_docker_machine $DOCKER_MACHINE $AWS_EC2_TYPE $EC2_PRICE \
867-
60 $AWS_KEYPAIR_NAME $AWS_SSH_KEY_PATH $AWS_REGION $zone
869+
60 $AWS_KEYPAIR_NAME $AWS_SSH_KEY_PATH $AWS_REGION $AWS_ZONE
868870
wait_ec2_docker_machine_ready "$DOCKER_MACHINE" false;
869871
else
870872
err "$(date "+%Y-%m-%d %H:%M:%S") ERROR: Cannot determine actual price for the instance $AWS_EC2_TYPE."
@@ -907,7 +909,7 @@ elif [[ "$RUN_ON" == "aws" ]]; then
907909
# Create new volume and attach them for non i3 instances if needed
908910
if [ ! -z ${AWS_EBS_VOLUME_SIZE+x} ]; then
909911
msg "Create and attach a new EBS volume (size: $AWS_EBS_VOLUME_SIZE GB)"
910-
VOLUME_ID=$(aws --region=$AWS_REGION ec2 create-volume --size $AWS_EBS_VOLUME_SIZE --availability-zone us-east-1a --volume-type gp2 | jq -r .VolumeId)
912+
VOLUME_ID=$(aws --region=$AWS_REGION ec2 create-volume --size $AWS_EBS_VOLUME_SIZE --availability-zone $AWS_REGION$AWS_ZONE --volume-type gp2 | jq -r .VolumeId)
911913
INSTANCE_ID=$(docker-machine ssh $DOCKER_MACHINE curl -s http://169.254.169.254/latest/meta-data/instance-id)
912914
sleep 10 # wait to volume will ready
913915
attachResult=$(aws --region=$AWS_REGION ec2 attach-volume --device /dev/xvdf --volume-id $VOLUME_ID --instance-id $INSTANCE_ID)

tests/nancy_run_invalid_aws_option.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ output=$(
99
2>&1
1010
)
1111

12-
if [[ $output =~ "must be used with '--run on aws'" ]]; then
12+
if [[ $output =~ "must be used with '--run-on aws'" ]]; then
1313
echo -e "\e[36mOK\e[39m"
1414
else
1515
>&2 echo -e "\e[31mFAILED\e[39m"

0 commit comments

Comments
 (0)