diff options
author | Doug Shelley <doug@parelastic.com> | 2016-07-28 00:15:41 +0000 |
---|---|---|
committer | Peter Stachowski <peter@tesora.com> | 2016-08-09 17:01:27 +0000 |
commit | 4f6ce5d5cae5a7ca3ef92ebd90611dacf2ed9f07 (patch) | |
tree | b5f183839d478427048e1c5a3163826969899694 | |
parent | bf6e9296f80811b7f6cf39d01c6d98588969f193 (diff) | |
download | trove-integration-4f6ce5d5cae5a7ca3ef92ebd90611dacf2ed9f07.tar.gz |
Add "clean" command to redstack
A long time request has been to add a "redstack clean"
command that would clean out all the trove, nova, cinder
etc resources left around after a failed test run.
This commit adds a "clean" command to redstack. It is a
first cut and hopefully can be evolved by the community
over time.
Change-Id: I5e2e28936161e65e0a4edfa5c4b9d5ffcab6cee8
-rwxr-xr-x | scripts/redstack | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/redstack b/scripts/redstack index 6c3e716..75eec90 100755 --- a/scripts/redstack +++ b/scripts/redstack @@ -1134,6 +1134,51 @@ function cmd_clear() { cmd_wipe_queues } +function exec_cmd_on_output() { + local output_cmd=$1 + local exec_cmd=$2 + local skip_id=${3:-""} + + echo "Cleaning up objects from '${output_cmd}'" + exec $output_cmd|awk -vexec_cmd="$exec_cmd" -vskip_id="$skip_id" '{if (NR>3 && $2!="" && $2!=skip_id && $2!="|") { cmd = exec_cmd " " $2; print "Executing " cmd; system(cmd) } }' +} + + +function cmd_clean() { + echo "Cleaning up project '${OS_PROJECT_NAME}'" + # reset any stuck backups + mysql_trove "update backups set state='COMPLETED'" + # clear out any DS version metadata + mysql_trove "delete from datastore_version_metadata" + # reset any stuck instances, and clear all replicas + mysql_trove "update instances set task_id=2, slave_of_id=null" + # reset any stuck clusters + mysql_trove "update clusters set task_id=1" + # get rid of any extraneous quota usage + mysql_trove "delete from quota_usages" + + source $PATH_DEVSTACK_SRC/openrc admin ${OS_PROJECT_NAME} + # delete any trove clusters + exec_cmd_on_output "trove cluster-list" "trove cluster-delete" + # delete any trove instances + exec_cmd_on_output "trove list" "trove delete" + # delete any backups + exec_cmd_on_output "trove backup-list" "trove backup-delete" + # sleep for a bit and then clean up + # any remaining nova instances or cinder volumes + sleep 5 + exec_cmd_on_output "nova list" "nova delete" + sleep 2 + exec_cmd_on_output "cinder list" "cinder delete" + # delete any config groups since all instances should be gone now + exec_cmd_on_output "trove configuration-list" "trove configuration-delete" + # delete any modules too + exec_cmd_on_output "trove module-list" "trove module-delete" + # make sure that security groups are also gone, except the default + exec_cmd_on_output "nova secgroup-list" "nova secgroup-delete" "1" + echo "If any errors occurred wait a few seconds and run the command again" +} + function cmd_kick_start() { cmd_test_init $1 cmd_build_and_upload_image $1 @@ -1304,6 +1349,7 @@ function print_usage() { rd-sql - Opens the Trove MySQL database. vagrant-ssh - Runs a command from the host on the server. clear - Destroy instances and rabbit queues. + clean - Clean up resources created by a failed test run. run - Starts RD but not in a screen. run-fake - Runs the server in fake mode. update-projects - Git pull on all the daemons trove dependencies. @@ -1341,6 +1387,7 @@ function run_command() { "debug" ) shift; echo "Enabling debugging."; \ set -o xtrace; run_command $@;; "clear" ) shift; cmd_clear $@;; + "clean" ) shift; cmd_clean $@;; "run" ) shift; cmd_run $@;; "kick-start" ) shift; cmd_kick_start $@;; "dsvm-gate-tests" ) shift; cmd_dsvm_gate_tests $@;; |