]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Deprecate branchless migration chains from neutron-db-manage
authorIhar Hrachyshka <ihrachys@redhat.com>
Tue, 29 Sep 2015 12:45:50 +0000 (14:45 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Wed, 30 Sep 2015 16:59:36 +0000 (18:59 +0200)
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

index c04205e443386c0c0440603f482ae9bcc70b77d0..5f775fc04df5720e0f0ef928b6f797a695d72e7f 100644 (file)
 #    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))