summaryrefslogtreecommitdiff
path: root/ironic/cmd
diff options
context:
space:
mode:
authorRuby Loo <ruby.loo@intel.com>2017-08-24 20:56:22 -0400
committerRuby Loo <ruby.loo@intel.com>2017-10-23 12:52:25 +0000
commit6a91b38ca48eea2892a5a82b4369f1f9b277d019 (patch)
tree993c13981bf3baf61234b5346ae7bf8cbff4e0e5 /ironic/cmd
parent7f64a501c3dd95d20c25e4872226b10dbec207fc (diff)
downloadironic-6a91b38ca48eea2892a5a82b4369f1f9b277d019.tar.gz
ironic-dbsync: check object versions
Now that we have rolling upgrades and the version column was added and populated in the Pike release, we can add checks to make sure the versions of objects in the DB are compatible with this ironic release, before ironic-dbsync's upgrade or online_data_migrations does its work. These ironic-dbsync calls are made as part of upgrading to this (Queens) release. Change-Id: I68758f8a29d483f5c0a7439fa2ea2962b2eb4124 Partial-Bug: #1708243
Diffstat (limited to 'ironic/cmd')
-rw-r--r--ironic/cmd/dbsync.py33
1 files changed, 12 insertions, 21 deletions
diff --git a/ironic/cmd/dbsync.py b/ironic/cmd/dbsync.py
index 93a1ffd46..6c34bee21 100644
--- a/ironic/cmd/dbsync.py
+++ b/ironic/cmd/dbsync.py
@@ -75,6 +75,10 @@ class DBCommand(object):
If it isn't compatible, we exit the program, returning 2.
"""
+ if migration.version() is None:
+ # no tables, nothing to check
+ return
+
if not dbapi.check_versions():
sys.stderr.write(_('The database is not compatible with this '
'release of ironic (%s). Please run '
@@ -86,13 +90,7 @@ class DBCommand(object):
sys.exit(2)
def upgrade(self):
- # TODO(rloo): enable this in Queens because we want the check done
- # before someone tries to upgrade to Queens.
- # It won't work now because the check looks at the value in the new
- # 'version' column for all objects. And this column doesn't exist until
- # *after* an upgrade to this Pike release (i.e., after this
- # 'ironic-dbsync upgrade' is run).
- # self._check_versions()
+ self._check_versions()
migration.upgrade(CONF.command.revision)
def revision(self):
@@ -108,12 +106,7 @@ class DBCommand(object):
migration.create_schema()
def online_data_migrations(self):
- # TODO(rloo): enable this in Queens.
- # It won't work now because the check looks at the value in the new
- # 'version' column for all objects, which cannot be null/None. In Pike,
- # only after running this 'ironic-dbsync online_data_migrations'
- # command, will the version column be populated.
- # self._check_versions()
+ self._check_versions()
self._run_online_data_migrations(max_count=CONF.command.max_count)
def _run_migration_functions(self, context, max_count):
@@ -217,16 +210,14 @@ def add_command_parsers(subparsers):
parser = subparsers.add_parser(
'upgrade',
- # TODO(rloo): Add this to the help string in Queens (because we need
- # to wait until online_data_migrations exists in older release first):
- # It returns 2 (error) if the database is "
- # "not compatible with this version. If this happens, the "
- # "'ironic-dbsync online_data_migrations' command should be run "
- # "using the previous version of ironic, before upgrading and "
- # "running this command."))
help=_("Upgrade the database schema to the latest version. "
"Optionally, use --revision to specify an alembic revision "
- "string to upgrade to."))
+ "string to upgrade to. It returns 2 (error) if the database is "
+ "not compatible with this version. If this happens, the "
+ "'ironic-dbsync online_data_migrations' command should be run "
+ "using the previous version of ironic, before upgrading and "
+ "running this command."))
+
parser.set_defaults(func=command_object.upgrade)
parser.add_argument('--revision', nargs='?')