Creating image-volume cache on NFS backend fails

snapshot.id doesn't have `tmp-snap` in it as id
is not passed as a option while creating snapshot
object. This should be change to
`snapshot.display_name` at same location

Closes-Bug: #1875570
Change-Id: I66da0212a61d778fe9795d382b3af5b225a8aa54
This commit is contained in:
Sofia Enriquez 2020-05-08 20:24:48 +00:00
parent 562fa42376
commit e52ab1a3ad
3 changed files with 13 additions and 2 deletions

View File

@ -280,7 +280,9 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
exp_acceptable_states = ['available', 'in-use', 'backing-up']
if tmp_snap:
exp_acceptable_states.append('downloading')
self._fake_snapshot.id = 'tmp-snap-%s' % self._fake_snapshot.id
self._fake_snapshot.volume.status = 'downloading'
display_name = 'tmp-snap-%s' % self._fake_snapshot.id
self._fake_snapshot.display_name = display_name
if volume_in_use:
self._fake_snapshot.volume.status = 'backing-up'
@ -315,6 +317,9 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
self._driver._create_snapshot,
self._fake_snapshot)
def test_create_snapshot_w_image_caching(self):
self._test_create_snapshot(tmp_snap=True)
@mock.patch('cinder.db.snapshot_get')
@mock.patch('time.sleep')
def test_create_snapshot_online_with_concurrent_delete(

View File

@ -1440,7 +1440,7 @@ class RemoteFSSnapDriverBase(RemoteFSDriver):
status = snapshot.volume.status
acceptable_states = ['available', 'in-use', 'backing-up']
if snapshot.id.startswith('tmp-snap-'):
if snapshot.display_name.startswith('tmp-snap-'):
# This is an internal volume snapshot. In order to support
# image caching, we'll allow creating/deleting such snapshots
# while having volumes in 'downloading' state.

View File

@ -0,0 +1,6 @@
---
fixes:
- |
`Bug #1875570 <https://bugs.launchpad.net/cinder/+bug/1875570>`:
Fixed issue with NFS backend where the image-volume cache was
never used to create a volume, even when the cache was enabled.