Merge lp:~ntt-pf-lab/nova/lp703037 into lp:~hudson-openstack/nova/trunk

Proposed by Hisaharu Ishii
Status: Merged
Approved by: Soren Hansen
Approved revision: 586
Merged at revision: 626
Proposed branch: lp:~ntt-pf-lab/nova/lp703037
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 247 lines (+56/-32)
8 files modified
bin/nova-manage (+2/-2)
nova/network/linux_net.py (+5/-6)
nova/network/manager.py (+5/-1)
nova/test.py (+2/-1)
nova/tests/test_virt.py (+13/-0)
nova/utils.py (+6/-10)
nova/virt/libvirt.xml.template (+4/-2)
nova/virt/libvirt_conn.py (+19/-10)
To merge this branch: bzr merge lp:~ntt-pf-lab/nova/lp703037
Reviewer Review Type Date Requested Status
Soren Hansen (community) Approve
Vish Ishaya (community) Approve
Wayne A. Walls Pending
Review via email: mp+47028@code.launchpad.net

Commit message

Fix Bug #703037. ra_server is None

Description of the change

Fix for LP Bug #703037
* update_ra() updates ra_server column every time
* When radvd is already running, not to hup, but to restart
* Fix prefixlen of RA server address in firewall rule from /64 to /128
* Fix apply_instance_filter is not implemented in NWFilterFirewall

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

I notice that you are using project_get_network to get the ra server for the project. This will not work properly in flatDHCP mode which doesn't have the project set. This needs to be changed to db.network_get_by_instance. I also noticed there are a few other references to this method that need to be changed, so I've put in an additional bug and fix here:

https://code.launchpad.net/~vishvananda/nova/lp707262

 so you might want to merge that branch as well and propose with that branch as a prerequisite

review: Needs Fixing
Revision history for this message
Hisaharu Ishii (ishii-hisaharu) wrote :

>Vish Ishaya

I have tried to merge your branch to my branch.
But in UnitTest, this error was occurred.
Now I'm working with this issue.

======================================================================
ERROR: test_creates_base_rule_first (nova.tests.test_virt.NWFilterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ishii/20110125/lp703037/nova/tests/test_virt.py", line 495, in test_creates_base_rule_first
    self.fw.prepare_instance_filter(instance)
  File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 1103, in prepare_instance_filter
    ra_server = self._ra_server_for_instance(instance)
  File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 886, in _ra_server_for_instance
    instance['id'])
  File "/home/ishii/20110125/lp703037/nova/db/api.py", line 517, in network_get_by_instance
    return IMPL.network_get_by_instance(context, instance_id)
  File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 96, in wrapper
    return f(*args, **kwargs)
  File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 1097, in network_get_by_instance
    raise exception.NotFound(_('No network for instance %s') % instance_id)
NotFound: No network for instance 92

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

You can use the same strategy for getting and allocating an ip that is used
by other tests test_virt if there is no other way to get the data in
prepare_instance_filter

On Mon, Jan 24, 2011 at 10:53 PM, Hisaharu Ishii <
<email address hidden>> wrote:

> >Vish Ishaya
>
> I have tried to merge your branch to my branch.
> But in UnitTest, this error was occurred.
> Now I'm working with this issue.
>
> ======================================================================
> ERROR: test_creates_base_rule_first (nova.tests.test_virt.NWFilterTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/ishii/20110125/lp703037/nova/tests/test_virt.py", line 495, in
> test_creates_base_rule_first
> self.fw.prepare_instance_filter(instance)
> File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 1103,
> in prepare_instance_filter
> ra_server = self._ra_server_for_instance(instance)
> File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 886,
> in _ra_server_for_instance
> instance['id'])
> File "/home/ishii/20110125/lp703037/nova/db/api.py", line 517, in
> network_get_by_instance
> return IMPL.network_get_by_instance(context, instance_id)
> File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 96,
> in wrapper
> return f(*args, **kwargs)
> File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 1097,
> in network_get_by_instance
> raise exception.NotFound(_('No network for instance %s') % instance_id)
> NotFound: No network for instance 92
>
> --
> https://code.launchpad.net/~ntt-pf-lab/nova/lp703037/+merge/47028
> You are reviewing the proposed merge of lp:~ntt-pf-lab/nova/lp703037 into
> lp:nova.
>

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

like so:
https://code.launchpad.net/~vishvananda/nova/lp703037

Vish

On Jan 25, 2011, at 12:07 AM, Vish Ishaya wrote:

