From ffe7a2cf34b22527e748835b8d47e1bd4c117c70 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Sun, 12 Jan 2014 13:57:55 +1100 Subject: [PATCH] Better cost metrics. This review attempts to provide better cost metrics for the upgrade steps. I do a few things: - restart mysql before the upgrades to flush innodb buffers and caches - run each migration as a separate job - log the innodb counters from mysql after each run This will provide some first order metrics which are better than wall time -- for example the number of written rows is probably a more interesting metric than the number of seconds on a loaded instance with a noisy neighbour. We also need to do git pulls on stable branches, as zuul doesn't do that for us. Change-Id: I39e964a9bbe43717b5a5b5dfd236ee2fa2c62a00 --- etc/sudoers | 1 + .../gate_real_db_upgrade/gerrit-git-prep.sh | 5 +- .../nova_mysql_migrations.sh | 80 ++++++++++++++----- .../task_plugins/gate_real_db_upgrade/task.py | 8 +- 4 files changed, 71 insertions(+), 23 deletions(-) diff --git a/etc/sudoers b/etc/sudoers index d75d601..74e7a5c 100644 --- a/etc/sudoers +++ b/etc/sudoers @@ -27,6 +27,7 @@ root ALL=(ALL:ALL) ALL # Turbo Hipster th ALL=(root) NOPASSWD: /sbin/ip netns exec nonet * +th ALL=(root) NOPASSWD: /usr/sbin/service mysql * # See sudoers(5) for more information on "#include" directives: diff --git a/turbo_hipster/task_plugins/gate_real_db_upgrade/gerrit-git-prep.sh b/turbo_hipster/task_plugins/gate_real_db_upgrade/gerrit-git-prep.sh index 28c2bf0..16b4aaf 100755 --- a/turbo_hipster/task_plugins/gate_real_db_upgrade/gerrit-git-prep.sh +++ b/turbo_hipster/task_plugins/gate_real_db_upgrade/gerrit-git-prep.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -# Stolen from http://git.openstack.org/cgit/openstack-infra/config/plain/modules/jenkins/files/slave_scripts/gerrit-git-prep.sh +# Stolen from http://git.openstack.org/cgit/openstack-infra/config/plain/modules/jenkins/files/slave_scripts/gerrit-git-prep.sh but has been hacked to be AWESOME! GERRIT_SITE=$1 ZUUL_SITE=$2 @@ -49,7 +49,7 @@ then fi fi git checkout master -git branch -D working || true +git pull git remote set-url origin $GIT_ORIGIN/$ZUUL_PROJECT # attempt to work around bugs 925790 and 1229352 @@ -83,6 +83,7 @@ else git clean -x -f -d -q fi fi +git branch -D working || true git checkout -b working if [ -f .gitmodules ] diff --git a/turbo_hipster/task_plugins/gate_real_db_upgrade/nova_mysql_migrations.sh b/turbo_hipster/task_plugins/gate_real_db_upgrade/nova_mysql_migrations.sh index 3e0b29b..0a6dfbd 100755 --- a/turbo_hipster/task_plugins/gate_real_db_upgrade/nova_mysql_migrations.sh +++ b/turbo_hipster/task_plugins/gate_real_db_upgrade/nova_mysql_migrations.sh @@ -49,7 +49,7 @@ db_sync() { # $5 is the nova db password # $6 is the nova db name # $7 is the logging.conf for openstack - # $8 is any sync options + # $8 is an (optional) destination version number # Create a nova.conf file cat - > $2/nova-$1.conf < /dev/null -git checkout -b working - stable_release_db_sync $2 $3 $4 $5 $6 $8 last_stable_version=`mysql -u $4 --password=$5 $6 -e "select * from migrate_version \G" | grep version | sed 's/.*: //'` @@ -179,16 +223,14 @@ db_sync "patchset" $2 $3 $4 $5 $6 $8 version=`mysql -u $4 --password=$5 $6 -e "select * from migrate_version \G" | grep version | sed 's/.*: //'` echo "Schema version is $version" -#target_version=`ls $3/nova/db/sqlalchemy/migrate_repo/versions | head -1 | cut -f 1 -d "_"` echo "Now downgrade all the way back to the last stable version (v$last_stable_version)" -db_sync "patchset" $2 $3 $4 $5 $6 $8 "--version $last_stable_version" +db_sync "downgrade" $2 $3 $4 $5 $6 $8 $last_stable_version # Determine the schema version version=`mysql -u $4 --password=$5 $6 -e "select * from migrate_version \G" | grep version | sed 's/.*: //'` echo "Schema version is $version" echo "And now back up to head from the start of trunk" -git checkout working # I think this line is redundant db_sync "patchset" $2 $3 $4 $5 $6 $8 # Determine the final schema version diff --git a/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py b/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py index 5f338d5..fb6d7d5 100644 --- a/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py +++ b/turbo_hipster/task_plugins/gate_real_db_upgrade/task.py @@ -13,6 +13,7 @@ # under the License. +import copy import json import logging import os @@ -306,12 +307,15 @@ class Runner(object): if not os.path.exists(local_path): os.makedirs(local_path) + git_args = copy.deepcopy(job_args) + git_args['GIT_ORIGIN'] = 'git://git.openstack.org/' + cmd = os.path.join(os.path.join(os.path.dirname(__file__), 'gerrit-git-prep.sh')) cmd += ' https://review.openstack.org' cmd += ' http://zuul.rcbops.com' - utils.execute_to_log(cmd, job_log_file_path, - env=job_args, cwd=local_path) + utils.execute_to_log(cmd, job_log_file_path, env=git_args, + cwd=local_path) return local_path def _get_work_data(self):