sql migration helpers incorrectly inspect for FKs

Bug #1398470 reported by Henry Nash
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Henry Nash

Bug Description

Our sql migration tests utilise the migration_helpers to execute such things as adding and removing constraints. In the case of ForeignKeys, the remove helper uses a method like this:

def get_constraints_names(table, column_name):
    fkeys = [fk.name for fk in table.constraints
             if (column_name in fk.columns and
                  isinstance(fk, sqlalchemy.ForeignKeyConstraint)]
    return keys

The test for column name in fk_colums is unsafe as written, since there are more than just ForeignKeyContraints in table.constraints (and they don't all have a columns attribute). The check should first ensure the item we are looking at IS a ForeignKey, and then check the column.

Henry Nash (henry-nash)
Changed in keystone:
assignee: nobody → Henry Nash (henry-nash)
importance: Undecided → High
milestone: none → kilo-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

Changed in keystone:
status: New → In Progress
Changed in keystone:
importance: High → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

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

commit e927ddfd7253f26f0505a247416a762f20f4102b
Author: Henry Nash <email address hidden>
Date: Tue Dec 2 18:07:55 2014 +0000

    Fix the way migration helpers check FK names.

    The current check for FK names is unsfafe due to the order
    of checks - this patch resolves this.

    Since FKs are not supported as part of standard database used for
    unit tests (sqlite), there is no unit test for this change. This
    change has been tested (and required) with MySQL and Postgres in the
    following on patch (https://review.openstack.org/#/c/130954/)

    Change-Id: I77ab359b4018e49de0afbef1f6e137d9080bdc26
    Closes-bug: 1398470

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: kilo-1 → 2015.1.0
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.