alembic v. 0.7.1 will support "remove_fk" and others not expected by heal_script

Bug #1397796 reported by Mike Bayer
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Critical
Unassigned
Juno
Fix Released
Undecided
Unassigned

Bug Description

neutron/db/migration/alembic_migrations/heal_script.py seems to have a hardcoded notion of what commands Alembic is prepared to pass within the execute_alembic_command() call. When Alembic 0.7.1 is released, the tests in neutron.tests.unit.db.test_migration will fail as follows:

Traceback (most recent call last):
      File "neutron/tests/unit/db/test_migration.py", line 194, in test_models_sync
        self.db_sync(self.get_engine())
      File "neutron/tests/unit/db/test_migration.py", line 136, in db_sync
        migration.do_alembic_command(self.alembic_config, 'upgrade', 'head')
      File "neutron/db/migration/cli.py", line 61, in do_alembic_command
        getattr(alembic_command, cmd)(config, *args, **kwargs)
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/command.py", line 165, in upgrade
        script.run_env()
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/script.py", line 382, in run_env
        util.load_python_file(self.dir, 'env.py')
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/util.py", line 241, in load_python_file
        module = load_module_py(module_id, path)
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/compat.py", line 79, in load_module_py
        mod = imp.load_source(module_id, path, fp)
      File "neutron/db/migration/alembic_migrations/env.py", line 109, in <module>
        run_migrations_online()
      File "neutron/db/migration/alembic_migrations/env.py", line 100, in run_migrations_online
        context.run_migrations()
      File "<string>", line 7, in run_migrations
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/environment.py", line 742, in run_migrations
        self.get_context().run_migrations(**kw)
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/.tox/sqla_py27/lib/python2.7/site-packages/alembic/migration.py", line 305, in run_migrations
        step.migration_fn(**kw)
      File "/var/jenkins/workspace/openstack_sqla_master/neutron/neutron/db/migration/alembic_migrations/versions/1d6ee1ae5da5_db_healing.py", line 32, in upgrade
        heal_script.heal()
      File "neutron/db/migration/alembic_migrations/heal_script.py", line 81, in heal
        execute_alembic_command(el)
      File "neutron/db/migration/alembic_migrations/heal_script.py", line 92, in execute_alembic_command
        METHODS[command[0]](*command[1:])
    KeyError: 'remove_fk'

I'll send a review for the obvious fix though I have a suspicion there's something more deliberate going on here, so consider this just a heads up!

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/137989

Changed in neutron:
assignee: nobody → Mike Bayer (zzzeek)
status: New → In Progress
Mike Bayer (zzzeek)
Changed in neutron:
assignee: Mike Bayer (zzzeek) → nobody
Revision history for this message
Adam Gandelman (gandelman-a) wrote :
Changed in neutron:
importance: Undecided → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

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

commit 6a9d1121472028f3583e577b62a7e576fff5806f
Author: Mike Bayer <email address hidden>
Date: Sun Nov 30 22:18:32 2014 -0500

    Alter execute_alembic_command() to not assume all commands

    Alembic 0.7.1 is adding new diff directives add_fk and remove_fk.
    The logic in execute_alembic_command() appears to assume all potential
    commands are present in METHODS. This patch adjusts it so that
    it checks METHODS first, allowing the tests in neutron.tests.unit.db.test_migration
    to pass. However, if the design here requires that all potential
    Alembic commands are handled, then this would not be the fix,
    though I recommend that the potential list of Alembic directives
    not be hardcoded.

    Change-Id: Ib08685be252e1fdb0f10853f8fc9a7e19ac54a94
    Closes-Bug: #1397796

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

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/138933

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/juno)

Reviewed: https://review.openstack.org/138933
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=d7ee2ff991e60ad54ff2125a397e9293ba966549
Submitter: Jenkins
Branch: stable/juno

commit d7ee2ff991e60ad54ff2125a397e9293ba966549
Author: Mike Bayer <email address hidden>
Date: Sun Nov 30 22:18:32 2014 -0500

    Alter execute_alembic_command() to not assume all commands

    Alembic 0.7.1 is adding new diff directives add_fk and remove_fk.
    The logic in execute_alembic_command() appears to assume all potential
    commands are present in METHODS. This patch adjusts it so that
    it checks METHODS first, allowing the tests in neutron.tests.unit.db.test_migration
    to pass. However, if the design here requires that all potential
    Alembic commands are handled, then this would not be the fix,
    though I recommend that the potential list of Alembic directives
    not be hardcoded.

    Change-Id: Ib08685be252e1fdb0f10853f8fc9a7e19ac54a94
    Closes-Bug: #1397796
    (cherry picked from commit 6a9d1121472028f3583e577b62a7e576fff5806f)

tags: added: in-stable-juno
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
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.