euca-terminate-instances fails to remove instance

Bug #613383 reported by Armando Migliaccio
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Unassigned

Bug Description

I get the following exception:

2010-08-04 11:42:36+0100 [-] (root): INFO Deleting instance files at /home/openstack/openstack/nova/data/instances/i-09mdf4sw
2010-08-04 11:42:36+0100 [-] Unhandled error in Deferred:
2010-08-04 11:42:36+0100 [-] Unhandled Error
        Traceback (most recent call last):
          File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 117, in maybeDeferred
            result = f(*args, **kw)
          File "/home/openstack/openstack/nova/trunk/nova/virt/libvirt_conn.py", line 102, in _wait_for_shutdown
            d.callback(None)
          File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 280, in callback
            self._startRunCallbacks(result)
          File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 354, in _startRunCallbacks
            self._runCallbacks()
        --- <exception caught here> ---
          File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 371, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "/home/openstack/openstack/nova/trunk/nova/virt/libvirt_conn.py", line 87, in <lambda>
            d.addCallback(lambda _: self._cleanup(instance))
          File "/home/openstack/openstack/nova/trunk/nova/virt/libvirt_conn.py", line 111, in _cleanup
            shutil.rmtree(target)
          File "/usr/lib/python2.6/shutil.py", line 208, in rmtree
            onerror(os.listdir, path, sys.exc_info())
          File "/usr/lib/python2.6/shutil.py", line 206, in rmtree
            names = os.listdir(path)
        exceptions.OSError: [Errno 2] No such file or directory: '~/openstack/nova/data/instances/i-09mdf4sw'

When the directory of the instance I am trying to terminate no longer exist (or has never been created due to errors on startup). However, euca-describe-instances still shows the instance in the list. In order to work this around (and remove the instance from the list) I create an empty directory under 'instances' and launch euca-terminate-instances again. I then get the following output:

2010-08-04 11:50:28+0100 [-] (root): DEBUG Got told to terminate instance i-09mdf4sw
2010-08-04 11:50:28+0100 [-] (root): DEBUG Finished init of Instance with id of i-09mdf4sw
2010-08-04 11:50:28+0100 [-] (root): INFO Deleting instance files at /home/openstack/openstack/nova/data/instances/i-09mdf4sw
2010-08-04 11:50:28+0100 [-] (root): INFO Destroying datamodel for Instance i-09mdf4sw

and the directory being removed under 'instances'

Revision history for this message
Jay Pipes (jaypipes) wrote :

The current code in LibvirtConnection._cleanup() is:

    def _cleanup(self, instance):
        target = os.path.join(FLAGS.instances_path, instance['name'])
        logging.info('instance %s: deleting instance files %s',
            instance['name'], target)
        if os.path.exists(target):
            shutil.rmtree(target)

Would you mind double-checking to see if this problem still exists, please, as it looks like the fix (checking for target directory existence before calling shutil.rmtree) is in trunk. Thanks!

Changed in nova:
status: New → Incomplete
importance: Undecided → Medium
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

yup, I think we can close it

Revision history for this message
Jay Pipes (jaypipes) wrote :

k, thx!

Changed in nova:
status: Incomplete → Fix Committed
Eric Day (eday)
Changed in nova:
status: Fix Committed → Fix Released
yongxiangwang (wangyxv)
description: updated
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.