Bug 1037675 - Packstack doesn't stamp neutron database
Summary: Packstack doesn't stamp neutron database
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-packstack
Version: 4.0
Hardware: Unspecified
OS: Unspecified
high
urgent
Target Milestone: rc
: 4.0
Assignee: Martin Magr
QA Contact: Lon Hohberger
URL:
Whiteboard:
Depends On:
Blocks: 1031801 1037681
TreeView+ depends on / blocked
 
Reported: 2013-12-03 15:18 UTC by Jakub Libosvar
Modified: 2016-04-26 13:47 UTC (History)
13 users (show)

Fixed In Version: openstack-packstack-2013.2.1-0.15.dev924.el6ost
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1037681 (view as bug list)
Environment:
Last Closed: 2013-12-20 00:40:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
OpenStack gerrit 60403 0 None None None Never
OpenStack gerrit 60884 0 None None None Never
Red Hat Bugzilla 1043282 0 high CLOSED openstack-foreman-installer: Failed to start neutron-server during Neutron-controller deployment (Empty version in neutr... 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHEA-2013:1859 0 normal SHIPPED_LIVE Red Hat Enterprise Linux OpenStack Platform Enhancement Advisory 2013-12-21 00:01:48 UTC

Internal Links: 1043282

Description Jakub Libosvar 2013-12-03 15:18:22 UTC
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.

Comment 1 Alvaro Lopez Ortega 2013-12-03 17:16:26 UTC
Terry, could you please give us a hand here?

Comment 2 Terry Wilson 2013-12-03 17:49:19 UTC
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.

Comment 3 Ian Wienand 2013-12-05 01:15:59 UTC
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/

Comment 4 Ian Wienand 2013-12-06 01:23:57 UTC
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?

Comment 5 Lars Kellogg-Stedman 2013-12-06 03:52:44 UTC
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.

Comment 6 Terry Wilson 2013-12-06 04:12:23 UTC
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.

Comment 7 Lars Kellogg-Stedman 2013-12-06 04:21:26 UTC
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.

Comment 8 Lars Kellogg-Stedman 2013-12-06 04:21:48 UTC
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.

Comment 9 Terry Wilson 2013-12-06 04:55:47 UTC
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.

Comment 10 Ian Wienand 2013-12-06 07:12:54 UTC
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

Comment 11 Martin Magr 2013-12-06 14:09:17 UTC
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.

Comment 12 Martin Magr 2013-12-06 14:24:17 UTC
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.

Comment 13 Lars Kellogg-Stedman 2013-12-06 14:39:28 UTC
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).

Comment 14 Jakub Libosvar 2013-12-06 14:58:06 UTC
(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.

Comment 15 Terry Wilson 2013-12-06 17:19:38 UTC
Looks good to me as well.

Comment 16 Ian Wienand 2013-12-09 00:30:04 UTC
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

Comment 17 Jakub Libosvar 2013-12-09 09:18:10 UTC
(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

Comment 18 Ian Wienand 2013-12-09 09:53:30 UTC
(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

Comment 19 Jakub Libosvar 2013-12-09 10:05:12 UTC
(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

Comment 22 Martin Magr 2013-12-09 17:28:36 UTC
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]

Comment 24 Jakub Libosvar 2013-12-09 21:32:23 UTC
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.

Comment 25 Alvaro Lopez Ortega 2013-12-09 22:16:21 UTC
60884 has just been merged.

Comment 27 Lon Hohberger 2013-12-11 21:58:18 UTC
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.

Comment 30 errata-xmlrpc 2013-12-20 00:40:46 UTC
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


Note You need to log in before you can comment on or make changes to this bug.