@@ -391,11 +391,11 @@ function check_cli_parameters() {
391
391
exit 1
392
392
fi
393
393
if [[ -z ${AWS_REGION+x} ]]; then
394
- err " NOTICE: AWS EC2 region not given. Will used us-east-1."
394
+ err " NOTICE: AWS EC2 region not given. Will use us-east-1."
395
395
AWS_REGION=' us-east-1'
396
396
fi
397
397
if [[ -z ${AWS_BLOCK_DURATION+x} ]]; then
398
- err " NOTICE: Container live time duration is not given. Will used 60 minutes."
398
+ err " NOTICE: Container live time duration is not given. Will use 60 minutes."
399
399
AWS_BLOCK_DURATION=60
400
400
else
401
401
case $AWS_BLOCK_DURATION in
@@ -408,6 +408,18 @@ function check_cli_parameters() {
408
408
;;
409
409
esac
410
410
fi
411
+ if [[ ! -z ${AWS_EBS_VOLUME_SIZE+x} ]]; then
412
+ re=' ^[0-9]+$'
413
+ if ! [[ $AWS_EBS_VOLUME_SIZE =~ $re ]] ; then
414
+ err " ERROR: --aws-ebs-volume-size must be integer."
415
+ exit 1
416
+ fi
417
+ else
418
+ if [[ ! ${AWS_EC2_TYPE: 0: 2} == ' i3' ]]; then
419
+ err " NOTICE: EBS volume size is not given, will be calculated based on the dump file size (might be not enough)."
420
+ err " WARNING: It is recommended to specify EBS volume size explicitly (CLI option '--ebs-volume-size')."
421
+ fi
422
+ fi
411
423
elif [[ " $RUN_ON " == " localhost" ]]; then
412
424
if [[ ! -z ${AWS_KEYPAIR_NAME+x} ]] || [[ ! -z ${AWS_SSH_KEY_PATH+x} ]] ; then
413
425
err " ERROR: options '--aws-keypair-name' and '--aws-ssh-key-path' must be used with '--run-on aws'."
@@ -489,6 +501,11 @@ function check_cli_parameters() {
489
501
DB_DUMP_EXT=${DB_DUMP_FILENAME##* .}
490
502
fi
491
503
504
+ if [[ -z ${DB_NAME+x} ]]; then
505
+ dbg " NOTICE: Database name is not given. Will use 'test'"
506
+ DB_NAME=' test'
507
+ fi
508
+
492
509
if [[ -z ${PG_CONFIG+x} ]]; then
493
510
err " NOTICE: No PostgreSQL config is provided. Will use default."
494
511
# TODO(NikolayS) use "auto-tuning" – shared_buffers=1/4 RAM, etc
@@ -514,11 +531,6 @@ function check_cli_parameters() {
514
531
ARTIFACTS_DESTINATION=" ."
515
532
fi
516
533
517
- if [[ -z ${DB_NAME+x} ]]; then
518
- err " NOTICE: Database name is not given. Will use test"
519
- DB_NAME=' test'
520
- fi
521
-
522
534
if [[ -z ${ARTIFACTS_FILENAME+x} ]]; then
523
535
dbg " Artifacts naming is not set. Will use: '$DOCKER_MACHINE '"
524
536
ARTIFACTS_FILENAME=$DOCKER_MACHINE
@@ -537,7 +549,7 @@ function check_cli_parameters() {
537
549
if [[ ! -z ${WORKLOAD_CUSTOM_SQL+x} ]]; then
538
550
check_path WORKLOAD_CUSTOM_SQL
539
551
if [[ " $? " -ne " 0" ]]; then
540
- # err "WARNING: Value given as workload-custom-sql: '$WORKLOAD_CUSTOM_SQL' not found as file will use as content"
552
+ dbg " WARNING: Value given as workload-custom-sql: '$WORKLOAD_CUSTOM_SQL ' not found as file will use as content"
541
553
echo " $WORKLOAD_CUSTOM_SQL " > $TMP_PATH /workload_custom_sql_tmp.sql
542
554
WORKLOAD_CUSTOM_SQL=" $TMP_PATH /workload_custom_sql_tmp.sql"
543
555
fi
@@ -546,7 +558,7 @@ function check_cli_parameters() {
546
558
if [[ ! -z ${COMMANDS_AFTER_CONTAINER_INIT+x} ]]; then
547
559
check_path COMMANDS_AFTER_CONTAINER_INIT
548
560
if [[ " $? " -ne " 0" ]]; then
549
- # err "WARNING: Value given as after_db_init_code: '$COMMANDS_AFTER_CONTAINER_INIT' not found as file will use as content"
561
+ dbg " WARNING: Value given as after_db_init_code: '$COMMANDS_AFTER_CONTAINER_INIT ' not found as file will use as content"
550
562
echo " $COMMANDS_AFTER_CONTAINER_INIT " > $TMP_PATH /after_docker_init_code_tmp.sh
551
563
COMMANDS_AFTER_CONTAINER_INIT=" $TMP_PATH /after_docker_init_code_tmp.sh"
552
564
fi
@@ -563,7 +575,7 @@ function check_cli_parameters() {
563
575
if [[ ! -z ${SQL_BEFORE_DB_RESTORE+x} ]]; then
564
576
check_path SQL_BEFORE_DB_RESTORE
565
577
if [[ " $? " -ne " 0" ]]; then
566
- # err "WARNING: Value given as before_db_init_code: '$SQL_BEFORE_DB_RESTORE' not found as file will use as content"
578
+ dbg " WARNING: Value given as before_db_init_code: '$SQL_BEFORE_DB_RESTORE ' not found as file will use as content"
567
579
echo " $SQL_BEFORE_DB_RESTORE " > $TMP_PATH /before_db_init_code_tmp.sql
568
580
SQL_BEFORE_DB_RESTORE=" $TMP_PATH /before_db_init_code_tmp.sql"
569
581
fi
@@ -592,21 +604,6 @@ function check_cli_parameters() {
592
604
DELTA_CONFIG=" $TMP_PATH /target_config_tmp.conf"
593
605
fi
594
606
fi
595
-
596
- if [[ " $RUN_ON " == " aws" ]]; then
597
- if [[ ! -z ${AWS_EBS_VOLUME_SIZE+x} ]]; then
598
- re=' ^[0-9]+$'
599
- if ! [[ $AWS_EBS_VOLUME_SIZE =~ $re ]] ; then
600
- err " ERROR: --aws-ebs-volume-size must be integer."
601
- exit 1
602
- fi
603
- else
604
- if [[ ! ${AWS_EC2_TYPE: 0: 2} == ' i3' ]]; then
605
- err " NOTICE: EBS volume size is not given, will be calculated based on the dump file size (might be not enough)."
606
- err " WARNING: It is recommended to specify EBS volume size explicitly (CLI option '--ebs-volume-size')."
607
- fi
608
- fi
609
- fi
610
607
# ## End of CLI parameters checks ###
611
608
}
612
609
@@ -626,7 +623,8 @@ function check_cli_parameters() {
626
623
# (text) [5] AWS keypair to use
627
624
# (text) [6] Path to Private Key file to use for instance
628
625
# Matching public key with .pub extension should exist
629
- # (text) [7] The AWS region to launch the instance (us-east-1, eu-central-1)
626
+ # (text) [7] The AWS region to launch the instance
627
+ # (for example us-east-1, eu-central-1)
630
628
# (text) [8] The AWS zone to launch the instance in (one of a,b,c,d,e)
631
629
# Returns:
632
630
# None
@@ -688,7 +686,7 @@ function wait_ec2_docker_machine_ready() {
688
686
if $check_price ; then
689
687
status=$( \
690
688
aws --region=$AWS_REGION ec2 describe-spot-instance-requests \
691
- --filters=" Name=launch.instance-type,Values=$AWS_EC2_TYPE " \
689
+ --filters=" Name=launch.instance-type,Values=$AWS_EC2_TYPE " \
692
690
| jq ' .SpotInstanceRequests | sort_by(.CreateTime) | .[] | .Status.Code' \
693
691
| tail -n 1
694
692
)
@@ -716,18 +714,18 @@ function determine_history_ec2_spot_price() {
716
714
# TODO detect region and/or allow to choose via options
717
715
prices=$(
718
716
aws --region=$AWS_REGION ec2 \
719
- describe-spot-price-history --instance-types $AWS_EC2_TYPE --no-paginate \
720
- --start-time=$( date +%s) --product-descriptions=" Linux/UNIX (Amazon VPC)" \
721
- --query ' SpotPriceHistory[*].{az:AvailabilityZone, price:SpotPrice}'
717
+ describe-spot-price-history --instance-types $AWS_EC2_TYPE --no-paginate \
718
+ --start-time=$( date +%s) --product-descriptions=" Linux/UNIX (Amazon VPC)" \
719
+ --query ' SpotPriceHistory[*].{az:AvailabilityZone, price:SpotPrice}'
722
720
)
723
721
minprice=$( echo $prices | jq ' min_by(.price) | .price' )
724
722
region=$( echo $prices | jq ' min_by(.price) | .az' ) # TODO(NikolayS) double-check zones®ions
725
723
region=" ${region/ \" / } "
726
724
region=" ${region/ \" / } "
727
725
minprice=" ${minprice/ \" / } "
728
726
minprice=" ${minprice/ \" / } "
729
- AWS_ZONE=${region: - 1}
730
- AWS_REGION=${region:: -1 }
727
+ AWS_ZONE=${region: $(( ${ # region} -1)) : 1}
728
+ AWS_REGION=${region: 0 : $(( ${ # region} -1)) }
731
729
msg " Min price from history: $minprice in $region (zone: $AWS_ZONE )"
732
730
multiplier=" 1.01"
733
731
price=$( echo " $minprice * $multiplier " | bc -l)
0 commit comments