> You can use the same strategy for getting and allocating an ip that is used
> by other tests test_virt if there is no other way to get the data in
> prepare_instance_filter
>
> On Mon, Jan 24, 2011 at 10:53 PM, Hisaharu Ishii <
> <email address hidden>> wrote:
>
>>> Vish Ishaya
>>
>> I have tried to merge your branch to my branch.
>> But in UnitTest, this error was occurred.
>> Now I'm working with this issue.
>>
>> ======================================================================
>> ERROR: test_creates_base_rule_first (nova.tests.test_virt.NWFilterTestCase)
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>> File "/home/ishii/20110125/lp703037/nova/tests/test_virt.py", line 495, in
>> test_creates_base_rule_first
>> self.fw.prepare_instance_filter(instance)
>> File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 1103,
>> in prepare_instance_filter
>> ra_server = self._ra_server_for_instance(instance)
>> File "/home/ishii/20110125/lp703037/nova/virt/libvirt_conn.py", line 886,
>> in _ra_server_for_instance
>> instance['id'])
>> File "/home/ishii/20110125/lp703037/nova/db/api.py", line 517, in
>> network_get_by_instance
>> return IMPL.network_get_by_instance(context, instance_id)
>> File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 96,
>> in wrapper
>> return f(*args, **kwargs)
>> File "/home/ishii/20110125/lp703037/nova/db/sqlalchemy/api.py", line 1097,
>> in network_get_by_instance
>> raise exception.NotFound(_('No network for instance %s') % instance_id)
>> NotFound: No network for instance 92
>>
>> --
>> https://code.launchpad.net/~ntt-pf-lab/nova/lp703037/+merge/47028
>> You are reviewing the proposed merge of lp:~ntt-pf-lab/nova/lp703037 into
>> lp:nova.
>>
>
> --
> https://code.launchpad.net/~ntt-pf-lab/nova/lp703037/+merge/47028
> You are reviewing the proposed merge of lp:~ntt-pf-lab/nova/lp703037 into lp:nova.

lp:~ntt-pf-lab/nova/lp703037 updated
580. By Nachi Ueno

Merged with r606

581. By Hisaharu Ishii

Merged with vish branch

582. By Nachi Ueno

Merged with http://bazaar.launchpad.net/~vishvananda/nova/lp703037

583. By Nachi Ueno

merged r621

584. By Nachi Ueno

Changed method signature of create_network

Revision history for this message
Nachi Ueno (nati-ueno) wrote :

>Vish
Thank you for your helpful code.
We fixed #703037 and #705811 in this branch.
We also merge this branch with r621.
Unit test is OK now.

lp:~ntt-pf-lab/nova/lp703037 updated
585. By Hisaharu Ishii

Fix merge miss

586. By Hisaharu Ishii

use 'ip addr change'

Revision history for this message
Hisaharu Ishii (ishii-hisaharu) wrote :

I updated our branch for
* Fix some merge miss in r583
* Fix Bug #707908

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

lgtm

