Description of problem: For db migrations in neutron is mandatory to have current stamp stored in alembic_version table. There is a tool neutron-db-manage which is capable of migrations and after each migration it stamps current version. 'neutron-db-manage upgrade head' is probably a good way to create database for neutron with correct stamp. Version-Release number of selected component (if applicable): openstack-packstack-2013.2.1-0.11.dev847.el6ost.noarch How reproducible: Always Steps to Reproduce: 1. Install neutron using packstack 2. neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini current 3. Actual results: None Expected results: havana Additional info: This blocks migration between neutron versions.
Terry, could you please give us a hand here?
Alvaro: The command `neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head` would be run in postscript_948.py if os-neutron-install=y to make sure that the database is stamped with the version of the database that was just set up. This would migrate the database of a previous release if it existed as well--which I don't think is a bad thing, but someone else might want to comment as well.
It seems this has come up several times in different contexts, best reference is probably [1] Although per comment #2 we could do this in a postscript file, it also seems that it should be something the puppet modules could handle. Indeed I found [2] by Dan Prince to implement this. The patch was abandoned after I assume discussion -- maybe upstream went a different way on master? But we could still use Dan's patch? Dan, can you comment on what we should do? [1] https://bugs.launchpad.net/neutron/+bug/1207402 [2] https://review.openstack.org/#/c/50162/
Terry, I added that command to the puppet postscript, but I get an error as per the following --- -bash-4.1# neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head No handlers could be found for logger "neutron.common.legacy" INFO [alembic.migration] Context impl SQLiteImpl. INFO [alembic.migration] Will assume transactional DDL. INFO [alembic.migration] Running upgrade None -> folsom Traceback (most recent call last): File "/usr/bin/neutron-db-manage", line 10, in <module> sys.exit(main()) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 143, in main CONF.command.func(config, CONF.command.name) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 80, in do_upgrade_downgrade do_alembic_command(config, cmd, revision, sql=CONF.command.sql) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 59, in do_alembic_command getattr(alembic_command, cmd)(config, *args, **kwargs) File "/usr/lib/python2.6/site-packages/alembic/command.py", line 124, in upgrade script.run_env() File "/usr/lib/python2.6/site-packages/alembic/script.py", line 191, in run_env util.load_python_file(self.dir, 'env.py') File "/usr/lib/python2.6/site-packages/alembic/util.py", line 186, in load_python_file module = imp.load_source(module_id, path, open(path, 'rb')) File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 105, in <module> run_migrations_online() File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 89, in run_migrations_online options=build_options()) File "<string>", line 7, in run_migrations File "/usr/lib/python2.6/site-packages/alembic/environment.py", line 494, in run_migrations self.get_context().run_migrations(**kw) File "/usr/lib/python2.6/site-packages/alembic/migration.py", line 211, in run_migrations change(**kw) File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/versions/folsom_initial.py", line 74, in upgrade upgrade_base() File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/versions/folsom_initial.py", line 111, in upgrade_base sa.PrimaryKeyConstraint('id') File "<string>", line 7, in create_table File "/usr/lib/python2.6/site-packages/alembic/operations.py", line 570, in create_table self._table(name, *columns, **kw) File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 148, in create_table self._exec(schema.CreateTable(table)) File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 75, in _exec conn.execute(construct, *multiparams, **params) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1449, in execute params) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1542, in _execute_ddl compiled File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1698, in _execute_context context) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context context) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 331, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (OperationalError) table networks already exists u'\nCREATE TABLE networks (\n\ttenant_id VARCHAR(255), \n\tid VARCHAR(36) NOT NULL, \n\tname VARCHAR(255), \n\tstatus VARCHAR(16), \n\tadmin_state_up BOOLEAN, \n\tshared BOOLEAN, \n\tPRIMARY KEY (id), \n\tCHECK (admin_state_up IN (0, 1)), \n\tCHECK (shared IN (0, 1))\n)\n\n' () --- Do you think perhaps we should use --- neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini stamp head --- instead?
Hello all, I really think this needs to happen in the Puppet modules, not in the spec file. We can't sanely create the database when performing a fresh install because neutron is unconfigured at that point -- there are no database credentials, and probably no database. This can only happen once an appropriate Neutron configuration is in place along with the necessary databases, grant entries, and so forth. This change needs to be made in the appropriate Puppet module where it will be used by both packstack and foreman. Terry's comment in #2 seems to be heading in the right direction, except that we probably do *not* want to accidentally upgrade the database. The only behavior we're looking for is: - Properly set the schema version information when initially creating the neutron database. As Jakub mentions in the description, the "neutron-db-manage ... upgrade head" command will Do The Right Thing when run against an empty (no tables) database. We really want to have this in place for the RHOS 4 release because we're modifying the neutron-server to require version information in the database before it will start neutron-server (to avoid neutron breaking the database if it hasn't yet been upgraded from grizzly). Terry's changes to the neutron packages make sure that everything is correct when upgrading from Grizzly, but in order to have a smooth experience for *new* installations we need the change requested in this bz, too.
Lars: I think they were trying to do it in the postcript_948.py in packstack itself, so after setting up a complete install, doing the upgrade. This would be pretty close to the equivalent of handling this in the puppet modules--instead just doing it as the last step of a packstack install. Ian: I'm not sure. I haven't had a lot of experience with running the upgrade command, but Jakub reported that it worked for him. Jakub, does it sound like they are doing what you expected to work? I can take a look after I wake up tomorrow as well.
Yup, I finally spotted that. The error they're getting by running that in the postscript is likely (not verified) that the database is actually getting created earlier in the process...so when "upgrade head" runs: - The database exists, but - Has no version information So everything falls over. I was just on irc with ianw, he's going to look a little deeper into the puppet modules and when I'm up in the morning I'll take a look. The open question (for me, at least) is what is actually create the database, and can we fix that.
Yup, I finally spotted that. The error they're getting by running that in the postscript is likely (not verified) that the database is actually getting created earlier in the process...so when "upgrade head" runs: - The database exists, but - Has no version information So everything falls over. I was just on irc with ianw, he's going to look a little deeper into the puppet modules and when I'm up in the morning I'll take a look. The open question (for me, at least) is what is actually creating the database, and can we fix that.
Lars: Ian: The db is created via: packstack/puppet/templates/mysql_neutron_install.pp It would probably be possible to do an Exec { } call in that template with a dependency that it run after the class {"neutron::db::mysql"}. That would be the easiest solution. Otherwise, the puppet module itself could be modified to take an option to do the Exec there (packstack//puppet/modules/neutron/manifests/db/mysql.pp). Short-term solution would be the first option, though.
Ok, so per comment #9 the db is created in [1] which is provided by [2]. Looking at [2], that just creates the mysql database but doesn't populate it with neutron-db-manage in any way. I see nowhere that explicitly creates the neutron database in packstack, so I assume that neutron itself is creating all the tables when it starts up. Possibly that is why when we run "upgrade head" in the postscript.pp, neutron has already started and created the db tables, leading to the "table networks already exists"? > It would probably be possible to do an Exec { } call in that template with a > dependency that it run after the class {"neutron::db::mysql"} I'm pretty sure that's what Dan's patch in [3] does, specifically [4]? [1] https://github.com/stackforge/packstack/blob/master/packstack/puppet/templates/mysql_neutron_install.pp [2] https://github.com/stackforge/puppet-neutron/blob/master/manifests/db/mysql.pp [3] https://review.openstack.org/#/c/50162/ [4] https://review.openstack.org/#/c/50162/6/manifests/db/mysql.pp,unified
Terry, in time mysql_neutron_install.pp is applied we don't have /usr/share/neutron/neutron-dist.conf nor /etc/neutron/neutron.conf nor /etc/neutron/plugin.ini created ... and since mysql_neutron_install.pp is applied on CONFIG_MYSQL_HOST this won't work on ditributed installations also ... will try to find some place for the Exec.
So ... I think that adding following to packstack/puppet/templates/neutron_api.pp might work: exec { 'neutron-db-manage upgrade': command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head', path => '/usr/bin', user => 'neutron', logoutput => 'on_failure', before => Service['neutron-server'], } What do you think? This way the command will be executed on correct host before neutron-server is started and we should have all conf files ready.
mmagr: That looks like a sensible solution to me. I'm assuming that at this point the neutron config files are already correctly configured (at least as far as database access is concerned).
(In reply to Martin Magr from comment #12) > So ... I think that adding following to > packstack/puppet/templates/neutron_api.pp might work: > > exec { 'neutron-db-manage upgrade': > command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf > --config-file /etc/neutron/plugin.ini upgrade head', > path => '/usr/bin', > user => 'neutron', > logoutput => 'on_failure', > before => Service['neutron-server'], > } > > What do you think? This way the command will be executed on correct host > before neutron-server is started and we should have all conf files ready. Agreed, great idea.
Looks good to me as well.
I put the call in as per comment #12. Unfortunately it fails, the error is as per below. This appears to be an issue with the sqlite backend [1]. Looking at neutron_api.pp [2] it does not seem to set 'sql_connection' for 'neutron::server', meaning it gets a default of sqlite [3]. Is this a feature or a bug? --- -bash-4.1# neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head No handlers could be found for logger "neutron.common.legacy" INFO [alembic.migration] Context impl SQLiteImpl. INFO [alembic.migration] Will assume transactional DDL. INFO [alembic.migration] Running upgrade None -> folsom INFO [alembic.migration] Running upgrade folsom -> 2c4af419145b INFO [alembic.migration] Running upgrade 2c4af419145b -> 5a875d0e5c INFO [alembic.migration] Running upgrade 5a875d0e5c -> 48b6f43f7471 INFO [alembic.migration] Running upgrade 48b6f43f7471 -> 3cb5d900c5de INFO [alembic.migration] Running upgrade 3cb5d900c5de -> 1d76643bcec4 INFO [alembic.migration] Running upgrade 1d76643bcec4 -> 2a6d0b51f4bb INFO [alembic.migration] Running upgrade 2a6d0b51f4bb -> 1b693c095aa3 INFO [alembic.migration] Running upgrade 1b693c095aa3 -> 1149d7de0cfa INFO [alembic.migration] Running upgrade 1149d7de0cfa -> 49332180ca96 INFO [alembic.migration] Running upgrade 49332180ca96 -> 38335592a0dc INFO [alembic.migration] Running upgrade 38335592a0dc -> 54c2c487e913 INFO [alembic.migration] Running upgrade 54c2c487e913 -> 45680af419f9 INFO [alembic.migration] Running upgrade 45680af419f9 -> 1c33fa3cd1a1 INFO [alembic.migration] Running upgrade 1c33fa3cd1a1 -> 363468ac592c INFO [alembic.migration] Running upgrade 363468ac592c -> 511471cc46b INFO [alembic.migration] Running upgrade 511471cc46b -> 3b54bf9e29f7 INFO [alembic.migration] Running upgrade 3b54bf9e29f7 -> 4692d074d587 INFO [alembic.migration] Running upgrade 4692d074d587 -> 1341ed32cc1e INFO [alembic.migration] Running upgrade 1341ed32cc1e -> grizzly INFO [alembic.migration] Running upgrade grizzly -> f489cf14a79c INFO [alembic.migration] Running upgrade f489cf14a79c -> 176a85fc7d79 INFO [alembic.migration] Running upgrade 176a85fc7d79 -> 32b517556ec9 INFO [alembic.migration] Running upgrade 32b517556ec9 -> 128e042a2b68 Traceback (most recent call last): File "/usr/bin/neutron-db-manage", line 10, in <module> sys.exit(main()) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 143, in main CONF.command.func(config, CONF.command.name) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 80, in do_upgrade_downgrade do_alembic_command(config, cmd, revision, sql=CONF.command.sql) File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 59, in do_alembic_command getattr(alembic_command, cmd)(config, *args, **kwargs) File "/usr/lib/python2.6/site-packages/alembic/command.py", line 124, in upgrade script.run_env() File "/usr/lib/python2.6/site-packages/alembic/script.py", line 191, in run_env util.load_python_file(self.dir, 'env.py') File "/usr/lib/python2.6/site-packages/alembic/util.py", line 186, in load_python_file module = imp.load_source(module_id, path, open(path, 'rb')) File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 105, in <module> run_migrations_online() File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 89, in run_migrations_online options=build_options()) File "<string>", line 7, in run_migrations File "/usr/lib/python2.6/site-packages/alembic/environment.py", line 494, in run_migrations self.get_context().run_migrations(**kw) File "/usr/lib/python2.6/site-packages/alembic/migration.py", line 211, in run_migrations change(**kw) File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/versions/128e042a2b68_ext_gw_mode.py", line 55, in upgrade nullable=False, default=True)) File "<string>", line 7, in add_column File "/usr/lib/python2.6/site-packages/alembic/operations.py", line 342, in add_column schema=schema File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 126, in add_column self._exec(base.AddColumn(table_name, column, schema=schema)) File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 75, in _exec conn.execute(construct, *multiparams, **params) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1449, in execute params) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1542, in _execute_ddl compiled File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1698, in _execute_context context) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context context) File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 331, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (OperationalError) Cannot add a NOT NULL column with default value NULL u'ALTER TABLE routers ADD COLUMN enable_snat BOOLEAN NOT NULL' () --- [1] https://bugs.launchpad.net/neutron/+bug/1241577 [2] https://github.com/stackforge/packstack/blob/master/packstack/puppet/templates/neutron_api.pp [3] https://github.com/stackforge/puppet-neutron/blob/master/manifests/server.pp#L104
(In reply to Ian Wienand from comment #16) > I put the call in as per comment #12. Unfortunately it fails, the error is > as per below. This appears to be an issue with the sqlite backend [1]. > > Looking at neutron_api.pp [2] it does not seem to set 'sql_connection' for > 'neutron::server', meaning it gets a default of sqlite [3]. Is this a > feature or a bug? sql_connection is set in the plugin symlinked by /etc/neutron/plugin.ini
(In reply to Jakub Libosvar from comment #17) > sql_connection is set in the plugin symlinked by /etc/neutron/plugin.ini In my test here that is /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini, but it does not have a [database] section. So I guess it falls back to the default [database] connection in neutron.conf which is sqlite I *think* what is happening here is that packstack calls 'neutron::plugins::ovs' with the sql_parameter in [1], but this has been deprecated in [2] for, as it says --- warning('sql_connection is deprecated for connection in the neutron::server class') --- So, the "sql_connection" parameter probably needs to be moved into [3]? [1] https://github.com/stackforge/packstack/blob/master/packstack/puppet/templates/neutron_ovs_plugin_local.pp [2] https://github.com/stackforge/puppet-neutron/blob/master/manifests/plugins/ovs.pp#L39 [3] https://github.com/stackforge/packstack/blob/master/packstack/puppet/templates/neutron_api.pp
(In reply to Ian Wienand from comment #18) > So, the "sql_connection" parameter probably needs to be moved into [3]? I think it depends on plugin intentionally because db name is according to used plugin. What's concerning me is that there is no [DATABASE] section in plugin.ini file. > [3] > https://github.com/stackforge/packstack/blob/master/packstack/puppet/ > templates/neutron_api.pp
So the reason why it's failing with DB error is that with last puppet-module update sql_connection filling moved to another puppet class. Can "neutron-db-manage upgreade head" run multiple times? I'm asking bacause now I'm failing on: Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: No handlers could be found for logger "neutron.common.legacy" Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: INFO [alembic.migration] Context impl SQLiteImpl. Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: INFO [alembic.migration] Will assume transactional DDL. Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: INFO [alembic.migration] Running upgrade None -> folsom Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: Traceback (most recent call last): Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/bin/neutron-db-manage", line 10, in <module> Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: sys.exit(main()) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 143, in main Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: CONF.command.func(config, CONF.command.name) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 80, in do_upgrade_downgrade Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: do_alembic_command(config, cmd, revision, sql=CONF.command.sql) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/cli.py", line 59, in do_alembic_command Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: getattr(alembic_command, cmd)(config, *args, **kwargs) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/command.py", line 124, in upgrade Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: script.run_env() Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/script.py", line 191, in run_env Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: util.load_python_file(self.dir, 'env.py') Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/util.py", line 186, in load_python_file Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: module = imp.load_source(module_id, path, open(path, 'rb')) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 105, in <module> Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: run_migrations_online() Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/env.py", line 89, in run_migrations_online Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: options=build_options()) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "<string>", line 7, in run_migrations Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/environment.py", line 494, in run_migrations Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: self.get_context().run_migrations(**kw) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/migration.py", line 211, in run_migrations Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: change(**kw) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/versions/folsom_initial.py", line 74, in upgrade Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: upgrade_base() Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/neutron/db/migration/alembic_migrations/versions/folsom_initial.py", line 111, in upgrade_base Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: sa.PrimaryKeyConstraint('id') Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "<string>", line 7, in create_table Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/operations.py", line 570, in create_table Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: self._table(name, *columns, **kw) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 148, in create_table Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: self._exec(schema.CreateTable(table)) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib/python2.6/site-packages/alembic/ddl/impl.py", line 75, in _exec Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: conn.execute(construct, *multiparams, **params) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1449, in execute Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: params) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1542, in _execute_ddl Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: compiled Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1698, in _execute_context Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: context) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: context) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 331, in do_execute Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: cursor.execute(statement, parameters) Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: sqlalchemy.exc.OperationalError: (OperationalError) table networks already exists u'\nCREATE TABLE networks (\n\ttenant_id VARCHAR(255), \n\tid VARCHAR(36) NOT NULL, \n\tname VARCHAR(255), \n\tstatus VARCHAR(16), \n\tadmin_state_up BOOLEAN, \n\tshared BOOLEAN, \n\tPRIMARY KEY (id), \n\tCHECK (admin_state_up IN (0, 1)), \n\tCHECK (shared IN (0, 1))\n)\n\n' () Error: neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head returned 1 instead of one of [0] Error: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: change from notrun to 0 failed: neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head returned 1 instead of one of [0]
It will always provide migration from "stamp" to "what you provide after upgrade argument". So if the db is empty (None) and "upgrade head" is called and succeeds then db is stamped with head, which is "havana". Second call of upgrade head will try to migrate from havana to havana, therefore it will do nothing and succeed. So yes, it can be called multiple times but first migration must be successful. From the traceback it seems it's failing at the very beginning (folsom_initial). Can you make sure that DB is empty when the upgrade is called? Also Notice: /Stage[main]//Exec[neutron-db-manage upgrade]/returns: INFO [alembic.migration] Context impl SQLiteImpl. still doesn't seem like MySQL, should be MySQLImpl.
60884 has just been merged.
Running with openstack-packstack-2013.2.1-0.18.dev934.el6ost.noarch [root@localhost ~]# neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini current No handlers could be found for logger "neutron.common.legacy" INFO [alembic.migration] Context impl MySQLImpl. INFO [alembic.migration] Will assume non-transactional DDL. Current revision for mysql://neutron:XXXXX.122.244/ovs_neutron: 27ef74513d33 -> havana (head), havana So, now there's a revision stamp, but also running simply 'neutron-db-manage' results in a stacktrace (with a user-hostile error message). This is a separate issue.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHEA-2013-1859.html