Merge "Address db_sync check against new install"
This commit is contained in:
commit
66c8612fb1
@ -225,7 +225,7 @@ authenticate requests normally.
|
||||
the previous release.
|
||||
|
||||
Using db_sync check
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In order to check the current state of your rolling upgrades, you may run the
|
||||
command ``keystone-manage db_sync --check``. This will inform you of any
|
||||
@ -239,8 +239,9 @@ can make from your current version. Here are a list of possible return codes.
|
||||
database and operator intervention will be required.
|
||||
|
||||
* A return code of ``2`` means that an upgrade from your current database
|
||||
version is available and your first step is to run ``keystone-manage
|
||||
db_sync --expand``.
|
||||
version is available, your database is not currently under version control,
|
||||
or the database is already under control. Your first step is to run
|
||||
``keystone-manage db_sync --expand``.
|
||||
|
||||
* A return code of ``3`` means that the expansion stage is complete, and the
|
||||
next step is to run ``keystone-manage db_sync --migrate``.
|
||||
|
@ -21,6 +21,7 @@ import uuid
|
||||
|
||||
import migrate
|
||||
from oslo_config import cfg
|
||||
from oslo_db.sqlalchemy import migration
|
||||
from oslo_log import log
|
||||
from oslo_log import versionutils
|
||||
from oslo_serialization import jsonutils
|
||||
@ -457,10 +458,17 @@ class DbSync(BaseApp):
|
||||
@classmethod
|
||||
def check_db_sync_status(self):
|
||||
status = 0
|
||||
expand_version = upgrades.get_db_version(repo='expand_repo')
|
||||
migrate_version = upgrades.get_db_version(
|
||||
repo='data_migration_repo')
|
||||
contract_version = upgrades.get_db_version(repo='contract_repo')
|
||||
try:
|
||||
expand_version = upgrades.get_db_version(repo='expand_repo')
|
||||
migrate_version = upgrades.get_db_version(
|
||||
repo='data_migration_repo')
|
||||
contract_version = upgrades.get_db_version(repo='contract_repo')
|
||||
except migration.exception.DbMigrationError:
|
||||
LOG.info(_LI('Your database is not currently under version '
|
||||
'control or the database is already controlled. Your '
|
||||
'first step is to run `keystone-manage db_sync '
|
||||
'--expand`.'))
|
||||
return 2
|
||||
|
||||
repo = migrate.versioning.repository.Repository(
|
||||
upgrades.find_repo('expand_repo'))
|
||||
|
@ -19,6 +19,7 @@ import uuid
|
||||
import fixtures
|
||||
import mock
|
||||
import oslo_config.fixture
|
||||
from oslo_db.sqlalchemy import migration
|
||||
from oslo_log import log
|
||||
from oslotest import mockpatch
|
||||
from six.moves import configparser
|
||||
@ -680,6 +681,17 @@ class CliDBSyncTestCase(unit.BaseTestCase):
|
||||
cli.DbSync.main()
|
||||
self._assert_correct_call(upgrades.contract_schema)
|
||||
|
||||
@mock.patch('keystone.cmd.cli.upgrades.get_db_version')
|
||||
def test_db_sync_check_when_database_is_empty(self, mocked_get_db_version):
|
||||
e = migration.exception.DbMigrationError("Invalid version")
|
||||
mocked_get_db_version.side_effect = e
|
||||
checker = cli.DbSync()
|
||||
|
||||
log_info = self.useFixture(fixtures.FakeLogger(level=log.INFO))
|
||||
status = checker.check_db_sync_status()
|
||||
self.assertIn("not currently under version control", log_info.output)
|
||||
self.assertEqual(status, 2)
|
||||
|
||||
|
||||
class TestMappingPopulate(unit.SQLDriverOverrides, unit.TestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user