Bug 912143 - openstack-db --init fails for glance when following GSG instructions
Summary: openstack-db --init fails for glance when following GSG instructions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-glance
Version: 2.0 (Folsom)
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: snapshot4
: 2.1
Assignee: Eoghan Glynn
QA Contact: Attila Fazekas
URL:
Whiteboard:
: 916619 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-02-17 20:53 UTC by Justin Clift
Modified: 2016-04-27 05:45 UTC (History)
10 users (show)

Fixed In Version: openstack-glance-2012.2.3-2.el6ost
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-03-21 19:05:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed fix for review. (2.31 KB, patch)
2013-02-20 16:31 UTC, Eoghan Glynn
no flags Details | Diff
Follow up dist-git patch to remove now obsolete editing of glance-cache-* utils to pick up dist config. (1.99 KB, patch)
2013-02-22 15:09 UTC, Eoghan Glynn
pbrady: review+
Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0672 0 normal SHIPPED_LIVE Red Hat OpenStack 2.0 (Folsom) Preview bug fix and enhancement update 2013-03-21 23:02:46 UTC

Description Justin Clift 2013-02-17 20:53:31 UTC
Description of problem:

  When initialising RHOS Folsom preview glance using the RHOS Folsom Getting Started Guide instructions (chapter 9), it fails with:

    ERROR 1146 (42S02) at line 1: Table 'glance.migrate_version' doesn't exist
    Final sanity check failed.


Version-Release number of selected component (if applicable):

  openstack-glance-2012.2.3-1.el6ost.noarch
  openstack-keystone-2012.2.3-1.el6ost.noarch
  openstack-utils-2012.2-6.1.el6ost.noarch
  python-sqlalchemy0.7-0.7.8-1.el6ost.x86_64

How reproducible:

  Every time.  Even after dropping the glance db and trying again (more than once), same error occurs.


Steps to Reproduce:
1. Install keystone and setup admin + username users, as per Chapter 8 of GSG.
2. Install openstack-glance using yum install
3. Attempt to initialise glance using "sudo openstack-db --init --service glance". Fails here.
  
Actual results:

  $ sudo openstack-db --init --service glance
  Please enter the password for the 'root' MySQL user: 
  Verified connectivity to MySQL.
  Creating 'glance' database.
  Asking openstack-glance to sync the database.
  Traceback (most recent call last):
    File "/usr/bin/glance-manage", line 133, in <module>
      main()
    File "/usr/bin/glance-manage", line 129, in main
      dispatch_cmd(args)
    File "/usr/bin/glance-manage", line 99, in dispatch_cmd
      cmd_func(args)
    File "/usr/bin/glance-manage", line 86, in do_db_sync
      glance.db.sqlalchemy.migration.db_sync(version, current_version)
    File "/usr/lib/python2.6/site-packages/glance/db/sqlalchemy/migration.py", line 120, in db_sync
      _version_control(current_version or 0)
    File "/usr/lib/python2.6/site-packages/glance/db/sqlalchemy/migration.py", line 109, in _version_control
      return versioning_api.version_control(sql_connection, repo_path, version)
    File "<string>", line 2, in version_control
    File "/usr/lib/python2.6/site-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
      return f(*a, **kw)
    File "/usr/lib/python2.6/site-packages/migrate/versioning/api.py", line 248, in version_control
      ControlledSchema.create(engine, repository, version)
    File "/usr/lib/python2.6/site-packages/migrate/versioning/schema.py", line 137, in create
      table = cls._create_table_version(engine, repository, version)
    File "/usr/lib/python2.6/site-packages/migrate/versioning/schema.py", line 178, in _create_table_version
      if not table.exists():
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/schema.py", line 579, in exists
      self.name, schema=self.schema)
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2424, in run_callable
      conn = self.contextual_connect()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py", line 2490, in contextual_connect
      self.pool.connect(), 
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 224, in connect
      return _ConnectionFairy(self).checkout()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 387, in __init__
      rec = self._connection_record = pool._do_get()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 802, in _do_get
      return self._create_connection()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 188, in _create_connection
      return _ConnectionRecord(self)
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 270, in __init__
      self.connection = self.__connect()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 330, in __connect
      connection = self.__pool._creator()
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 80, in connect
      return dialect.connect(*cargs, **cparams)
    File "/usr/lib64/python2.6/site-packages/SQLAlchemy-0.7.8-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 281, in connect
      return self.dbapi.connect(*cargs, **cparams)
  sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None
  ERROR 1146 (42S02) at line 1: Table 'glance.migrate_version' doesn't exist
  Final sanity check failed.
  Please file a bug report on bugzilla.redhat.com against the openstack-glance package.

Expected results:

  Successful creation of glance db.


Additional info:

This is from using RHOS on RHEL 6.4 RC 1 (as per official recommendation).

Comment 3 Justin Clift 2013-02-18 16:11:02 UTC
As a thought, I'm wondering if BZ# 879387 is in some way related to this, even though MySQL was used here:

  https://bugzilla.redhat.com/show_bug.cgi?id=879387

Comment 4 John Bresnahan 2013-02-19 03:39:21 UTC
It appears that the value for sql_connection in both of the files:

/etc/glance/glance-api.conf
/etc/glance/glance-registry.conf 

