When the 'connection' configuration key is NOT defined in /etc/nova/nova.conf the nova-common.postinst script still tries to run 'nova-manage db sync'
root@juju-b24bc9-mno-18:~# grep connection /etc/nova/nova.conf
root@juju-b24bc9-mno-18:~# dpkg-reconfigure nova-common
Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
Option "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future.
ERROR: could not access cell mapping database - has api db been created?
An error has occurred:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nova/cmd/manage.py", line 1602, in main
ret = fn(*fn_args, **fn_kwargs)
File "/usr/lib/python2.7/dist-packages/nova/cmd/manage.py", line 645, in sync
return migration.db_sync(version)
File "/usr/lib/python2.7/dist-packages/nova/db/migration.py", line 26, in db_sync
return IMPL.db_sync(version=version, database=database, context=context)
File "/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/migration.py", line 57, in db_sync
repository, version)
File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 186, in upgrade
return _migrate(url, repository, version, upgrade=True, err=err, **opts)
File "<decorator-gen-15>", line 2, in _migrate
File "/usr/lib/python2.7/dist-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
return f(*a, **kw)
File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 366, in _migrate
schema.runchange(ver, change, changeset.step)
File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 93, in runchange
change.run(self.engine, step)
File "/usr/lib/python2.7/dist-packages/migrate/versioning/script/py.py", line 148, in run
script_func(engine)
File "/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/migrate_repo/versions/345_require_online_migration_completion.py", line 44, in upgrade
raise exception.ValidationError(detail=msg)
ValidationError: Migration cannot continue until all these have been migrated to the api database. Please run `nova-manage db online_migrations' on Newton code before continuing.There are still 5 unmigrated flavors.
Running the postinst script manually with -x
root@juju-b24bc9-mno-18:~# bash -ex /var/lib/dpkg/info/nova-common.postinst configure
+ '[' configure = configure ']'
+ getent group nova
+ getent passwd nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chown -R nova:nova /etc/nova
+ chown -R nova:adm /var/log/nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chmod 0640 /etc/nova/nova.conf
+ chmod 0640 /etc/nova/api-paste.ini
+ chmod 0750 /etc/nova
+ chmod 0750 /var/log/nova
+ chown root:root /etc/nova/rootwrap.conf
+ chown root:root /etc/nova/rootwrap.d
+ chmod 0755 /etc/nova/rootwrap.d
+ grep -qE '^(sql_)?connection( )?=.*' /etc/nova/nova.conf
+ su -s /bin/sh -c 'nova-manage db sync' nova
Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
Option "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future.
ERROR: could not access cell mapping database - has api db been created?
An error has occurred:
Traceback (most recent call last):
...
ValidationError: Migration cannot continue until all these have been migrated to the api database. Please run `nova-manage db online_migrations' on Newton code before continuing.There are still 5 unmigrated flavors.
The condition to run the sync operation should be that the connection config key is defined in nova.conf
When the 'connection' configuration key is NOT defined in /etc/nova/nova.conf the nova-common. postinst script still tries to run 'nova-manage db sync'
root@juju- b24bc9- mno-18: ~# grep connection /etc/nova/nova.conf b24bc9- mno-18: ~# dpkg-reconfigure nova-common python2. 7/dist- packages/ nova/cmd/ manage. py", line 1602, in main python2. 7/dist- packages/ nova/cmd/ manage. py", line 645, in sync db_sync( version) python2. 7/dist- packages/ nova/db/ migration. py", line 26, in db_sync sync(version= version, database=database, context=context) python2. 7/dist- packages/ nova/db/ sqlalchemy/ migration. py", line 57, in db_sync python2. 7/dist- packages/ migrate/ versioning/ api.py" , line 186, in upgrade gen-15> ", line 2, in _migrate python2. 7/dist- packages/ migrate/ versioning/ util/__ init__. py", line 160, in with_engine python2. 7/dist- packages/ migrate/ versioning/ api.py" , line 366, in _migrate runchange( ver, change, changeset.step) python2. 7/dist- packages/ migrate/ versioning/ schema. py", line 93, in runchange run(self. engine, step) python2. 7/dist- packages/ migrate/ versioning/ script/ py.py", line 148, in run func(engine) python2. 7/dist- packages/ nova/db/ sqlalchemy/ migrate_ repo/versions/ 345_require_ online_ migration_ completion. py", line 44, in upgrade ValidationError (detail= msg)
root@juju-
Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
Option "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future.
ERROR: could not access cell mapping database - has api db been created?
An error has occurred:
Traceback (most recent call last):
File "/usr/lib/
ret = fn(*fn_args, **fn_kwargs)
File "/usr/lib/
return migration.
File "/usr/lib/
return IMPL.db_
File "/usr/lib/
repository, version)
File "/usr/lib/
return _migrate(url, repository, version, upgrade=True, err=err, **opts)
File "<decorator-
File "/usr/lib/
return f(*a, **kw)
File "/usr/lib/
schema.
File "/usr/lib/
change.
File "/usr/lib/
script_
File "/usr/lib/
raise exception.
ValidationError: Migration cannot continue until all these have been migrated to the api database. Please run `nova-manage db online_migrations' on Newton code before continuing.There are still 5 unmigrated flavors.
Running the postinst script manually with -x
root@juju- b24bc9- mno-18: ~# bash -ex /var/lib/ dpkg/info/ nova-common. postinst configure api-paste. ini rootwrap. conf rootwrap. d rootwrap. d )?connection( )?=.*' /etc/nova/nova.conf
+ '[' configure = configure ']'
+ getent group nova
+ getent passwd nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chown -R nova:nova /etc/nova
+ chown -R nova:adm /var/log/nova
+ '[' -z '' ']'
+ chown -R nova:nova /var/lib/nova/
+ chmod 0640 /etc/nova/nova.conf
+ chmod 0640 /etc/nova/
+ chmod 0750 /etc/nova
+ chmod 0750 /var/log/nova
+ chown root:root /etc/nova/
+ chown root:root /etc/nova/
+ chmod 0755 /etc/nova/
+ grep -qE '^(sql_
+ su -s /bin/sh -c 'nova-manage db sync' nova
Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
Option "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future.
ERROR: could not access cell mapping database - has api db been created?
An error has occurred:
Traceback (most recent call last):
...
ValidationError: Migration cannot continue until all these have been migrated to the api database. Please run `nova-manage db online_migrations' on Newton code before continuing.There are still 5 unmigrated flavors.
The condition to run the sync operation should be that the connection config key is defined in nova.conf
# diff -u /var/lib/ dpkg/info/ nova-common. postinst ./nova- common. postinst dpkg/info/ nova-common. postinst 2017-06-19 08:12:49.000000000 +0000 common. postinst 2017-08-25 13:08:48.852744427 +0000 rootwrap. d rootwrap. d
--- /var/lib/
+++ ./nova-
@@ -47,8 +47,8 @@
chown root:root /etc/nova/
chmod 0755 /etc/nova/
- if ! grep -qE "^(sql_ )?connection( )?=.*" /etc/nova/nova.conf || \ )?connection. *sqlite. *" /etc/nova/nova.conf )?connection( )?=.*" /etc/nova/nova.conf || \ )?connection. *sqlite. *" /etc/nova/nova.conf
- grep -qE "^(sql_
+ if grep -qE "^(sql_
+ grep -qE "^(sql_
then
su -s /bin/sh -c 'nova-manage db sync' nova
fi