termie / nova-migration-demo

Nova is a cloud computing fabric controller (the main part of an IaaS system). It is written in Python.
http://openstack.org/projects/compute/
Apache License 2.0
2 stars 0 forks source link

getting error "local variable 'location' referenced before assignment" while trying to attach an iscsi target #738

Open termie opened 13 years ago

termie commented 13 years ago

I successfully create a new iscsi volume and now I try to attach it to a running instance. But I got the attached error in /var/log/nova/compute.log.

ares:~ # euca-describe-instances RESERVATION r-0axmd0ci testing default INSTANCE i-00000079 ami-2a1izx00 192.168.3.18 192.168.3.18 running foobar (testing, ares) 0 m1.tiny 2011-02-22T15:28:05 nova

ares:~ # euca-describe-volumes VOLUME vol-00000001 7 nova available (berendt, deimos, None, None) 2011-02-22T14:45:00

ares:~ # euca-attach-volume vol-00000001 -i i-00000079 -d /dev/vdb VOLUME vol-00000001

2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: decorating: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: arguments: |<nova.compute.manager.ComputeManager object at 0xf6ec90>| |<nova.context.RequestContext object at 0x13f4b50>| |121| 2011-02-22 16:32:34,895 DEBUG nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: getting locked state from (pid=4273) get_lock /usr/lib64/python2.6/site-packages/nova/compute/manager.py:514 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: locked: |False| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: admin: |True| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: executing: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,990 AUDIT nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: attaching volume 1 to /dev/vdb 2011-02-22 16:30:21,250 ERROR nova.root [-] Exception during message handling (nova.root): TRACE: Traceback (most recent call last): (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/rpc.py", line 199, in _receive (nova.root): TRACE: rval = node_func(context=ctxt, _node_args) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 93, in decorated_function (nova.root): TRACE: function(self, context, instance_id, args, *_kwargs) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 556, in attach_volume (nova.root): TRACE: volume_id) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/manager.py", line 159, in setup_compute_volume (nova.root): TRACE: path = self.driver.discover_volume(volume_ref) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 312, in discover_volume (nova.root): TRACE: iscsi_name, iscsi_portal = self._get_name_and_portal(volume) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 307, in _get_name_and_portal (nova.root): TRACE: iscsi_portal = location.split(",")0: TRACE: UnboundLocalError: local variable 'location' referenced before assignment (nova.root): TRACE:


Imported from Launchpad using lp2gh.

termie commented 13 years ago

(by vishvananda) you need to set --iscsi_ip_prefix (for nova-compute) to something useful. It is essentially used as a grep to figure out which ip it should try to connect on during discovery,since discovery returns all ips of the volume-host that is exporting the volume. So if your hosts are on 192.168.0.0/24, then set it to 192.168.0. This will be removed once we git rid of discovery in the iscsi code. Justin's branch is most of the way there.

On Feb 22, 2011, at 7:33 AM, Christian Berendt wrote:

Public bug reported:

I successfully create a new iscsi volume and now I try to attach it to a running instance. But I got the attached error in /var/log/nova/compute.log.

ares:~ # euca-describe-instances RESERVATION r-0axmd0ci testing default INSTANCE i-00000079 ami-2a1izx00 192.168.3.18 192.168.3.18 running foobar (testing, ares) 0 m1.tiny 2011-02-22T15:28:05 nova

ares:~ # euca-describe-volumes VOLUME vol-00000001 7 nova available (berendt, deimos, None, None) 2011-02-22T14:45:00

ares:~ # euca-attach-volume vol-00000001 -i i-00000079 -d /dev/vdb VOLUME vol-00000001

2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: decorating: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: arguments: |<nova.compute.manager.ComputeManager object at 0xf6ec90>| |<nova.context.RequestContext object at 0x13f4b50>| |121| 2011-02-22 16:32:34,895 DEBUG nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: getting locked state from (pid=4273) get_lock /usr/lib64/python2.6/site-packages/nova/compute/manager.py:514 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: locked: |False| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: admin: |True| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: executing: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,990 AUDIT nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: attaching volume 1 to /dev/vdb 2011-02-22 16:30:21,250 ERROR nova.root [-] Exception during message handling (nova.root): TRACE: Traceback (most recent call last): (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/rpc.py", line 199, in _receive (nova.root): TRACE: rval = node_func(context=ctxt, _node_args) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 93, in decorated_function (nova.root): TRACE: function(self, context, instance_id, args, *_kwargs) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 556, in attach_volume (nova.root): TRACE: volume_id) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/manager.py", line 159, in setup_compute_volume (nova.root): TRACE: path = self.driver.discover_volume(volume_ref) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 312, in discover_volume (nova.root): TRACE: iscsi_name, iscsi_portal = self._get_name_and_portal(volume) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 307, in _get_name_and_portal (nova.root): TRACE: iscsi_portal = location.split(",")0: TRACE: UnboundLocalError: local variable 'location' referenced before assignment (nova.root): TRACE:

\ Affects: nova Importance: Undecided Status: New

You received this bug notification because you are a member of Nova Bug Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/723192

Title: getting error "local variable 'location' referenced before assignment" while trying to attach an iscsi target

Status in OpenStack Compute (Nova): New

Bug description: I successfully create a new iscsi volume and now I try to attach it to a running instance. But I got the attached error in /var/log/nova/compute.log.

ares:~ # euca-describe-instances RESERVATION r-0axmd0ci testing default INSTANCE i-00000079 ami-2a1izx00 192.168.3.18 192.168.3.18 running foobar (testing, ares) 0 m1.tiny 2011-02-22T15:28:05 nova

ares:~ # euca-describe-volumes VOLUME vol-00000001 7 nova available (berendt, deimos, None, None) 2011-02-22T14:45:00

ares:~ # euca-attach-volume vol-00000001 -i i-00000079 -d /dev/vdb VOLUME vol-00000001

2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: decorating: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: arguments: |<nova.compute.manager.ComputeManager object at 0xf6ec90>| |<nova.context.RequestContext object at 0x13f4b50>| |121| 2011-02-22 16:32:34,895 DEBUG nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: getting locked state from (pid=4273) get_lock /usr/lib64/python2.6/site-packages/nova/compute/manager.py:514 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: locked: |False| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: admin: |True| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: executing: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,990 AUDIT nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: attaching volume 1 to /dev/vdb 2011-02-22 16:30:21,250 ERROR nova.root [-] Exception during message handling (nova.root): TRACE: Traceback (most recent call last): (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/rpc.py", line 199, in _receive (nova.root): TRACE: rval = node_func(context=ctxt, _node_args) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 93, in decorated_function (nova.root): TRACE: function(self, context, instance_id, args, *_kwargs) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 556, in attach_volume (nova.root): TRACE: volume_id) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/manager.py", line 159, in setup_compute_volume (nova.root): TRACE: path = self.driver.discover_volume(volume_ref) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 312, in discover_volume (nova.root): TRACE: iscsi_name, iscsi_portal = self._get_name_and_portal(volume) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 307, in _get_name_and_portal (nova.root): TRACE: iscsi_portal = location.split(",")0: TRACE: UnboundLocalError: local variable 'location' referenced before assignment (nova.root): TRACE:

termie commented 13 years ago

(by berendt) I added "--iscsi_ip_prefix=192.168.3." (using network 192.168.3.0/24) to my nova.conf, but still not working.

ares:~ # iscsiadm -m discovery -t sendtargets -p deimos 192.168.2.140:3260,1 iqn.2010-10.org.openstack:volume-00000001

First question: I'm running all my services in the 192.168.2.0/24 network, all running instances will get an ip address in 192.168.3.0/24. If I understood you in the right way I should set the prefix to the network where my instances are located. Differs the output of iscsiadm (produced on a SLES system) to the output of a ubuntu system? I don't think so. Probably I missunderstood you...

I changed the flag to --iscsi_ip_prefix=192.168.2. and now it's working fine... (got a new device /dev/vdb on the instance... [ 913.710033] vdb: unknown partition table).

Also there is a missing check in _get_name_and_portal(self, volume) in nova/volume/driver.py. iscsiadm is called (not checking if there was some kind of error) and then it iterates through the results. If there is not entry matching FLAGS.iscsi_ip_prefix (which is $my_ip per default btw...) the method doesn't notice this.

Not sure to commit a bugfix if there will come in some new code (Justin's branch).

def _get_name_and_portal(self, volume):
    """Gets iscsi name and portal from volume name and host."""
    volume_name = volume['name']
    host = volume['host']
    (out, _err) = self._execute("sudo iscsiadm -m discovery -t "
                                "sendtargets -p %s" % host)
    for target in out.splitlines():
        if FLAGS.iscsi_ip_prefix in target and volume_name in target:
            (location, _sep, iscsi_name) = target.partition(" ")
            break
    iscsi_portal = location.split(",")[0]
    return (iscsi_name, iscsi_portal)
termie commented 13 years ago

(by vishvananda) Actually, it should be the prefix where the hosts are running. Better error checking would be good. It should also put a specific ip into the db instead of using a prefix, which would get rid of the need to use discover.

Vish On Feb 22, 2011, at 1:53 PM, Christian Berendt wrote:

I added "--iscsi_ip_prefix=192.168.3." (using network 192.168.3.0/24) to my nova.conf, but still not working.

ares:~ # iscsiadm -m discovery -t sendtargets -p deimos 192.168.2.140:3260,1 iqn.2010-10.org.openstack:volume-00000001

First question: I'm running all my services in the 192.168.2.0/24 network, all running instances will get an ip address in 192.168.3.0/24. If I understood you in the right way I should set the prefix to the network where my instances are located. Differs the output of iscsiadm (produced on a SLES system) to the output of a ubuntu system? I don't think so. Probably I missunderstood you...

I changed the flag to --iscsi_ip_prefix=192.168.2. and now it's working fine... (got a new device /dev/vdb on the instance... [ 913.710033] vdb: unknown partition table).

Also there is a missing check in _get_name_and_portal(self, volume) in nova/volume/driver.py. iscsiadm is called (not checking if there was some kind of error) and then it iterates through the results. If there is not entry matching FLAGS.iscsi_ip_prefix (which is $my_ip per default btw...) the method doesn't notice this.

Not sure to commit a bugfix if there will come in some new code (Justin's branch).

def _get_name_and_portal(self, volume): """Gets iscsi name and portal from volume name and host.""" volume_name = volume['name'] host = volume['host'](out, _err) = self._execute("sudo iscsiadm -m discovery -t " "sendtargets -p %s" % host) for target in out.splitlines(): if FLAGS.iscsi_ip_prefix in target and volume_name in target: (location, _sep, iscsi_name) = target.partition(" ") break iscsi_portal = location.split(",")[0] return (iscsi_name, iscsi_portal)

You received this bug notification because you are a member of Nova Bug Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/723192

Title: getting error "local variable 'location' referenced before assignment" while trying to attach an iscsi target

Status in OpenStack Compute (Nova): New

Bug description: I successfully create a new iscsi volume and now I try to attach it to a running instance. But I got the attached error in /var/log/nova/compute.log.

ares:~ # euca-describe-instances RESERVATION r-0axmd0ci testing default INSTANCE i-00000079 ami-2a1izx00 192.168.3.18 192.168.3.18 running foobar (testing, ares) 0 m1.tiny 2011-02-22T15:28:05 nova

ares:~ # euca-describe-volumes VOLUME vol-00000001 7 nova available (berendt, deimos, None, None) 2011-02-22T14:45:00

ares:~ # euca-attach-volume vol-00000001 -i i-00000079 -d /dev/vdb VOLUME vol-00000001

2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: decorating: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,894 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: arguments: |<nova.compute.manager.ComputeManager object at 0xf6ec90>| |<nova.context.RequestContext object at 0x13f4b50>| |121| 2011-02-22 16:32:34,895 DEBUG nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: getting locked state from (pid=4273) get_lock /usr/lib64/python2.6/site-packages/nova/compute/manager.py:514 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: locked: |False| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: admin: |True| 2011-02-22 16:32:34,944 INFO nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] check_instance_lock: executing: |<function attach_volume at 0xff0050>| 2011-02-22 16:32:34,990 AUDIT nova.compute.manager [JRZCL-3E16YICPXKCARK berendt testing] instance 121: attaching volume 1 to /dev/vdb 2011-02-22 16:30:21,250 ERROR nova.root [-] Exception during message handling (nova.root): TRACE: Traceback (most recent call last): (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/rpc.py", line 199, in _receive (nova.root): TRACE: rval = node_func(context=ctxt, _node_args) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 93, in decorated_function (nova.root): TRACE: function(self, context, instance_id, args, *_kwargs) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/compute/manager.py", line 556, in attach_volume (nova.root): TRACE: volume_id) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/manager.py", line 159, in setup_compute_volume (nova.root): TRACE: path = self.driver.discover_volume(volume_ref) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 312, in discover_volume (nova.root): TRACE: iscsi_name, iscsi_portal = self._get_name_and_portal(volume) (nova.root): TRACE: File "/usr/lib64/python2.6/site-packages/nova/volume/driver.py", line 307, in _get_name_and_portal (nova.root): TRACE: iscsi_portal = location.split(",")0: TRACE: UnboundLocalError: local variable 'location' referenced before assignment (nova.root): TRACE:

termie commented 13 years ago

(by armando-migliaccio) What hypervisor are you using? If you're using xapi the flags you need are:

target_host: the iSCSI Target Host IP address, i.e. the IP address for the nova-volume host target_port: iSCSI Target Port, 3260 Default iqn_prefix: IQN Prefix, e.g. 'iqn.2010-10.org.openstack'

This part of the code would do with a bit of cleaning. More info on:

https://bugs.launchpad.net/nova/+bug/695045 http://wiki.openstack.org/iSCSISupportXenAPI

termie commented 13 years ago

(by ttx) @Christian: any chance you could provide the requested information ? We can't really make progress on this without your input.