Merge lp:~vishvananda/nova/fix-floating-reboot into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Devin Carlen
Approved revision: 1542
Merged at revision: 1571
Proposed branch: lp:~vishvananda/nova/fix-floating-reboot
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 97 lines (+14/-6)
4 files modified
nova/db/api.py (+5/-3)
nova/db/sqlalchemy/api.py (+4/-1)
nova/network/manager.py (+2/-1)
nova/tests/db/fakes.py (+3/-1)
To merge this branch: bzr merge lp:~vishvananda/nova/fix-floating-reboot
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Dan Prince (community) Approve
Review via email: mp+75279@code.launchpad.net

Description of the change

Fix issue where floating ips don't get recreated when a network host reboots.

To post a comment you must log in.
Revision history for this message
Dan Prince (dan-prince) wrote :

This looks good. I suppose we could attempt to populate the host columns via a DB migration (by looking in the services table for a network host?). Kind of a polish thing but if a user had lots of floating IPs it could save a bit of time.

I think this is good though.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

Vish, do you want to do anything with the migrations?

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

no, it would only be for people who are upgrading from d4, earlier than that the host wasn't set. I don't feel it is really necessary.

Revision history for this message
Devin Carlen (devcamcar) wrote :

Sounds good, will approve.

Revision history for this message
Trey Morris (tr3buchet) wrote :

gah i gotta pay closer attention.. So networks have hosts, and fixed_ips have networks, floating_ips are associated with fixed_ips. Couldn't we just get to the host a floating_ip is associated with.

floating_ip['fixed_ip']['network']['host']
or
if ha
floating_ip['fixed_ip']['instance']['host']

I'm confused.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Yes that was my first approach, but it required changing linked tables in the db as well, so I figured go for the smaller change for diablo bug fixing. I you feel like the other change is more accurate, feel free to prop it into essex, perhaps with a drop column host in floating ips.

Vish

 On Sep 16, 2011, at 3:32 PM, Trey Morris wrote:

> gah i gotta pay closer attention.. So networks have hosts, and fixed_ips have networks, floating_ips are associated with fixed_ips. Couldn't we just get to the host a floating_ip is associated with.
>
> floating_ip['fixed_ip']['network']['host']
> or
> if ha
> floating_ip['fixed_ip']['instance']['host']
>
> I'm confused.
> --
> https://code.launchpad.net/~vishvananda/nova/fix-floating-reboot/+merge/75279
> You are the owner of lp:~vishvananda/nova/fix-floating-reboot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/db/api.py'
2--- nova/db/api.py 2011-09-08 20:49:03 +0000
3+++ nova/db/api.py 2011-09-13 23:54:17 +0000
4@@ -261,11 +261,13 @@
5 return IMPL.floating_ip_disassociate(context, address)
6
7
8-def floating_ip_fixed_ip_associate(context, floating_address, fixed_address):
9+def floating_ip_fixed_ip_associate(context, floating_address,
10+ fixed_address, host):
11 """Associate an floating ip to a fixed_ip by address."""
12 return IMPL.floating_ip_fixed_ip_associate(context,
13 floating_address,
14- fixed_address)
15+ fixed_address,
16+ host)
17
18
19 def floating_ip_get_all(context):
20@@ -367,7 +369,7 @@
21
22 def fixed_ip_get_all_by_instance_host(context, host):
23 """Get all allocated fixed ips filtered by instance host."""
24- return IMPL.fixed_ip_get_all_instance_by_host(context, host)
25+ return IMPL.fixed_ip_get_all_by_instance_host(context, host)
26
27
28 def fixed_ip_get_by_address(context, address):
29
30=== modified file 'nova/db/sqlalchemy/api.py'
31--- nova/db/sqlalchemy/api.py 2011-09-12 19:43:15 +0000
32+++ nova/db/sqlalchemy/api.py 2011-09-13 23:54:17 +0000
33@@ -529,7 +529,8 @@
34
35
36 @require_context
37-def floating_ip_fixed_ip_associate(context, floating_address, fixed_address):
38+def floating_ip_fixed_ip_associate(context, floating_address,
39+ fixed_address, host):
40 session = get_session()
41 with session.begin():
42 # TODO(devcamcar): How to ensure floating_id belongs to user?
43@@ -540,6 +541,7 @@
44 fixed_address,
45 session=session)
46 floating_ip_ref.fixed_ip = fixed_ip_ref
47+ floating_ip_ref.host = host
48 floating_ip_ref.save(session=session)
49
50
51@@ -583,6 +585,7 @@
52 else:
53 fixed_ip_address = None
54 floating_ip_ref.fixed_ip = None
55+ floating_ip_ref.host = None
56 floating_ip_ref.save(session=session)
57 return fixed_ip_address
58
59
60=== modified file 'nova/network/manager.py'
61--- nova/network/manager.py 2011-09-12 02:11:43 +0000
62+++ nova/network/manager.py 2011-09-13 23:54:17 +0000
63@@ -289,7 +289,8 @@
64
65 self.db.floating_ip_fixed_ip_associate(context,
66 floating_address,
67- fixed_address)
68+ fixed_address,
69+ self.host)
70 self.driver.bind_floating_ip(floating_address)
71 self.driver.ensure_floating_forward(floating_address, fixed_address)
72
73
74=== modified file 'nova/tests/db/fakes.py'
75--- nova/tests/db/fakes.py 2011-07-19 21:25:16 +0000
76+++ nova/tests/db/fakes.py 2011-09-13 23:54:17 +0000
77@@ -125,10 +125,11 @@
78 if ips[0]['fixed_ip']:
79 fixed_ip_address = ips[0]['fixed_ip']['address']
80 ips[0]['fixed_ip'] = None
81+ ips[0]['host'] = None
82 return fixed_ip_address
83
84 def fake_floating_ip_fixed_ip_associate(context, floating_address,
85- fixed_address):
86+ fixed_address, host):
87 float = filter(lambda i: i['address'] == floating_address,
88 floating_ips)
89 fixed = filter(lambda i: i['address'] == fixed_address,
90@@ -136,6 +137,7 @@
91 if float and fixed:
92 float[0]['fixed_ip'] = fixed[0]
93 float[0]['fixed_ip_id'] = fixed[0]['id']
94+ float[0]['host'] = host
95
96 def fake_floating_ip_get_all_by_host(context, host):
97 # TODO(jkoelker): Once we get the patches that remove host from