migration 20 fails when member_role_id already in metadata

Bug #1206257 reported by Mark Washenberger on 2013-07-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
High
Mark Washenberger

Bug Description

If member_role_id is already in the a user-project's metadata, the old metadata never gets deserialized.

    for metadata in session.query(old_metadata_table):
        if config.CONF.member_role_id not in metadata.data:
            data = json.loads(metadata.data)
            data['roles'].append(config.CONF.member_role_id)
        else:
            data = metadata.data

This means, when data is later accessed as a dictionary (when its actually just a string) you get the following exception.

'Traceback (most recent call last):\\\\\\\
File "/usr/bin/keystone-manage", line 28, in <module>\\\\\\\
cli.main(argv=sys.argv, config_files=config_files)\\\\\\\
File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 197, in main\\\\\\\
CONF.command.cmd_class.main()\\\\\\\
File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 65, in main\\\\\\\
driver.db_sync(CONF.command.version)\\\\\\\
File "/usr/lib/python2.7/dist-packages/keystone/identity/backends/sql.py", line 156, in db_sync\\\\\\\
migration.db_sync(version=version)\\\\\\\
File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 52, in db_sync\\\\\\\
return versioning_api.upgrade(CONF.sql.connection, repo_path, version)\\\\\\\
File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 186, in upgrade\\\\\\\
return _migrate(url, repository, version, upgrade=True, err=err, **opts)\\\\\\\
File "<string>", line 2, in _migrate\\\\\\\
File "/usr/lib/python2.7/dist-packages/migrate/versioning/util/_init_.py", line 159, in with_engine\\\\\\\
return f(*a, **kw)\\\\\\\
File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 366, in _migrate\\\\\\\
schema.runchange(ver, change, changeset.step)\\\\\\\
File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 91, in runchange\\\\\\\
change.run(self.engine, step)\\\\\\\
File "/usr/lib/python2.7/dist-packages/migrate/versioning/script/py.py", line 145, in run\\\\\\\
script_func(engine)\\\\\\\
File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migrate_repo/versions/021_migrate_metadata_table_roles.py", line 41, in upgrade\\\\\\\
old_roles = data\\\\\\\\\\\\\\\'roles\\\\\\\\\\\\\\\'\\\\\\\
TypeError: string indices must be integers, not str\\\\\\\
\\\\\\\'\\\'\

Mark Washenberger (markwash) wrote :

I suspect that https://bugs.launchpad.net/keystone/+bug/1197367 is related to this bug. In the other bug, it seems like the individual's migration failed for some reason, and subsequent attempts give him the error he reports. Maybe this issue above was the original cause of failure?

Fix proposed to branch: master
Review: https://review.openstack.org/39147

Changed in keystone:
assignee: nobody → Mark Washenberger (markwash)
status: New → In Progress
Dolph Mathews (dolph) on 2013-08-02
Changed in keystone:
importance: Undecided → High

Reviewed: https://review.openstack.org/39147
Committed: http://github.com/openstack/keystone/commit/cf27bbe356013c11d2a8f2e12da3e5aa60e2fcf9
Submitter: Jenkins
Branch: master

commit cf27bbe356013c11d2a8f2e12da3e5aa60e2fcf9
Author: Mark J. Washenberger <email address hidden>
Date: Mon Jul 29 11:12:03 2013 -0700

    Handle json data when migrating role metadata.

    Fixes bug 1206257

    Change-Id: Ia522e023a2d66ec25bc909db12d358f7c0ee6952

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2013-09-05
Changed in keystone:
milestone: none → havana-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2013-10-17
Changed in keystone:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers