HyperV: remove instance snapshot lock

At the moment, the instance snapshot operation is synchronized using
the instance uuid. This was added some time ago, as the instance
destroy operation was failing when an instance snapshot was in
proggress.

This is now causing a deadlock, as a similar lock was recently
introduced in the manager for the shelve operation by this change:
Id36b3b9516d72d28519c18c38d98b646b47d288d

We can safely remove the lock from the HyperV driver as we now stop
pending jobs when destroying instances.

Closes-Bug: #1611321

Change-Id: I1c2ca0d24c195ebaba442bbb7091dcecc0a7e781
This commit is contained in:
Lucian Petrut 2016-08-09 13:21:48 +03:00
parent e6a05382bd
commit c7af24ca82
2 changed files with 0 additions and 33 deletions

View File

@ -16,10 +16,8 @@
import os
import mock
from os_win import exceptions as os_win_exc
from nova.compute import task_states
from nova import exception
from nova.tests.unit import fake_instance
from nova.tests.unit.virt.hyperv import test_base
from nova.virt.hyperv import snapshotops
@ -121,18 +119,3 @@ class SnapshotOpsTestCase(test_base.HyperVBaseTestCase):
def test_snapshot_no_base_disk(self):
self._test_snapshot(base_disk_path=None)
@mock.patch.object(snapshotops.SnapshotOps, '_snapshot')
def test_snapshot_instance_not_found(self, mock_snapshot):
mock_instance = fake_instance.fake_instance_obj(self.context)
mock_snapshot.side_effect = os_win_exc.HyperVVMNotFoundException(
vm_name=mock_instance.name)
self.assertRaises(exception.InstanceNotFound,
self._snapshotops.snapshot,
self.context, mock_instance, mock.sentinel.image_id,
mock.sentinel.update_task_state)
mock_snapshot.assert_called_once_with(self.context, mock_instance,
mock.sentinel.image_id,
mock.sentinel.update_task_state)

View File

@ -18,15 +18,12 @@ Management class for VM snapshot operations.
"""
import os
from os_win import exceptions as os_win_exc
from os_win import utilsfactory
from oslo_log import log as logging
from nova.compute import task_states
from nova import exception
from nova.i18n import _LE
from nova.image import glance
from nova import utils
from nova.virt.hyperv import pathutils
LOG = logging.getLogger(__name__)
@ -49,19 +46,6 @@ class SnapshotOps(object):
purge_props=False)
def snapshot(self, context, instance, image_id, update_task_state):
# While the snapshot operation is not synchronized within the manager,
# attempting to destroy an instance while it's being snapshoted fails.
@utils.synchronized(instance.uuid)
def instance_synchronized_snapshot():
self._snapshot(context, instance, image_id, update_task_state)
try:
instance_synchronized_snapshot()
except os_win_exc.HyperVVMNotFoundException:
# the instance might disappear before starting the operation.
raise exception.InstanceNotFound(instance_id=instance.uuid)
def _snapshot(self, context, instance, image_id, update_task_state):
"""Create snapshot from a running VM instance."""
instance_name = instance.name