Allow limitting concurrent image ops

Nova defines a config option that allows limitting concurrent
image operations. This behavior is disabled by default.

The threshold is enforced using a semaphore, which we're now going
to use.

As opposed to the libvirt driver, we're not applying the semaphore
when merging differencing images since that would have a larger
impact on the hyper-v driver (e.g. when resizing legacy vhd images,
when deleting temporary snapshots, etc). For now, we're using it
only when downloading or uploading glance images.

Change-Id: I74ecf4b343428c71aad77b049faa5d2382e88dc8
blueprint: io-semaphore-for-concurrent-disk-ops
This commit is contained in:
Lucian Petrut 2020-02-11 14:08:35 +02:00
parent b3636915d7
commit b69b91df5c
2 changed files with 11 additions and 5 deletions

View File

@ -18,6 +18,7 @@ Image caching and management.
import os
import re
from nova.compute import utils as compute_utils
from nova import exception
from nova import utils
from nova.virt import imagecache
@ -146,9 +147,11 @@ class ImageCache(imagecache.ImageCacheManager):
if not image_path:
try:
images.fetch(context, image_id, base_image_path,
trusted_certs)
fetched = True
with compute_utils.disk_ops_semaphore:
images.fetch(context, image_id, base_image_path,
trusted_certs)
fetched = True
if image_type == 'iso':
format_ext = 'iso'
else:

View File

@ -19,6 +19,7 @@ Management class for VM snapshot operations.
import os
from nova.compute import task_states
from nova.compute import utils as compute_utils
from nova import exception
from nova.image import glance
from nova import utils
@ -46,8 +47,10 @@ class SnapshotOps(object):
image_metadata = {"disk_format": image_format,
"container_format": "bare"}
with self._pathutils.open(image_vhd_path, 'rb') as f:
glance_image_service.update(context, image_id, image_metadata, f,
purge_props=False)
with compute_utils.disk_ops_semaphore:
glance_image_service.update(context, image_id,
image_metadata, f,
purge_props=False)
def snapshot(self, context, instance, image_id, update_task_state):
# This operation is not fully preemptive at the moment. We're locking