Creating snapshot on NFS backend fails

Bug #1886222 reported by Alex Deiter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Alex Deiter

Bug Description

Creating a snapshot on the NFS backend fails if the snapshot name is not specified.

Following are the steps to reproduce the issue:

1. Configure a NFS backend for Cinder:

/etc/cinder/cinder.conf:
[DEFAULT]
default_volume_type = nfs
enabled_backends = nfs

[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
volume_backend_name = nfs
nfs_snapshot_support = True
nas_host = 10.3.35.41
nas_share_path = /volumes/pool1/nas

2. Create a volume:
$ cinder create --volume-type nfs 1

3. Check the volume file:
$ qemu-img info /opt/stack/data/cinder/mnt/0abe5ba79045d7dd179ddc8a4ff1991c/volume-c37c17d9-7657-4f9c-8072-b8af85aeb55e
image: /opt/stack/data/cinder/mnt/0abe5ba79045d7dd179ddc8a4ff1991c/volume-c37c17d9-7657-4f9c-8072-b8af85aeb55e
file format: raw
virtual size: 1.0G (1073741824 bytes)
disk size: 512

3. Try to create a snapshot for the volume:
$ cinder snapshot-create c37c17d9-7657-4f9c-8072-b8af85aeb55e

Expected result:
Snapshot has been successfully created

Actual result:
Snapshot gets has an error state

Cinder volume service log file:

Jul 03 18:15:57 openstack-master-ns5-nfs cinder-volume[115495]: DEBUG cinder.volume.drivers.remotefs [req-b2011f05-d492-4509-b1eb-93562b65297f req-
7de56069-3901-4442-8d72-88753feddf61 admin None] Creating offline snapshot be7de718-87e8-4c17-b71a-83cb56c2ba7c of volume c37c17d9-7657-4f9c-8072-b
8af85aeb55e {{_create_snapshot /opt/stack/cinder/cinder/volume/drivers/remotefs.py:1621}}
...
Jul 03 18:15:58 openstack-master-ns5-nfs cinder-volume[115495]: INFO cinder.message.api [req-b2011f05-d492-4509-b1eb-93562b65297f req-7de56069-3901
-4442-8d72-88753feddf61 admin None] Creating message record for request_id = req-7de56069-3901-4442-8d72-88753feddf61
Jul 03 18:15:58 openstack-master-ns5-nfs cinder-volume[115495]: ERROR oslo_messaging.rpc.server [req-b2011f05-d492-4509-b1eb-93562b65297f req-7de56
069-3901-4442-8d72-88753feddf61 admin None] Exception during message handling: AttributeError: 'NoneType' object has no attribute 'startswith'
...
ERROR oslo_messaging.rpc.server File "/opt/stack/cinder/cinder/volume/drivers/nfs.py", line 576, in create_snapshot
ERROR oslo_messaging.rpc.server return self._create_snapshot(snapshot)
ERROR oslo_messaging.rpc.server File "/opt/stack/cinder/cinder/volume/drivers/remotefs.py", line 1626, in _create_snapshot
ERROR oslo_messaging.rpc.server if snapshot.display_name.startswith('tmp-snap-'):
ERROR oslo_messaging.rpc.server AttributeError: 'NoneType' object has no attribute 'startswith'

Workaround:
Specify a name when creating the snapshot:
$ cinder snapshot-create --name test c37c17d9-7657-4f9c-8072-b8af85aeb55e

Solution:
Parent RemoteFSSnapDriverBase._create_snapshot should check snapshot.display_name property for its value.

proposed patch:
$ git diff
diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py
index 658c25615..ebb197325 100644
--- a/cinder/volume/drivers/remotefs.py
+++ b/cinder/volume/drivers/remotefs.py
@@ -1623,7 +1623,8 @@ class RemoteFSSnapDriverBase(RemoteFSDriver):
         status = snapshot.volume.status

         acceptable_states = ['available', 'in-use', 'backing-up']
- if snapshot.display_name.startswith('tmp-snap-'):
+ if (snapshot.display_name and
+ 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.

Please let me post it on review

Thank you!

Revision history for this message
Alex Deiter (deiter) wrote :
Alex Deiter (deiter)
Changed in cinder:
assignee: nobody → Alex Deiter (deiter)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/739277

Changed in cinder:
status: New → In Progress
Alex Deiter (deiter)
summary: - Creating qcow2 snapshot on NFS backend fails
+ Creating snapshot on NFS backend fails
description: updated
Alex Deiter (deiter)
description: updated
description: updated
description: updated
Alex Deiter (deiter)
description: updated
Eric Harney (eharney)
tags: added: drivers nfs
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.opendev.org/739277
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=11b5c9d97bd69f9e8b5db0d32bfe257063170155
Submitter: Zuul
Branch: master

commit 11b5c9d97bd69f9e8b5db0d32bfe257063170155
Author: Alex Deiter <email address hidden>
Date: Fri Jul 3 18:32:54 2020 +0000

    Creating snapshot on NFS backend fails

    Fixed an issue with creating a snapshot on an NFS backend
    if the snapshot name is not specified.

    Closes-Bug: 1886222
    Change-Id: I33da9c65ef56b3e4967170e3a0fb25f12e067876

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/742581

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/ussuri)

Reviewed: https://review.opendev.org/742581
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=f23c7e8f85f3aef368d9ea83a33bdd194efc459c
Submitter: Zuul
Branch: stable/ussuri

commit f23c7e8f85f3aef368d9ea83a33bdd194efc459c
Author: Alex Deiter <email address hidden>
Date: Fri Jul 3 18:32:54 2020 +0000

    Creating snapshot on NFS backend fails

    Fixed an issue with creating a snapshot on an NFS backend
    if the snapshot name is not specified.

    Conflicts:
      cinder/tests/unit/volume/drivers/test_remotefs.py
      Encryption parameter in test method definition

    (cherry picked from commit 11b5c9d97bd69f9e8b5db0d32bfe257063170155)

    Closes-Bug: 1886222
    Change-Id: I33da9c65ef56b3e4967170e3a0fb25f12e067876

tags: added: in-stable-ussuri
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.