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
This commit is contained in:
Ihar Hrachyshka 2015-09-29 14:45:50 +02:00
parent bcf9052e8c
commit 82216c8764
1 changed files with 18 additions and 5 deletions

View File

@ -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))