From 82216c8764b47b4e2de93533b47af2d5aaf2730f Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 29 Sep 2015 14:45:50 +0200 Subject: [PATCH] Deprecate branchless migration chains from neutron-db-manage Support for the scheme puts additional burden on neutron-db-manage maintainers. The split branches were introduced in all 'official' subprojects in Liberty, so it's fine to deprecate it in Mitaka, and drop in Noodle. Since there is no user actionable item to do for users, using debtcollector that will only issue DeprecationWarning if they are enabled. The assumption is that developers run their tests with that enabled (as the BaseTestCase ensures) and handle warnings. Related-Bug: #1501380 Change-Id: Ie4ddd29d8c51be74a112864aae3d16fb5e52c0fa --- neutron/db/migration/cli.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index c04205e4433..5f775fc04df 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -13,17 +13,18 @@ # under the License. import os -import six from alembic import command as alembic_command from alembic import config as alembic_config from alembic import environment from alembic import script as alembic_script from alembic import util as alembic_util +import debtcollector from oslo_config import cfg from oslo_utils import fileutils from oslo_utils import importutils import pkg_resources +import six from neutron.common import utils @@ -42,6 +43,10 @@ migration_entrypoints = { for entrypoint in pkg_resources.iter_entry_points(MIGRATION_ENTRYPOINTS) } + +BRANCHLESS_WARNING = 'Branchless migration chains are deprecated as of Mitaka.' + + neutron_alembic_ini = os.path.join(os.path.dirname(__file__), 'alembic.ini') VALID_SERVICES = ['fwaas', 'lbaas', 'vpnaas'] @@ -298,7 +303,11 @@ def validate_head_file(config): '''Check that HEAD file contains the latest head for the branch.''' if _use_separate_migration_branches(config): return + _validate_head_file(config) + +@debtcollector.removals.remove(message=BRANCHLESS_WARNING) +def _validate_head_file(config): script = alembic_script.ScriptDirectory.from_config(config) expected_head = script.get_heads() head_path = _get_head_file_path(config) @@ -316,19 +325,23 @@ def validate_head_file(config): def update_head_file(config): '''Update HEAD file with the latest branch head.''' - head_file = _get_head_file_path(config) - if _use_separate_migration_branches(config): # Kill any HEAD(S) files because we don't rely on them for branch-aware # chains anymore - files_to_remove = [head_file, _get_heads_file_path(config)] + files_to_remove = [ + _get_head_file_path(config), _get_heads_file_path(config) + ] for file_ in files_to_remove: fileutils.delete_if_exists(file_) return + _update_head_file(config) + +@debtcollector.removals.remove(message=BRANCHLESS_WARNING) +def _update_head_file(config): script = alembic_script.ScriptDirectory.from_config(config) head = script.get_heads() - with open(head_file, 'w+') as f: + with open(_get_head_file_path(config), 'w+') as f: f.write('\n'.join(head))