Merge "Perform flavor_data_migration before to backup DB"
This commit is contained in:
commit
640faa150e
|
@ -33,6 +33,7 @@ def upgrade_db(orig_id, seed_id, db_role_name):
|
|||
env_util.delete_fuel_resources(seed_env)
|
||||
# Wait for Neutron to reconfigure networks
|
||||
time.sleep(7) # FIXME: Use more deterministic way
|
||||
db.nova_migrate_flavor_data(orig_env)
|
||||
maintenance.disable_apis(orig_env)
|
||||
maintenance.stop_corosync_services(seed_env)
|
||||
maintenance.stop_upstart_services(seed_env)
|
||||
|
|
|
@ -14,7 +14,6 @@ import io
|
|||
|
||||
import mock
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import db
|
||||
from octane.util import ssh
|
||||
|
||||
|
@ -67,16 +66,12 @@ def test_db_sync(mocker, node, mock_subprocess, mock_ssh_call):
|
|||
get_one_controller = mocker.patch('octane.util.env.get_one_controller')
|
||||
get_one_controller.return_value = node
|
||||
|
||||
applied_patches = mocker.patch("octane.util.ssh.applied_patches")
|
||||
fix_migration_mock = mocker.patch("octane.util.db.fix_neutron_migrations")
|
||||
|
||||
db.db_sync('env')
|
||||
|
||||
fix_migration_mock.assert_called_once_with(node)
|
||||
|
||||
applied_patches.assert_called_once_with(
|
||||
magic_consts.NOVA_PATCH_PREFIX_DIR, node, *magic_consts.NOVA_PATCHES)
|
||||
|
||||
assert not mock_subprocess.called
|
||||
assert all(call[1]['parse_levels']
|
||||
for call in mock_ssh_call.call_args_list)
|
||||
|
|
|
@ -10,13 +10,18 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import env as env_util
|
||||
from octane.util import ssh
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_databases(env):
|
||||
node = env_util.get_one_controller(env)
|
||||
with ssh.popen([
|
||||
|
@ -31,6 +36,33 @@ def get_databases(env):
|
|||
return out.splitlines()
|
||||
|
||||
|
||||
def nova_migrate_flavor_data(env, attempts=20, attempt_delay=30):
|
||||
node = env_util.get_one_controller(env)
|
||||
for i in xrange(attempts):
|
||||
output = ssh.call_output(['nova-manage', 'db', 'migrate_flavor_data'],
|
||||
node=node, parse_levels=True)
|
||||
match = FLAVOR_STATUS_RE.match(output)
|
||||
if not match:
|
||||
raise Exception(
|
||||
"The format of the migrate_flavor_data command was changed: "
|
||||
"'{0}'".format(output))
|
||||
params = match.groupdict()
|
||||
matched = int(params["matched"])
|
||||
completed = int(params["completed"])
|
||||
if matched == 0:
|
||||
LOG.info("All flavors were successfully migrated.")
|
||||
return
|
||||
LOG.debug("Trying to migrate flavors data, iteration %s: %s matches, "
|
||||
"%s completed", i, matched, completed)
|
||||
time.sleep(attempt_delay)
|
||||
raise Exception(
|
||||
"After %s attempts flavors data migration is still not ""completed")
|
||||
|
||||
FLAVOR_STATUS_RE = re.compile(
|
||||
r"^(?P<matched>[0-9]+) instances matched query, "
|
||||
"(?P<completed>[0-9]+) completed$")
|
||||
|
||||
|
||||
def mysqldump_from_env(env, role_name, dbs, fname):
|
||||
node = env_util.get_one_node_of(env, role_name)
|
||||
cmd = [
|
||||
|
@ -75,26 +107,8 @@ def fix_neutron_migrations(node):
|
|||
def db_sync(env):
|
||||
node = env_util.get_one_controller(env)
|
||||
ssh.call(['keystone-manage', 'db_sync'], node=node, parse_levels=True)
|
||||
# migrate nova in few steps
|
||||
# at start sync up to 290 step
|
||||
# (this migration check flavor instances consistency)
|
||||
# than migrate flavor (transform them to normal state)
|
||||
# after that sync nova to the end
|
||||
with ssh.applied_patches(magic_consts.NOVA_PATCH_PREFIX_DIR,
|
||||
node,
|
||||
*magic_consts.NOVA_PATCHES):
|
||||
ssh.call(
|
||||
['nova-manage', 'db', 'sync', '--version', '290'],
|
||||
node=node, parse_levels=True)
|
||||
ssh.call(
|
||||
['nova-manage', 'db', 'migrate_flavor_data'],
|
||||
node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'db', 'sync'], node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'db', 'expand'], node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'db', 'migrate'],
|
||||
node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'db', 'contract', '--force-experimental'],
|
||||
node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'db', 'sync'], node=node, parse_levels=True)
|
||||
ssh.call(['nova-manage', 'api_db', 'sync'], node=node, parse_levels=True)
|
||||
ssh.call(['heat-manage', 'db_sync'], node=node, parse_levels=True)
|
||||
ssh.call(['glance-manage', 'db_sync'], node=node, parse_levels=True)
|
||||
ssh.call(['neutron-db-manage', '--config-file=/etc/neutron/neutron.conf',
|
||||
|
|
Loading…
Reference in New Issue