Migration scripts and db models are not in sync

Bug #1486936 reported by Jakub Libosvar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Jakub Libosvar

Bug Description

Alembic used to not compare foreign keys correctly that caused migration scripts and db models are out of sync. With new alembic version that fixed the bug [1] we are gonna fail in Neutron:

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "neutron/tests/functional/db/test_migrations.py", line 166, in test_models_sync
        self.fail("Models and migration scripts aren't in sync:\n%s" % msg)
      File "/opt/stack/neutron/.tox/functional/lib/python2.7/site-packages/unittest2/case.py", line 690, in fail
        raise self.failureException(msg)
    AssertionError: Models and migration scripts aren't in sync:
    [ ( 'remove_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a80e9a28>, None, name=u'csnat_l3_agent_bindings_ibfk_3', ondelete=u'CASCADE', table=Table('csnat_l3_agent_bindings', MetaData(bind=None), Column('router_id', VARCHAR(length=36), ForeignKey(u'routers.id'), ForeignKey(u'routers.id'), table=<csnat_l3_agent_bindings>, primary_key=True, nullable=False), Column('l3_agent_id', VARCHAR(length=36), ForeignKey(u'agents.id'), ForeignKey(u'agents.id'), table=<csnat_l3_agent_bindings>, primary_key=True, nullable=False), Column('host_id', VARCHAR(length=255), table=<csnat_l3_agent_bindings>), Column('csnat_gw_port_id', VARCHAR(length=36), ForeignKey(u'ports.id'), ForeignKey(u'ports.id'), table=<csnat_l3_agent_bindings>), schema=None))),
      ( 'add_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a9235518>, None, table=Table('csnat_l3_agent_bindings', MetaData(bind=None), Column('router_id', String(length=36), ForeignKey('routers.id'), table=<csnat_l3_agent_bindings>, primary_key=True, nullable=False), Column('l3_agent_id', String(length=36), ForeignKey('agents.id'), table=<csnat_l3_agent_bindings>, primary_key=True, nullable=False), Column('host_id', String(length=255), table=<csnat_l3_agent_bindings>), Column('csnat_gw_port_id', String(length=36), ForeignKey('ports.id'), table=<csnat_l3_agent_bindings>), schema=None))),
      ( 'remove_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a80fe0e0>, None, name=u'flavorserviceprofilebindings_ibfk_1', table=Table('flavorserviceprofilebindings', MetaData(bind=None), Column('service_profile_id', VARCHAR(length=36), ForeignKey(u'serviceprofiles.id'), ForeignKey(u'serviceprofiles.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), Column('flavor_id', VARCHAR(length=36), ForeignKey(u'flavors.id'), ForeignKey(u'flavors.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), schema=None))),
      ( 'remove_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a80fe290>, None, name=u'flavorserviceprofilebindings_ibfk_2', table=Table('flavorserviceprofilebindings', MetaData(bind=None), Column('service_profile_id', VARCHAR(length=36), ForeignKey(u'serviceprofiles.id'), ForeignKey(u'serviceprofiles.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), Column('flavor_id', VARCHAR(length=36), ForeignKey(u'flavors.id'), ForeignKey(u'flavors.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), schema=None))),
      ( 'add_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a9e6bfc8>, None, ondelete='CASCADE', table=Table('flavorserviceprofilebindings', MetaData(bind=None), Column('flavor_id', String(length=36), ForeignKey('flavors.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), Column('service_profile_id', String(length=36), ForeignKey('serviceprofiles.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), schema=None))),
      ( 'add_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a9e6be60>, None, ondelete='CASCADE', table=Table('flavorserviceprofilebindings', MetaData(bind=None), Column('flavor_id', String(length=36), ForeignKey('flavors.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), Column('service_profile_id', String(length=36), ForeignKey('serviceprofiles.id'), table=<flavorserviceprofilebindings>, primary_key=True, nullable=False), schema=None))),
      ( 'remove_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a80673f8>, None, name=u'qos_bandwidth_limit_rules_ibfk_1', ondelete=u'CASCADE', table=Table('qos_bandwidth_limit_rules', MetaData(bind=None), Column('id', VARCHAR(length=36), table=<qos_bandwidth_limit_rules>, primary_key=True, nullable=False), Column('qos_policy_id', VARCHAR(length=36), ForeignKey(u'qos_policies.id'), ForeignKey(u'qos_policies.id'), table=<qos_bandwidth_limit_rules>, nullable=False), Column('max_kbps', INTEGER(display_width=11), table=<qos_bandwidth_limit_rules>), Column('max_burst_kbps', INTEGER(display_width=11), table=<qos_bandwidth_limit_rules>), schema=None))),
      ( 'add_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42aa5cb488>, None, table=Table('qos_bandwidth_limit_rules', MetaData(bind=None), Column('id', String(length=36), table=<qos_bandwidth_limit_rules>, primary_key=True, nullable=False, default=ColumnDefault(<function <lambda> at 0x7f42aa72b1b8>)), Column('qos_policy_id', String(length=36), ForeignKey('qos_policies.id'), table=<qos_bandwidth_limit_rules>, nullable=False), Column('max_kbps', Integer(), table=<qos_bandwidth_limit_rules>), Column('max_burst_kbps', Integer(), table=<qos_bandwidth_limit_rules>), schema=None))),
      ( 'remove_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42a8095638>, None, name=u'subnetpoolprefixes_ibfk_1', ondelete=u'CASCADE', table=Table('subnetpoolprefixes', MetaData(bind=None), Column('cidr', VARCHAR(length=64), table=<subnetpoolprefixes>, primary_key=True, nullable=False), Column('subnetpool_id', VARCHAR(length=36), ForeignKey(u'subnetpools.id'), ForeignKey(u'subnetpools.id'), table=<subnetpoolprefixes>, primary_key=True, nullable=False), schema=None))),
      ( 'add_fk',
        ForeignKeyConstraint(<sqlalchemy.sql.base.ColumnCollection object at 0x7f42aa608ea8>, None, table=Table('subnetpoolprefixes', MetaData(bind=None), Column('cidr', String(length=64), table=<subnetpoolprefixes>, primary_key=True, nullable=False), Column('subnetpool_id', String(length=36), ForeignKey('subnetpools.id'), table=<subnetpoolprefixes>, primary_key=True, nullable=False), schema=None)))]

[1] https://bitbucket.org/zzzeek/alembic/issues/317

Changed in neutron:
assignee: nobody → Jakub Libosvar (libosvar)
Henry Gessau (gessau)
Changed in neutron:
status: New → Confirmed
Changed in neutron:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/215129
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=fad17a2d8449f8a364f40896ee0efe8248dbffd3
Submitter: Jenkins
Branch: master

commit fad17a2d8449f8a364f40896ee0efe8248dbffd3
Author: Jakub Libosvar <email address hidden>
Date: Thu Aug 20 12:33:59 2015 +0000

    Sync FK constraints in db models with migration scripts

    We do have a functional test that compares Neutron's db models with
    migration scripts. The comparison is based on alembic library that had a
    bug which is gonna be solved in the next release [1]. Once we start
    using newer alembic, functional test mentioned above will start failing
    due to models and scripts are not in sync.

    This patch adds needed constraints discovered by running functional test
    locally with dev version of alembic.

    Note: There is already a patch [2] that fixes QoS.

    [1] https://bitbucket.org/zzzeek/alembic/issues/317
    [2] https://review.openstack.org/#/c/214215/

    Change-Id: I0d0bddb05f543365d09e592bd81759534de49367
    Closes-Bug: 1486936

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (feature/pecan)

Fix proposed to branch: feature/pecan
Review: https://review.openstack.org/218710

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (feature/pecan)
Download full text (155.6 KiB)

Reviewed: https://review.openstack.org/218710
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=2c5f44e1b3bd4ed8a0b7232fd293b576cc8c1c87
Submitter: Jenkins
Branch: feature/pecan

commit f35d1c5c50dccbef1a2e079f967b82f0df0e22e9
Author: Adelina Tuvenie <email address hidden>
Date: Thu Aug 27 02:27:28 2015 -0700

    Fixes wrong neutron Hyper-V Agent name in constants

    Change Id03fb147e11541be309c1cd22ce27e70fadc28b5 moved the
    AGENT_TYPE_HYPERV constant from common.constants to
    plugins.ml2.drivers.hyperv.constants but change the value of the
    constant from 'HyperV agent' to 'hyperv'. This patch changes
    the name back to 'HyperV agent'

    Change-Id: If74b4b2a84811e266c8b12e70bf6bfe74ed4ea21
    Partial-Bug: #1487598

commit de604de334854e2eb6b4312ff57920564cbd4459
Author: OpenStack Proposal Bot <email address hidden>
Date: Sun Aug 30 01:39:06 2015 +0000

    Updated from global requirements

    Change-Id: Ie52aa3b59784722806726e4046bd07f4a4d97328

commit f0415ac20eaf5ab4abb9bd4839bf6d04ceee85d0
Author: armando-migliaccio <email address hidden>
Date: Fri Aug 28 13:53:04 2015 -0700

    Revert "Add support for unaddressed port"

    This implementation may expose a vulnerability where a malicious
    user can sieze the opportunity of a time window where a port
    may land unaddressed on a shared network, thus allowing him/her
    to suck up all the tenant traffic he/she wants....oh the shivers.

    This reverts commit d4c52b7f5a36a103a92bf9dcda7f371959112292.

    Change-Id: I7ebdaa8d3defa80eab90e460fde541a5bdd8864c

commit 013fdcd2a6d45dbe4de5d6e7077e5e9b60985ef9
Author: Assaf Muller <email address hidden>
Date: Fri Aug 28 16:41:07 2015 -0400

    Improve logging upon failure in iptables functional tests

    This will help us nail down a more accurate and efficient logstash
    query.

    Change-Id: Iee4238e358f7b056e373c7be8d6aa3202117a680
    Related-Bug: #1478847

commit 622dea818d851224a43d5276a81d5ce8a6eebb76
Author: Ivar Lazzaro <email address hidden>
Date: Mon Aug 17 17:17:42 2015 -0700

    handle gw_info outside of the db transaction on router creation

    Move the gateway interface creation outside the DB transaction
    to avoid lock timeout.

    Change-Id: I5a78d7f32e8ca912016978105221d5f34618af19
    Closes-bug: 1485809

commit 5b27d290a0a95f6247fc5a0fe6da1e7d905e6b2d
Author: Assaf Muller <email address hidden>
Date: Wed Aug 26 10:07:03 2015 -0400

    Remove ml2 resource extension success logging

    This is the cause of a tremendous amount of logs, for no
    perceivable gain. A normal dvr run in the gate shows this debug
    message around 120K times, which is way too much.

    Closes-Bug: #1489952

    Change-Id: I26fca8515d866a7cc1638d07fa33bc04479ae221

commit 8d3faf549cba2f58c872ef4121b2481e73464010
Author: huangpengtao <email address hidden>
Date: Fri Aug 28 23:20:46 2015 +0800

    Replace "prt" variable by "port"

    the local variable prt is meaningless,
    and port is used popular.

    Change-Id: I20849102cf5b4d84433c46791b4b1e2a22dc4739

commit ee374e7a5f4dea538fcd942f5...

tags: added: in-feature-pecan
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: liberty-3 → 7.0.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.