is never set.  This leaves a default of sqlite:///glance.sqlite.  This ends up with a file that is not readable by the glance user.

Comment 5 John Bresnahan 2013-02-19 08:18:04 UTC
It seems that the problem here is that the RPM is manipulating the files:

/usr/share/glance/glance-registry-dist.conf 
/usr/share/glance/glance-api-dist.conf

And not 

/etc/glance/glance-registry.conf
/etc/glance/glance-api.conf

The search path is picking up the files in /etc and thus the default location for the database, which is incorrect.

There is some discussion in this area here:

https://bugzilla.redhat.com/show_bug.cgi?id=887811#c14.  Hopefully @eglynn or @pbrady can apply those conclusions here.

Comment 6 Eoghan Glynn 2013-02-20 16:29:26 UTC
The basic problem here is that the fix for https://bugzilla.redhat.com/887811 patches the glance-cache-* utilities to pick up the glance distribution config by default, but neglects to do the same for the glance-manage utility.

Comment 7 Eoghan Glynn 2013-02-20 16:31:02 UTC
Created attachment 700130 [details]
Proposed fix for review.

Comment 9 John Bresnahan 2013-02-20 19:01:56 UTC
I do not have the familiarity with RPMs that others here do, so perhaps this comment is off base. However it seems strange to me to modify source code with sed in the installation.  I would be more comfortable with a patch.

Comment 10 John Bresnahan 2013-02-20 19:03:01 UTC
Comment on attachment 700130 [details]
Proposed fix for review.

Would it be better to use a patch instead of a sed command in the installation?

Comment 11 Eoghan Glynn 2013-02-21 17:04:17 UTC
Pádraig - thanks for the feedback, I'm now tending to agree with you that the parameterization of /usr/share is not worth losing the generality of the alternate solution.

A slightly different approach is required for glance, as the config files are named for the service (glance-api etc.) as opposed to the project (glance) as in the nova case.

Patches to follow ...

Comment 13 Eoghan Glynn 2013-02-22 15:09:57 UTC
Created attachment 701215 [details]
Follow up dist-git patch to remove now obsolete editing of glance-cache-* utils to pick up dist config.

Comment 14 Pádraig Brady 2013-02-22 15:13:44 UTC
Comment on attachment 701215 [details]
Follow up dist-git patch to remove now obsolete editing of glance-cache-* utils to pick up dist config.

+1 assuming of course the patches are updated later to include the necessary support

Comment 15 jliberma@redhat.com 2013-02-25 20:32:41 UTC
What is the workaround for this issue?

Setting sql_connection in:
/etc/glance/glance-registry.conf
/etc/glance/glance-api.conf

Comment 16 Pádraig Brady 2013-02-25 22:19:28 UTC
Only glance-registry.conf needs to be updated as far as I know.
Also I'd set the rpc_backend setting as per the dist conf too.

Comment 17 Stephen Gordon 2013-02-26 03:22:19 UTC
I discussed with Russell Bryant on IRC and the outcome of our discussion and some testing on my part was:

- The rpc_backend value does not apply to glance, the value notifier_strategy however does.
- We do not set notifier_strategy at this time in our dist configs, nor do they appear to be set in the ones you get via "manual" installation.
- The sql_connection is as per comment # 15 set in both files in our dist configs.

As such I've added this note to the errata (based on the previous one for cinder and nova):

The following known issue has been identified with these packages, impacting deployments performed without the use of the packstack utility:

* Currently Glance and the associated utilities only retrieve configuration values from /etc/glance/glance-registry.conf and /etc/glance/glance-api.conf. As a result they ignore distribution specific configuration values defined in other files.

To work around this issue you must ensure that the sql_connection configuration key in both /etc/glance/glance-registry.conf and /etc/glance/glance-api.conf is uncommented and contains the correct details for the MySQL server in your environment. This change must be made on all systems you wish to host Glance on and run the associated utilities from.

Comment 18 Eoghan Glynn 2013-02-27 09:25:15 UTC
How to test
-----------

Install openstack-glance:

  $ sudo yum install openstack-glance

Ensure mysql is installed and running:

  $ sudo service mysqld status
 
Initialize glance DB:

  $ sudo openstack-db --init --service glance

Ensure the migration has succeeded:

  $ echo "select * from migrate_version;" | mysql -t -u glance -pglance glance
+-------------------+--------------------------------------------------------------------+---------+
| repository_id     | repository_path                                                    | version |
+-------------------+--------------------------------------------------------------------+---------+
| Glance Migrations | /usr/lib/python2.6/site-packages/glance/db/sqlalchemy/migrate_repo |      15 |
+-------------------+--------------------------------------------------------------------+---------+

Comment 19 Eoghan Glynn 2013-02-27 09:28:14 UTC
One additional step for the "How to test" section, if there's preexisting glance DB on the current host.

Before initializing the glance DB, drop any pre-existing remnants:

  $ sudo openstack-db --drop --service glance

Comment 21 Eoghan Glynn 2013-03-01 11:33:23 UTC
*** Bug 916619 has been marked as a duplicate of this bug. ***

Comment 23 errata-xmlrpc 2013-03-21 19:05:50 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/RHBA-2013-0672.html


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