Skip to content

Commit

Permalink
SERVER-29527 Use infrastructure_provisioning.sh and infrastructure_te…
Browse files Browse the repository at this point in the history
…ardown.sh

* Use infrastructure_provisioning.sh instead of setup_cluster.sh.

* The code to save and reuse terraform.tfstate in
  /data/infrastructure_provisioning/ goes into infrastructure_provisioning.sh.
  (From there, the good old setup_cluster.sh is called too.)

* Rename destroy_cluster.sh to infrastructure_teardown.sh

(cherry picked from commit 859d07ad4fcaafa4302149707afa17e58975e893)
  • Loading branch information
Henrik Ingo committed Jun 21, 2017
1 parent f3a7c3d commit 5eb2814
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 111 deletions.
40 changes: 15 additions & 25 deletions etc/longevity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ functions:
rm -rf ./*
mkdir src
mkdir work
mkdir bin
mkdir keys
pwd
ls
- command: manifest.load
- command: git.get_project
params:
Expand Down Expand Up @@ -133,36 +129,27 @@ functions:
virtualenv ./venv
source ./venv/bin/activate
pip install -r ../src/dsi/dsi/requirements.txt
python ../src/dsi/dsi/bin/bootstrap.py --production
python ../src/dsi/dsi/bin/bootstrap.py
- command: shell.exec
params:
script: |
set -v
set -e
source work/dsienv.sh
$DSI_PATH/bin/setup-dsi-env.sh
cp terraform/* work/
ls work
- command: shell.exec
params:
working_dir: work
script: |
set -v
set -e
./terraform get --update
ls -a work
"bring up 3 shard cluster":
"infrastructure provisioning":
- command: shell.exec
# bring up the cluster
# call infrastructure-provisioning.sh. This will either create a cluster, or update tags on existing instances.
params:
working_dir: work
silent: true
script: |
# to create a mongod EC2 cluster
set -e
set -o verbose
set -v
source ./dsienv.sh
$DSI_PATH/bin/setup-cluster.sh ${cluster} false --skip-fio
export PRODUCTION=true
$DSI_PATH/bin/infrastructure_provisioning.sh ${cluster}
"configure mongodb cluster":
- command: shell.exec
Expand Down Expand Up @@ -202,10 +189,13 @@ functions:
set -e
set -o verbose
source ./dsienv.sh
# destroy the EC2 cluster
yes yes | ./terraform destroy --var-file=cluster.json
yes yes | ./terraform destroy --var-file=cluster.json
# Longevity runs so rarely, we simply teardown the cluster when done.
# Note that nowadays infrastructure_teardown.sh is actually copying the terraform.tfstate into /data/infrastructure_provisioning
# but as of this writing the rhel70-perf-longevity distro didn't actually use the teardown hook.
source ./dsienv.sh
$DSI_PATH/bin/infrastructure_teardown.sh
echo "Cluster DESTROYED."
echo
echo "All perf results"
cd ..
cat perf.json | egrep "name|ops_per_sec"
Expand Down Expand Up @@ -291,7 +281,7 @@ tasks:
vars:
storageEngine: "wiredTiger"
test: "ycsb"
- func: "bring up 3 shard cluster"
- func: "infrastructure provisioning"
- func: "configure mongodb cluster"
- func: "run test"
vars:
Expand All @@ -312,7 +302,7 @@ tasks:
vars:
storageEngine: "mmapv1"
test: "ycsb"
- func: "bring up 3 shard cluster"
- func: "infrastructure provisioning"
- func: "configure mongodb cluster"
- func: "run test"
vars:
Expand Down
92 changes: 6 additions & 86 deletions etc/system_perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ functions:
rm -rf ./*
mkdir src
mkdir work
mkdir bin
pwd
ls
- command: manifest.load
- command: git.get_project
params:
Expand Down Expand Up @@ -150,96 +147,19 @@ functions:
set -e
source work/dsienv.sh
$DSI_PATH/bin/setup-dsi-env.sh
cp terraform/* work/
ls work
- command: shell.exec
params:
working_dir: work
script: |
set -v
set -e
./terraform get --update
- command: shell.exec
# set up /data/infrastructure_provisioning to keep track of resources,
# and allow Evergreen to release resources from there
params:
script: |
set -o verbose
# To force re-creation of existing instances, e.g. for a patch build, you can uncomment this:
#if [ -d "/data/infrastructure_provisioning" ]; then
# /data/infrastructure_provisioning/terraform/infrastructure_teardown.sh \
# && rm -rf /data/infrastructure_provisioning
#fi
# IF there's anything still in $HOME it's old or a mistake. Clean it up.
if [ -d "$HOME/infrastructure_provisioning" ]; then
$HOME/infrastructure_provisioning/terraform/infrastructure_teardown.sh \
&& rm -rf $HOME/infrastructure_provisioning
fi
if [ ! -d "/data/infrastructure_provisioning" ]; then
echo "copying terraform to Evergreen host"
mkdir /data/infrastructure_provisioning
cp -r terraform /data/infrastructure_provisioning/.
cp -r modules /data/infrastructure_provisioning/.
echo "copying infrastructure_teardown.sh to Evergreen host"
cp src/dsi/dsi/bin/destroy_cluster.sh /data/infrastructure_provisioning/terraform/infrastructure_teardown.sh
fi
ls -l /data/infrastructure_provisioning
ls -a work
"infrastructure provisioning":
- command: shell.exec
# if /data/infrastructure_provisioning exists, get info about provisioned resources
# from there otherwise provision resources from the cloud
# call infrastructure-provisioning.sh. This will either create a cluster, or update tags on existing instances.
params:
working_dir: work
script: |
set -e
set -o verbose
if [ -e "/data/infrastructure_provisioning/terraform/terraform.tfstate" ]; then
echo "Restrieving info for existing resources"
cp /data/infrastructure_provisioning/terraform/terraform.tfstate .
else
echo "No existing resources found"
fi
- command: shell.exec
# call setup-cluster.sh, in most cases this only updates tags
params:
working_dir: work
script: |
# don't run this with "set -e" so we can set up properly for the teardown.sh
set -o verbose
set -v
source ./dsienv.sh
if [ ! -e /data/infrastructure_provisioning/terraform/provisioned.${cluster} ]; then
EXISTING="false"
else
EXISTING="true"
fi
$DSI_PATH/bin/setup-cluster.sh ${cluster} $EXISTING
# handle the case when setup-cluster.sh fail
if [ $? -eq 0 ]; then
echo "Resource provisioned/updated."
# copy terraform information needed for teardown
cp {terraform.tfstate,cluster.tf,terraform.tfvars,security.tf,cluster.json} /data/infrastructure_provisioning/terraform/.
rsync -vr ../modules /data/infrastructure_provisioning/modules
cd /data/infrastructure_provisioning/terraform
./terraform get
# use provisioned.${shard} to indicate the type of clusters held by EVG host
# remove previous information and keep the latest cluster type
rm provisioned.*
touch provisioned.${cluster}
echo "Provisioning state updated on Evergreen host."
else
echo "Failed to provision resources. Cleaning up partial state."
cp ../src/dsi/dsi/bin/destroy_cluster.sh .
./destroy_cluster.sh
echo "Resource released."
rm -r /data/infrastructure_provisioning
echo "Cleaned up provisioning state on Evergreen host. Exiting test."
exit 1
fi
export PRODUCTION=true
$DSI_PATH/bin/infrastructure_provisioning.sh ${cluster}
"configure mongodb cluster":
- command: shell.exec
Expand All @@ -251,7 +171,7 @@ functions:
set -o verbose
source ./dsienv.sh
source ./venv/bin/activate
$DSI_PATH/bin/mongodb_setup.py && echo "${cluster} MongoDB Cluster STARTED."
$DSI_PATH/bin/mongodb_setup.py && echo "${setup} MongoDB Cluster STARTED."
"run test":
- command: shell.exec
Expand Down

0 comments on commit 5eb2814

Please sign in to comment.