diff options
author | Andrey Pavlov <andrey.mp@gmail.com> | 2016-11-23 17:02:14 +0300 |
---|---|---|
committer | Andrey Pavlov <andrey.mp@gmail.com> | 2016-11-24 13:15:42 +0300 |
commit | f1afda393d8bfafd92b26a445452ab4c74912f0e (patch) | |
tree | ea3f8b4d1dee918a5ebd346b9505dd04cc75708e | |
parent | 2689a350c3f8ae63a4e175d81a673ee866db26c0 (diff) | |
download | glance_store-f1afda393d8bfafd92b26a445452ab4c74912f0e.tar.gz |
take into consideration created volume size in cinder backend
cinder can create bigger volumes than requested.
also cinder can extend volume to bigger size than requested.
cinder driver should take in into consideration.
Closes-Bug: #1644177
Change-Id: Ic0c0bc31193eaa28fb32fb5e13c4bceeeb11ae2b
-rw-r--r-- | glance_store/_drivers/cinder.py | 2 | ||||
-rw-r--r-- | glance_store/tests/unit/test_cinder_store.py | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index 521eb83..bfca003 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -660,6 +660,7 @@ class Store(glance_store.driver.Store): volume = client.volumes.create(size_gb, name=name, metadata=metadata, volume_type=volume_type) volume = self._wait_volume_status(volume, 'creating', 'available') + size_gb = volume.size failed = True need_extend = True @@ -694,6 +695,7 @@ class Store(glance_store.driver.Store): volume = self._wait_volume_status(volume, 'extending', 'available') + size_gb = volume.size except exceptions.BackendException: raise exceptions.StorageFull() diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py index d18a101..9cbae7d 100644 --- a/glance_store/tests/unit/test_cinder_store.py +++ b/glance_store/tests/unit/test_cinder_store.py @@ -308,12 +308,16 @@ class TestCinderStore(base.StoreBaseTest, volume_type='some_type') def test_cinder_add(self): - fake_volume = mock.MagicMock(id=str(uuid.uuid4()), status='available') + fake_volume = mock.MagicMock(id=str(uuid.uuid4()), + status='available', + size=1) volume_file = six.BytesIO() self._test_cinder_add(fake_volume, volume_file) def test_cinder_add_with_verifier(self): - fake_volume = mock.MagicMock(id=str(uuid.uuid4()), status='available') + fake_volume = mock.MagicMock(id=str(uuid.uuid4()), + status='available', + size=1) volume_file = six.BytesIO() verifier = mock.MagicMock() self._test_cinder_add(fake_volume, volume_file, 1, verifier) @@ -323,7 +327,9 @@ class TestCinderStore(base.StoreBaseTest, e = IOError() volume_file = six.BytesIO() e.errno = errno.ENOSPC - fake_volume = mock.MagicMock(id=str(uuid.uuid4()), status='available') + fake_volume = mock.MagicMock(id=str(uuid.uuid4()), + status='available', + size=1) with mock.patch.object(volume_file, 'write', side_effect=e): self.assertRaises(exceptions.StorageFull, self._test_cinder_add, fake_volume, volume_file) |