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
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
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
Created attachment 801477 [details] possibly more general fix possibly more general fix attached
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,
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?
Note ANSISchemaChanger derives from SchemaGenerator, which is sqlalchemy.sql.compiler which should have the appropriate attributes we're looking up
Created attachment 801606 [details] possibly more general fix
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
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
I'd really appreciate a test with the new package, which contains the more general fix in comment 7. thanks!
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.
_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.
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).
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.
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.