Skip to content

Commit

Permalink
Fix sloppy initialization of the new disk ops semaphore.
Browse files Browse the repository at this point in the history
Some tests weren't calling init_host, so the semaphore was None.
This caused the smoke to come out of nova's tests in ways that
would be less confusing if they'd failed during the testing of
the implementing patch.

Instead, set the semaphore to being unbounded, and then override
that later if the user has in fact specified a limit. This relies
on init_host being called very early, but that should be true
already.

Change-Id: If144be253f78b14cef60200a46aefc02c0e19ced
Closes-Bug: #1806123
  • Loading branch information
mikalstill committed Dec 2, 2018
1 parent 288c537 commit 1e8c2c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions nova/compute/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,14 +1192,12 @@ def init_host(self):

nova.conf.neutron.register_dynamic_opts(CONF)

# one-time initialization
# Override the number of concurrent disk operations allowed if the
# user has specified a limit.
if CONF.compute.max_concurrent_disk_ops != 0:
compute_utils.disk_ops_semaphore = \
eventlet.semaphore.BoundedSemaphore(
CONF.compute.max_concurrent_disk_ops)
else:
compute_utils.disk_ops_semaphore = \
compute_utils.UnlimitedSemaphore()

self.driver.init_host(host=self.host)
context = nova.context.get_admin_context()
Expand Down
11 changes: 6 additions & 5 deletions nova/compute/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
CONF = nova.conf.CONF
LOG = log.getLogger(__name__)

# This semaphore is used to enforce a limit on disk-IO-intensive operations
# (image downloads, image conversions) at any given time.
# It is initialized at ComputeManager.init_host()
disk_ops_semaphore = None


def exception_to_dict(fault, message=None):
"""Converts exceptions to a dict for use in notifications."""
Expand Down Expand Up @@ -1176,6 +1171,12 @@ def balance(self):
return 0


# This semaphore is used to enforce a limit on disk-IO-intensive operations
# (image downloads, image conversions) at any given time.
# It is initialized at ComputeManager.init_host()
disk_ops_semaphore = UnlimitedSemaphore()


@contextlib.contextmanager
def notify_about_instance_delete(notifier, context, instance,
delete_type='delete',
Expand Down

0 comments on commit 1e8c2c0

Please sign in to comment.