diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-13 16:07:16 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-13 16:07:16 +0000 |
| commit | 03de59d976e1c2e821ebfa2ee8933083c92a27e6 (patch) | |
| tree | be96846460057af7cebe322dae6c3d7de1ce981e | |
| parent | b0c461847a0b699377224174b4646d2c328200a7 (diff) | |
| parent | 5eea8879b6f3268dcaba326193bef0ed75470bb7 (diff) | |
Merge "ensure libguestfs mounts are cleaned up"
| -rw-r--r-- | nova/virt/disk/guestfs.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nova/virt/disk/guestfs.py b/nova/virt/disk/guestfs.py index f2ff3c371..c44158d0d 100644 --- a/nova/virt/disk/guestfs.py +++ b/nova/virt/disk/guestfs.py @@ -17,6 +17,7 @@ import os +from nova import exception from nova import utils from nova.virt.disk import mount @@ -88,9 +89,18 @@ class Mount(mount.Mount): def unmnt_dev(self): if not self.mounted: return - # root users don't need a specific unmnt_dev() - # but ordinary users do - utils.execute('fusermount', '-u', self.mount_dir, run_as_root=True) + umount_cmd = ['fusermount', '-u', self.mount_dir] + try: + # We make a few attempts to work around other + # processes temporarily scanning the mount_dir etc. + utils.execute(*umount_cmd, attempts=5, run_as_root=True) + except exception.ProcessExecutionError: + # If we still can't umount, then do a lazy umount + # (in the background), so that mounts might eventually + # be cleaned up. Note we'll wait 10s below for the umount to + # complete, after which we'll raise an exception. + umount_cmd.insert(1, '-z') + utils.execute(*umount_cmd, run_as_root=True) # Unfortunately FUSE has an issue where it doesn't wait # for processes associated with the mount to terminate. |