review: Approve
Revision history for this message
Soren Hansen (soren) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/nova-manage'
2--- bin/nova-manage 2011-01-25 23:29:30 +0000
3+++ bin/nova-manage 2011-01-26 12:27:54 +0000
4@@ -495,9 +495,9 @@
5 cidr=fixed_range,
6 num_networks=int(num_networks),
7 network_size=int(network_size),
8+ cidr_v6=fixed_range_v6,
9 vlan_start=int(vlan_start),
10- vpn_start=int(vpn_start),
11- cidr_v6=fixed_range_v6)
12+ vpn_start=int(vpn_start))
13
14
15 class ServiceCommands(object):
16
17=== modified file 'nova/network/linux_net.py'
18--- nova/network/linux_net.py 2011-01-17 18:05:26 +0000
19+++ nova/network/linux_net.py 2011-01-26 12:27:54 +0000
20@@ -198,9 +198,9 @@
21 net_attrs['broadcast'],
22 net_attrs['netmask']))
23 if(FLAGS.use_ipv6):
24- _execute("sudo ifconfig %s add %s up" % \
25- (bridge,
26- net_attrs['cidr_v6']))
27+ _execute("sudo ip -f inet6 addr change %s dev %s" %
28+ (net_attrs['cidr_v6'], bridge))
29+ _execute("sudo ifconfig %s up" % bridge)
30 else:
31 _execute("sudo ifconfig %s up" % bridge)
32 if FLAGS.use_nova_chains:
33@@ -298,10 +298,9 @@
34 % pid, check_exit_code=False)
35 if conffile in out:
36 try:
37- _execute('sudo kill -HUP %d' % pid)
38- return
39+ _execute('sudo kill %d' % pid)
40 except Exception as exc: # pylint: disable-msg=W0703
41- LOG.debug(_("Hupping radvd threw %s"), exc)
42+ LOG.debug(_("killing radvd threw %s"), exc)
43 else:
44 LOG.debug(_("Pid %d is stale, relaunching radvd"), pid)
45 command = _ra_cmd(network_ref)
46
47=== modified file 'nova/network/manager.py'
48--- nova/network/manager.py 2011-01-25 22:53:09 +0000
49+++ nova/network/manager.py 2011-01-26 12:27:54 +0000
50@@ -428,6 +428,10 @@
51 self.driver.ensure_bridge(network_ref['bridge'],
52 FLAGS.flat_interface,
53 network_ref)
54+ if not FLAGS.fake_network:
55+ self.driver.update_dhcp(context, network_id)
56+ if(FLAGS.use_ipv6):
57+ self.driver.update_ra(context, network_id)
58
59
60 class VlanManager(NetworkManager):
61@@ -497,7 +501,7 @@
62 network_ref['bridge'])
63
64 def create_networks(self, context, cidr, num_networks, network_size,
65- vlan_start, vpn_start, cidr_v6):
66+ cidr_v6, vlan_start, vpn_start):
67 """Create networks based on parameters."""
68 fixed_net = IPy.IP(cidr)
69 fixed_net_v6 = IPy.IP(cidr_v6)
70
71=== modified file 'nova/test.py'
72--- nova/test.py 2011-01-14 19:19:51 +0000
73+++ nova/test.py 2011-01-26 12:27:54 +0000
74@@ -69,9 +69,10 @@
75 network_manager.VlanManager().create_networks(ctxt,
76 FLAGS.fixed_range,
77 5, 16,
78+ FLAGS.fixed_range_v6,
79 FLAGS.vlan_start,
80 FLAGS.vpn_start,
81- FLAGS.fixed_range_v6)
82+ )
83
84 # emulate some of the mox stuff, we can't use the metaclass
85 # because it screws with our generators
86
87=== modified file 'nova/tests/test_virt.py'
88--- nova/tests/test_virt.py 2011-01-25 02:31:04 +0000
89+++ nova/tests/test_virt.py 2011-01-26 12:27:54 +0000
90@@ -474,6 +474,19 @@
91 'project_id': 'fake'})
92 inst_id = instance_ref['id']
93
94+ ip = '10.11.12.13'
95+
96+ network_ref = db.project_get_network(self.context,
97+ 'fake')
98+
99+ fixed_ip = {'address': ip,
100+ 'network_id': network_ref['id']}
101+
102+ admin_ctxt = context.get_admin_context()
103+ db.fixed_ip_create(admin_ctxt, fixed_ip)
104+ db.fixed_ip_update(admin_ctxt, ip, {'allocated': True,
105+ 'instance_id': instance_ref['id']})
106+
107 def _ensure_all_called():
108 instance_filter = 'nova-instance-%s' % instance_ref['name']
109 secgroup_filter = 'nova-secgroup-%s' % self.security_group['id']
110
111=== modified file 'nova/utils.py'
112--- nova/utils.py 2011-01-19 15:41:30 +0000
113+++ nova/utils.py 2011-01-26 12:27:54 +0000
114@@ -206,21 +206,17 @@
115 def get_my_linklocal(interface):
116 try:
117 if_str = execute("ip -f inet6 -o addr show %s" % interface)
118- condition = "\s+inet6\s+([0-9a-f:]+/\d+)\s+scope\s+link"
119+ condition = "\s+inet6\s+([0-9a-f:]+)/\d+\s+scope\s+link"
120 links = [re.search(condition, x) for x in if_str[0].split('\n')]
121 address = [w.group(1) for w in links if w is not None]
122 if address[0] is not None:
123 return address[0]
124 else:
125- return 'fe00::'
126- except IndexError as ex:
127- LOG.warn(_("Couldn't get Link Local IP of %(interface)s :%(ex)s")
128- % locals())
129- except ProcessExecutionError as ex:
130- LOG.warn(_("Couldn't get Link Local IP of %(interface)s :%(ex)s")
131- % locals())
132- except:
133- return 'fe00::'
134+ raise exception.Error(_("Link Local address is not found.:%s")
135+ % if_str)
136+ except Exception as ex:
137+ raise exception.Error(_("Couldn't get Link Local IP of %s :%s")
138+ % (interface, ex))
139
140
141 def to_global_ipv6(prefix, mac):
142
143=== modified file 'nova/virt/libvirt.xml.template'
144--- nova/virt/libvirt.xml.template 2011-01-14 10:24:57 +0000
145+++ nova/virt/libvirt.xml.template 2011-01-26 12:27:54 +0000
146@@ -75,11 +75,13 @@
147 <!-- <model type='virtio'/> CANT RUN virtio network right now -->
148 <filterref filter="nova-instance-${name}">
149 <parameter name="IP" value="${ip_address}" />
150- <parameter name="DHCPSERVER" value="${dhcp_server}" />
151- <parameter name="RASERVER" value="${ra_server}" />
152+ <parameter name="DHCPSERVER" value="${dhcp_server}" />
153 #if $getVar('extra_params', False)
154 ${extra_params}
155 #end if
156+#if $getVar('ra_server', False)
157+ <parameter name="RASERVER" value="${ra_server}" />
158+#end if
159 </filterref>
160 </interface>
161
162
163=== modified file 'nova/virt/libvirt_conn.py'
164--- nova/virt/libvirt_conn.py 2011-01-25 23:20:55 +0000
165+++ nova/virt/libvirt_conn.py 2011-01-26 12:27:54 +0000
166@@ -678,8 +678,7 @@
167 # Assume that the gateway also acts as the dhcp server.
168 dhcp_server = network['gateway']
169 ra_server = network['ra_server']
170- if not ra_server:
171- ra_server = 'fd00::'
172+
173 if FLAGS.allow_project_net_traffic:
174 if FLAGS.use_ipv6:
175 net, mask = _get_net_and_mask(network['cidr'])
176@@ -718,11 +717,13 @@
177 'mac_address': instance['mac_address'],
178 'ip_address': ip_address,
179 'dhcp_server': dhcp_server,
180- 'ra_server': ra_server,
181 'extra_params': extra_params,
182 'rescue': rescue,
183 'local': instance_type['local_gb'],
184 'driver_type': driver_type}
185+
186+ if ra_server:
187+ xml_info['ra_server'] = ra_server + "/128"
188 if not rescue:
189 if instance['kernel_id']:
190 xml_info['kernel'] = xml_info['basepath'] + "/kernel"
191@@ -905,6 +906,11 @@
192 the security group."""
193 raise NotImplementedError()
194
195+ def _ra_server_for_instance(self, instance):
196+ network = db.network_get_by_instance(context.get_admin_context(),
197+ instance['id'])
198+ return network['ra_server']
199+
200
201 class NWFilterFirewall(FirewallDriver):
202 """
203@@ -957,6 +963,10 @@
204 self.static_filters_configured = False
205 self.handle_security_groups = False
206
207+ def apply_instance_filter(self, instance):
208+ """No-op. Everything is done in prepare_instance_filter"""
209+ pass
210+
211 def _get_connection(self):
212 return self._libvirt_get_connection()
213 _conn = property(_get_connection)
214@@ -1115,7 +1125,9 @@
215 'nova-base-ipv6',
216 'nova-allow-dhcp-server']
217 if FLAGS.use_ipv6:
218- instance_secgroup_filter_children += ['nova-allow-ra-server']
219+ ra_server = self._ra_server_for_instance(instance)
220+ if ra_server:
221+ instance_secgroup_filter_children += ['nova-allow-ra-server']
222
223 ctxt = context.get_admin_context()
224
225@@ -1142,10 +1154,6 @@
226
227 return
228
229- def apply_instance_filter(self, instance):
230- """No-op. Everything is done in prepare_instance_filter"""
231- pass
232-
233 def refresh_security_group_rules(self, security_group_id):
234 return self._define_filter(
235 self.security_group_to_nwfilter_xml(security_group_id))
236@@ -1301,8 +1309,9 @@
237 elif(ip_version == 6):
238 # Allow RA responses
239 ra_server = self._ra_server_for_instance(instance)
240- our_rules += ['-A %s -s %s -p icmpv6 '
241- '-j ACCEPT' % (chain_name, ra_server)]
242+ if ra_server:
243+ our_rules += ['-A %s -s %s -p icmpv6 -j ACCEPT' %
244+ (chain_name, ra_server + "/128")]
245 #Allow project network traffic
246 if (FLAGS.allow_project_net_traffic):
247 cidrv6 = self._project_cidrv6_for_instance(instance)