diff options
author | Dmitry Tantsur <divius.inside@gmail.com> | 2018-12-11 18:17:30 +0100 |
---|---|---|
committer | Dmitry Tantsur <divius.inside@gmail.com> | 2018-12-13 16:44:33 +0100 |
commit | 78d6d95033fa8040157160d010377f571965f981 (patch) | |
tree | 78c1151edbd49d75c8ffeb6546b5dcd5d525d346 /ironic/cmd | |
parent | c5a4ad8006d20d482696e1d0c2a2298af7d846c2 (diff) | |
download | ironic-78d6d95033fa8040157160d010377f571965f981.tar.gz |
Ignore newly introduced tables in pre-upgrade versions check
The version check is run before tables are created, so it cannot
succeed for them.
Change-Id: Ibcf0728bc5d1b0cbdd78796526f9c93fc99e8c08
Story: #2004589
Task: #28467
Diffstat (limited to 'ironic/cmd')
-rw-r--r-- | ironic/cmd/dbsync.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ironic/cmd/dbsync.py b/ironic/cmd/dbsync.py index 99badb4df..52012a2c3 100644 --- a/ironic/cmd/dbsync.py +++ b/ironic/cmd/dbsync.py @@ -78,10 +78,15 @@ ONLINE_MIGRATIONS = ( (dbapi, 'update_to_latest_versions'), ) +# These are the models added in supported releases. We skip the version check +# for them since the tables do not exist when it happens. +NEW_MODELS = [ +] + class DBCommand(object): - def _check_versions(self): + def _check_versions(self, ignore_missing_tables=False): """Check the versions of objects. Check that the object versions are compatible with this release @@ -94,8 +99,13 @@ class DBCommand(object): # no tables, nothing to check return + if ignore_missing_tables: + ignore_models = NEW_MODELS + else: + ignore_models = () + try: - if not dbapi.check_versions(): + if not dbapi.check_versions(ignore_models=ignore_models): sys.stderr.write( _('The database is not compatible with this ' 'release of ironic (%s). Please run ' @@ -119,7 +129,7 @@ class DBCommand(object): sys.exit(2) def upgrade(self): - self._check_versions() + self._check_versions(ignore_missing_tables=True) migration.upgrade(CONF.command.revision) def revision(self): |