db_sync throws CRITICAL KeyError: <VerNum(1)>

Bug #1314340 reported by Justin Shepherd
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Morgan Fainberg

Bug Description

On Ubuntu14.04

# cd /opt

# git clone https://github.com/openstack/keystone

# cd keystone

# virtualenv .venv

# tools/with_venv.sh pip install -r requirements.txt
Successfully installed pbr WebOb eventlet greenlet netaddr PasteDeploy Paste Routes six SQLAlchemy sqlalchemy-migrate passlib lxml iso8601 python-keystoneclient oslo.config oslo.messaging Babel oauthlib dogpile.cache jsonschema pycadf posix-ipc repoze.lru decorator Tempita PrettyTable requests stevedore PyYAML kombu pytz dogpile.core amqp anyjson

# tools/with_venv.sh bin/keystone-manage db_version
0

# tools/with_venv.sh bin/keystone-manage db_sync
2014-04-29 18:24:15.251 30096 CRITICAL keystone [-] KeyError: <VerNum(1)>

Revision history for this message
Justin Shepherd (jshepher) wrote :

# git show
commit 7a041d726339ceaa5cc9dd630d7de25fdf67f2ab
Merge: e170988 7e4aab3
Author: Jenkins <email address hidden>
Date: Tue Apr 29 16:46:20 2014 +0000

    Merge "Ignore broken endpoints in get_v3_catalog"

Revision history for this message
Justin Shepherd (jshepher) wrote :

# sqlite3 keystone.db
SQLite version 3.8.2 2013-12-06 14:53:30
sqlite> .schema
CREATE TABLE migrate_version (
 repository_id VARCHAR(250) NOT NULL,
 repository_path TEXT,
 version INTEGER,
 PRIMARY KEY (repository_id)
);
sqlite> select * from migrate_version;
keystone|/opt/keystone/keystone/common/sql/migrate_repo|0

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

I think this is because db_version was called before db_sync. db_version command doesn't set the base DB_INIT_VERSION value. This should be a relatively quick fix to get in.

Changed in keystone:
status: New → Triaged
description: updated
Changed in keystone:
importance: Undecided → Medium
assignee: nobody → Morgan Fainberg (mdrnstm)
milestone: none → juno-1
Revision history for this message
Justin Shepherd (jshepher) wrote :

Morgan.. i re-ran with out db_version before db_sync and it does sync to version 50.

I also checked stable/icehouse and version/sync/version works there.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

The issue is at https://github.com/openstack/keystone/blob/master/keystone/common/sql/migration_helpers.py#L165 Changing the 0 to reference DB_INIT_VERSION should resolve it.

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to keystone (master)

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

Changed in keystone:
status: Triaged → In Progress
Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

@Justin Shepherd,

Thanks for reporting this. This was an artifact of the SQL migration collapse we did. Icehouse didn't see this change so I expected to only see this issue on Master. The fix i just posted up for review should solve the issue of running db_version prior to db_sync.

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/91123
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=bee989df071c3d586df5c33329aa8bfdb0794f17
Submitter: Jenkins
Branch: master

commit bee989df071c3d586df5c33329aa8bfdb0794f17
Author: Morgan Fainberg <email address hidden>
Date: Tue Apr 29 11:41:44 2014 -0700

    Set proper DB_INIT_VERSION on db_version command

    When db_version argument to keystone-manage is used before db_sync
    the versioning API incorrectly versioned the DB to 0. The code now
    properly references the DB_INIT_VERSION allowing for db_version
    to be run on an unversioned database prior to sync.

    Change-Id: Idca5c8a3f4822ade8a5566181960085862ec2429
    Closes-Bug: 1314340

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.