Bug 969702 - No attribute '_index_identifier' in python-migrate during glance-manage db_sync against postgresql
Summary: No attribute '_index_identifier' in python-migrate during glance-manage db_sy...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-migrate
Version: 19
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Pádraig Brady
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-01 23:10 UTC by netalien
Modified: 2014-01-08 07:55 UTC (History)
5 users (show)

Fixed In Version: python-migrate-0.7.2-9.fc19
Clone Of:
Environment:
Last Closed: 2013-10-12 04:25:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
possibly more general fix (1.55 KB, patch)
2013-09-23 04:05 UTC, Pádraig Brady
no flags Details | Diff
possibly more general fix (1.55 KB, patch)
2013-09-23 12:47 UTC, Pádraig Brady
no flags Details | Diff

Description netalien 2013-06-01 23:10:56 UTC
Description of problem:

Running 'glance-manage db_sync' against postgresql-9.2 returns an error because python-migrate tries to use a non existing property '_index_identifier' of PGSchemaChanger object

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

python-migrate-0.7.2-7.fc19.noarch

How reproducible:

Always

Steps to Reproduce:
1. Install openstack-glance python-glanceclient python-glance sqlalchemy and postgresql
2. Create user with password and database in postgresql for glance and grant access in pg_hba.conf for such user
3. Configure verbose=true, debug=true and sql_connection in glance-api.conf and glance-registry.conf as sql_connection=postgresql://dbuser:dbpassword@host/glancedb
4. Start services openstack-glance-api and openstack-glance-registry
5. Execute glance-manage db_sync

Actual results:

# glance-manage db_sync
2013-06-01 17:41:28.794 5649 INFO glance.db.sqlalchemy.migration [-] Upgrading database to version latest
2013-06-01 17:41:28.855 5649 INFO glance.db.sqlalchemy.migrate_repo.schema [-] creating table images
2013-06-01 17:41:29.058 5649 INFO glance.db.sqlalchemy.migrate_repo.schema [-] creating table image_properties
2013-06-01 17:41:29.568 5649 CRITICAL glance [-] 'PGSchemaChanger' object has no attribute '_index_identifier'
2013-06-01 17:41:29.568 5649 TRACE glance Traceback (most recent call last):
2013-06-01 17:41:29.568 5649 TRACE glance   File "/bin/glance-manage", line 134, in <module>
2013-06-01 17:41:29.568 5649 TRACE glance     main()
2013-06-01 17:41:29.568 5649 TRACE glance   File "/bin/glance-manage", line 128, in main
2013-06-01 17:41:29.568 5649 TRACE glance     CONF.command.func()
2013-06-01 17:41:29.568 5649 TRACE glance   File "/bin/glance-manage", line 80, in do_db_sync
2013-06-01 17:41:29.568 5649 TRACE glance     CONF.command.current_version)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/glance/db/sqlalchemy/migration.py", line 127, in db_sync
2013-06-01 17:41:29.568 5649 TRACE glance     upgrade(version=version)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/glance/db/sqlalchemy/migration.py", line 66, in upgrade
2013-06-01 17:41:29.568 5649 TRACE glance     return versioning_api.upgrade(sql_connection, repo_path, version)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/versioning/api.py", line 186, in upgrade
2013-06-01 17:41:29.568 5649 TRACE glance     return _migrate(url, repository, version, upgrade=True, err=err, **opts)
2013-06-01 17:41:29.568 5649 TRACE glance   File "<string>", line 2, in _migrate
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/versioning/util/__init__.py", line 159, in with_engine
2013-06-01 17:41:29.568 5649 TRACE glance     return f(*a, **kw)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/versioning/api.py", line 366, in _migrate
2013-06-01 17:41:29.568 5649 TRACE glance     schema.runchange(ver, change, changeset.step)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/versioning/schema.py", line 91, in runchange
2013-06-01 17:41:29.568 5649 TRACE glance     change.run(self.engine, step)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/versioning/script/py.py", line 145, in run
2013-06-01 17:41:29.568 5649 TRACE glance     script_func(engine)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/glance/db/sqlalchemy/migrate_repo/versions/006_key_to_name.py", line 85, in upgrade
2013-06-01 17:41:29.568 5649 TRACE glance     index.rename('ix_image_properties_image_id_name')
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/changeset/schema.py", line 642, in rename
2013-06-01 17:41:29.568 5649 TRACE glance     engine._run_visitor(visitorcallable, self, connection, **kwargs)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1479, in _run_visitor
2013-06-01 17:41:29.568 5649 TRACE glance     conn._run_visitor(visitorcallable, element, **kwargs)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1122, in _run_visitor
2013-06-01 17:41:29.568 5649 TRACE glance     **kwargs).traverse_single(element)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/changeset/ansisql.py", line 53, in traverse_single
2013-06-01 17:41:29.568 5649 TRACE glance     ret = super(AlterTableVisitor, self).traverse_single(elem)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 111, in traverse_single
2013-06-01 17:41:29.568 5649 TRACE glance     return meth(obj, **kw)
2013-06-01 17:41:29.568 5649 TRACE glance   File "/usr/lib/python2.7/site-packages/migrate/changeset/ansisql.py", line 178, in visit_index
2013-06-01 17:41:29.568 5649 TRACE glance     self._index_identifier(
2013-06-01 17:41:29.568 5649 TRACE glance AttributeError: 'PGSchemaChanger' object has no attribute '_index_identifier'
2013-06-01 17:41:29.568 5649 TRACE glance

Expected results:

db_sync should run without issues and return no output on console or logs

Additional info:

I'm opening the bug against sqlalchemy and not glance since this error also happened before and was fixed in sqlalchemy 0.7.1, references:

https://bugzilla.redhat.com/show_bug.cgi?id=879387
https://bugs.launchpad.net/glance/+bug/1081172

Related software info:
postgresql-server-9.2.4-1.fc19.x86_64
python-sqlalchemy-0.8.1-1.fc19.x86_64
python-glanceclient-0.9.0-2.fc19.noarch
python-glance-2013.1-2.fc19.noarch
openstack-glance-2013.1-2.fc19.noarch

Comment 1 Pádraig Brady 2013-09-23 01:45:26 UTC
Seems this is related to sqlalchemy 0.8 version in Fedora 19
See migrate/changeset/ansisql.py patch here for possible fix:
https://github.com/lugensa/sqlalchemy-migrate/commit/0e439505a0

Comment 2 netalien 2013-09-23 03:02:09 UTC
Hello,

Thanks for taking the time to answer.

I've tested the patch you pointed out and can confirm that the new def on ansisql.py solves this bug

As of now, _current_ python-migrate package at version 0.7.2-7.fc19 lacks the _index_identifier definition


Regards

Comment 3 Pádraig Brady 2013-09-23 04:05:05 UTC
Created attachment 801477 [details]
possibly more general fix

possibly more general fix attached

Comment 4 netalien 2013-09-23 04:48:22 UTC
Hello,

Unless I'm mistaken, the proposed more general fix wouldn't work, problem being the elif is just checking if SA is 0.8 or later in which case it would call PGSchemaChanger._prepared_index_name otherwise it would call PGSchemaChanger._index_identifier, however, ANSISchemaChanger (the base class of PGSchemaChanger) doesn't have an attribute called '_index_identifier' if SA < 0.8

If the more general fix is to be used in hand with the _index_identifier declaration (commit: 0e439505a0) then it's all good and I haven't said anything :)

Regards,

Comment 5 Pádraig Brady 2013-09-23 05:17:59 UTC
I've not tested the more general change, but it seems to me that sqlalchemy < 0.8 makes _index_identifier() available, while sqlalchemy >= 0.8 just changes this to _prepared_index_name(). The code is just checking for which of these is available?

Comment 6 Pádraig Brady 2013-09-23 05:27:06 UTC
Note ANSISchemaChanger derives from SchemaGenerator, which is
sqlalchemy.sql.compiler which should have the appropriate attributes we're looking up

Comment 7 Pádraig Brady 2013-09-23 12:47:01 UTC
Created attachment 801606 [details]
possibly more general fix

Comment 8 Fedora Update System 2013-09-23 22:58:00 UTC
python-migrate-0.7.2-9.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-migrate-0.7.2-9.fc19

Comment 9 Fedora Update System 2013-09-23 22:58:43 UTC
python-migrate-0.7.2-9.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-migrate-0.7.2-9.fc20

Comment 10 Pádraig Brady 2013-09-23 23:01:03 UTC
I'd really appreciate a test with the new package, which contains the more general fix in comment 7. thanks!

Comment 11 netalien 2013-09-24 01:38:53 UTC
Hello again, sorry for the delay.

I've tested the proposed patch at comment 7 and can confirm it works :)

Feel free to mark the bug as closed/fixed.

Best regards.

Comment 12 Pádraig Brady 2013-09-24 09:08:38 UTC
_much_ apppreciated!

If you want to click through the update link above you can add a +1
to expediate this update being pushed to stable.
This bug will be auto closed when that happens.

Comment 13 Fedora Update System 2013-09-24 22:50:55 UTC
Package python-migrate-0.7.2-9.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-migrate-0.7.2-9.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-17509/python-migrate-0.7.2-9.fc20
then log in and leave karma (feedback).

Comment 14 Fedora Update System 2013-10-12 04:25:00 UTC
python-migrate-0.7.2-9.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2014-01-08 07:55:19 UTC
python-migrate-0.7.2-9.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


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