Description
===========
This issue is seen in the CI more often than in real deployments, although it's possible there as well. The LVM driver may have failed creation of a share, share snapshot or a group snapshot, and the user may want to delete the failed resource. The recommended way for share drivers to handle deletion of already deleted resources is to log a warning and return to the share manager, and not fail the operation. Failing the operation will result in the resource's status being set to "error" or "error_deleting" - a state that requires administrator intervention to investigate and correct.
This applies to shares and snapshots. To reliably reproduce, you could:
1) create a manila share on the LVM driver
2) create a snapshot
3) delete the snapshot externally with "lvremove -f"
4) delete the snapshot via manila, check the manila-share log, the error is:
ERROR oslo_messaging.rpc.server Traceback (most recent call last):
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/server.py", line 165, in _process_incoming
ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/dispatcher.py", line 273, in dispatch
ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/dispatcher.py", line 193, in _do_dispatch
ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/utils.py", line 568, in wrapper
ERROR oslo_messaging.rpc.server return func(self, *args, **kwargs)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/manager.py", line 4368, in delete_share_group_snapshot
ERROR oslo_messaging.rpc.server snap_ref['name'])
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
ERROR oslo_messaging.rpc.server self.force_reraise()
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/six.py", line 703, in reraise
ERROR oslo_messaging.rpc.server raise value
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/manager.py", line 4349, in delete_share_group_snapshot
ERROR oslo_messaging.rpc.server context, snap_ref, share_server=share_server))
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/driver.py", line 1707, in delete_share_group_snapshot
ERROR oslo_messaging.rpc.server context, share_snapshot, share_server=share_server)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/drivers/lvm.py", line 435, in delete_snapshot
ERROR oslo_messaging.rpc.server share_server)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/drivers/lvm.py", line 146, in delete_snapshot
ERROR oslo_messaging.rpc.server self._deallocate_container(snapshot['name'])
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/drivers/lvm.py", line 109, in _deallocate_container
ERROR oslo_messaging.rpc.server share_name), run_as_root=True)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/driver.py", line 221, in _try_execute
ERROR oslo_messaging.rpc.server self._execute(*command, **kwargs)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/utils.py", line 101, in execute
ERROR oslo_messaging.rpc.server return processutils.execute(*cmd, **kwargs)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_concurrency/processutils.py", line 434, in execute
ERROR oslo_messaging.rpc.server cmd=sanitized_cmd)
ERROR oslo_messaging.rpc.server oslo_concurrency.processutils.ProcessExecutionError: Unexpected error while running command.
ERROR oslo_messaging.rpc.server Command: sudo manila-rootwrap /etc/manila/rootwrap.conf lvremove -f lvm-shares/share-snapshot-fb495959-052f-4c55-b901-3b3ab93089dd
ERROR oslo_messaging.rpc.server Exit code: 5
ERROR oslo_messaging.rpc.server Stdout: ''
ERROR oslo_messaging.rpc.server Stderr: ' Failed to find logical volume "lvm-shares/share-snapshot-fb495959-052f-4c55-b901-3b3ab93089dd"\n'
5) force delete the snapshot
6) unmount the lvm share and delete the share externally
7) try deleting the manila share, check manila log:
Command: sudo manila-rootwrap /etc/manila/rootwrap.conf umount -f /opt/stack/data/manila/mnt/share-d9f2c67e-e664-4116-bb90-c4732a54965b
Exit code: 32
Stdout: ''
Stderr: 'umount: /opt/stack/data/manila/mnt/share-d9f2c67e-e664-4116-bb90-c4732a54965b: not mounted.\n'
ERROR oslo_messaging.rpc.server Traceback (most recent call last):
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/server.py", line 165, in _process_incoming
ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/dispatcher.py", line 273, in dispatch
ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_messaging/rpc/dispatcher.py", line 193, in _do_dispatch
ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/manager.py", line 187, in wrapped
ERROR oslo_messaging.rpc.server return f(self, *args, **kwargs)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/utils.py", line 568, in wrapper
ERROR oslo_messaging.rpc.server return func(self, *args, **kwargs)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/manager.py", line 3095, in delete_share_instance
ERROR oslo_messaging.rpc.server exception=excep)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
ERROR oslo_messaging.rpc.server self.force_reraise()
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/six.py", line 703, in reraise
ERROR oslo_messaging.rpc.server raise value
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/manager.py", line 3070, in delete_share_instance
ERROR oslo_messaging.rpc.server share_server=share_server)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/drivers/lvm.py", line 259, in delete_share
ERROR oslo_messaging.rpc.server self._unmount_device(share)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/share/drivers/lvm.py", line 269, in _unmount_device
ERROR oslo_messaging.rpc.server self._execute('umount', '-f', mount_path, run_as_root=True)
ERROR oslo_messaging.rpc.server File "/opt/stack/manila/manila/utils.py", line 101, in execute
ERROR oslo_messaging.rpc.server return processutils.execute(*cmd, **kwargs)
ERROR oslo_messaging.rpc.server File "/usr/local/lib/python3.6/dist-packages/oslo_concurrency/processutils.py", line 434, in execute
ERROR oslo_messaging.rpc.server cmd=sanitized_cmd)
ERROR oslo_messaging.rpc.server oslo_concurrency.processutils.ProcessExecutionError: Unexpected error while running command.
ERROR oslo_messaging.rpc.server Command: sudo manila-rootwrap /etc/manila/rootwrap.conf umount -f /opt/stack/data/manila/mnt/share-d9f2c67e-e664-4116-bb90-c4732a54965b
ERROR oslo_messaging.rpc.server Exit code: 32
ERROR oslo_messaging.rpc.server Stdout: ''
ERROR oslo_messaging.rpc.server Stderr: 'umount: /opt/stack/data/manila/mnt/share-d9f2c67e-e664-4116-bb90-c4732a54965b: not mounted.\n'
ERROR oslo_messaging.rpc.server
This code path needs hardening.
Fix proposed to branch: master /review. opendev. org/743438
Review: https:/