GlusterFS: Delete volume-<uuid>.info file when volume is deleted.
glusterfs creates a file named volume-<uuid>.info to hold volume data, mapping cinder snapshot UUIDs and filenames. When the volume and its associated snapshots are both deleted, this file remains. This patch deletes the volume-<uuid>.info (if one exists) when the volume is deleted. Change-Id: Iefc8bd4768b30a75c648c4689d935daeab3afe98 Closes-Bug: #1299182
This commit is contained in:
parent
6b3d177695
commit
bf006ecb4a
|
@ -14,7 +14,9 @@
|
|||
# under the License.
|
||||
"""Unit tests for the GlusterFS driver module."""
|
||||
|
||||
import contextlib
|
||||
import errno
|
||||
import mock
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
@ -745,6 +747,31 @@ class GlusterFsDriverTestCase(test.TestCase):
|
|||
|
||||
mox.VerifyAll()
|
||||
|
||||
@mock.patch('os.remove')
|
||||
@mock.patch('os.path.exists')
|
||||
def test_delete_volume_with_info_file(self, mock_path_exists, mock_remove):
|
||||
mock_path_exists.return_value = True
|
||||
info_file = self.TEST_LOCAL_PATH + '.info'
|
||||
volume = self._simple_volume()
|
||||
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self._driver, '_ensure_share_mounted'),
|
||||
mock.patch.object(self._driver, 'local_path'),
|
||||
mock.patch.object(self._driver, '_execute')
|
||||
) as (mock_ensure_share_mounted, mock_local_path, mock_execute):
|
||||
mock_local_path.return_value = self.TEST_LOCAL_PATH
|
||||
|
||||
self._driver.delete_volume(volume)
|
||||
|
||||
mock_ensure_share_mounted.assert_called_once_with(
|
||||
volume['provider_location'])
|
||||
mock_local_path.assert_called_once_with(volume)
|
||||
mock_execute.assert_called_once_with('rm', '-f',
|
||||
self.TEST_LOCAL_PATH,
|
||||
run_as_root=True)
|
||||
mock_path_exists.assert_called_once_with(info_file)
|
||||
mock_remove.assert_called_once_with(info_file)
|
||||
|
||||
def test_create_snapshot(self):
|
||||
(mox, drv) = self._mox, self._driver
|
||||
|
||||
|
|
|
@ -297,6 +297,10 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
|
|||
|
||||
self._execute('rm', '-f', mounted_path, run_as_root=True)
|
||||
|
||||
info_path = mounted_path + '.info'
|
||||
if os.path.exists(info_path):
|
||||
os.remove(info_path)
|
||||
|
||||
@utils.synchronized('glusterfs', external=False)
|
||||
def create_snapshot(self, snapshot):
|
||||
"""Apply locking to the create snapshot operation."""
|
||||
|
|
Loading…
Reference in New Issue