[openstack-dev] [neutron] Plethora of dbase migration questions...

Salvatore Orlando sorlando at nicira.com
Tue Jul 7 10:13:10 UTC 2015


Some comments inline.

Salvatore

On 6 July 2015 at 20:00, Paul Michali <pc at michali.net> wrote:

> Hi,
>
> I have some urgent requests about migration that I'm hoping to get some
> info on. I'm working on a bug where I need to add two (related) fields to a
> table for VPNaaS. Here's the objectives related to migration...
>
> 1) create local_v4_ip and lcoal_v6_ip fields in the vpnservice table
> 2) for each entry in the vpnservice table:
>     2.1) Get the router.gw_port.fixed_ips list
>     2.2) Determine the version of each fixed IP and store the first of
> each version (if any) into the appropriate new field.
>
> I have created a migration file, and I changed the down_revision to be the
> number of the revision that is the first in the migration chain in the VPN
> repo.
>
> Here are the many questions I have...
>
> When I look in the VPN repo, the HEAD file has the version 'kilo', which
> is not the current head.
>

> Shouldn't it the version number of the first file in the migration chain?
>

It should indeed. How are you generating the revision script? Using
neutron-db-manage it should be updated automatically [1]

For my commit, I'm assuming I change the HEAD file to use my migration
> file's version?
>

You can do that manually too, yes.


>
> I set HEAD to my migration file, and my file has a down revision of the
> previous head's revision. If I run 'neutron-db-manage --config-file
> ../neutron/etc/neutron.conf --config-file
> ../neutron/etc/neutron/plugins/ml2/ml2_conf.ini check_migration' there is
> no output so I guess that is OK.
>
> As I develop my new migration file, is there a way that I can test it
> (running neutron-db-migration, maybe)?
>

When I test migrations I usually dump the database, run the migration with
neutron-db-manage upgrade HEAD (I think it's not necessary to specify
HEAD), and restore the db from the dump if the migration fails.


> Is there a way to run the migration file under the debugger, as well
> (importing pdb, for example)?
>

The migration process is just like any python application, so I guess you
can debug it with pdb.


>
> In the migration, I can add the columns needed. What's the best way to
> fill out those fields - using raw SQL queries or create a Session object
> and access the VpnService object's router object?
>

If the default value for the column is not enough, and you need to specify
a value which depends on other values in the same row I would prefer plain
SQL statements, but if that become cumbersome I guess it's ok to use
sqlalchemy's session.


> I see there is some op.bind() call and then engine.execute(), but could
> use some help on the best way to extract the needed queries (I need to
> access the vpnservice's router, and then access the (Port) gw_port
> relationship, and from that access the (IPAllocation) fixed_ips list).
>

Perhaps you can point us to the review pages on gerrit, and we can provide
detailed comments there.


>
> Appreciate any advise here on how to debug the migration stuff...
>
> Paul Michali (pc_m)
>

[1]
http://git.openstack.org/cgit/openstack/neutron/tree/neutron/db/migration/cli.py#n124


>
>
>
>
>
>
>
>
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150707/6856104a/attachment.html>


More information about the OpenStack-dev mailing list