Make CELL_TIMEOUT a constant
This unifies the various places that hard-code a 60-second timeout for cells scatter/gather operations use a constant instead. Change-Id: I77d719ca4588bf273271e4f138f53d09c7d3e330
This commit is contained in:
parent
df3dd2b5c7
commit
b7c3dd8682
@ -65,7 +65,7 @@ class ExtendedVolumesController(wsgi.Controller):
|
||||
|
||||
bdms = {}
|
||||
results = context.scatter_gather_cells(
|
||||
ctxt, cell_mappings.values(), 60,
|
||||
ctxt, cell_mappings.values(), context.CELL_TIMEOUT,
|
||||
objects.BlockDeviceMappingList.bdms_by_instance_uuid,
|
||||
instance_uuids)
|
||||
for cell_uuid, result in results.items():
|
||||
|
@ -254,7 +254,8 @@ class CrossCellLister(object):
|
||||
# TODO(tssurya): Modify this to return the minimal available info from
|
||||
# the down cells.
|
||||
if self.cells:
|
||||
results = context.scatter_gather_cells(ctx, self.cells, 60,
|
||||
results = context.scatter_gather_cells(ctx, self.cells,
|
||||
context.CELL_TIMEOUT,
|
||||
do_query)
|
||||
else:
|
||||
results = context.scatter_gather_all_cells(ctx, do_query)
|
||||
|
@ -52,6 +52,8 @@ raised_exception_sentinel = object()
|
||||
# first time we look. This needs to be refreshed on a timer or
|
||||
# trigger.
|
||||
CELLS = []
|
||||
# Timeout value for waiting for cells to respond
|
||||
CELL_TIMEOUT = 60
|
||||
|
||||
|
||||
class _ContextAuthPlugin(plugin.BaseAuthPlugin):
|
||||
@ -485,9 +487,9 @@ def load_cells():
|
||||
def scatter_gather_skip_cell0(context, fn, *args, **kwargs):
|
||||
"""Target all cells except cell0 in parallel and return their results.
|
||||
|
||||
The first parameter in the signature of the function to call for each cell
|
||||
should be of type RequestContext. There is a 60 second timeout for waiting
|
||||
on all results to be gathered.
|
||||
The first parameter in the signature of the function to call for
|
||||
each cell should be of type RequestContext. There is a timeout for
|
||||
waiting on all results to be gathered.
|
||||
|
||||
:param context: The RequestContext for querying cells
|
||||
:param fn: The function to call for each cell
|
||||
@ -502,16 +504,16 @@ def scatter_gather_skip_cell0(context, fn, *args, **kwargs):
|
||||
"""
|
||||
load_cells()
|
||||
cell_mappings = [cell for cell in CELLS if not cell.is_cell0()]
|
||||
return scatter_gather_cells(context, cell_mappings, 60, fn, *args,
|
||||
**kwargs)
|
||||
return scatter_gather_cells(context, cell_mappings, CELL_TIMEOUT,
|
||||
fn, *args, **kwargs)
|
||||
|
||||
|
||||
def scatter_gather_all_cells(context, fn, *args, **kwargs):
|
||||
"""Target all cells in parallel and return their results.
|
||||
|
||||
The first parameter in the signature of the function to call for each cell
|
||||
should be of type RequestContext. There is a 60 second timeout for waiting
|
||||
on all results to be gathered.
|
||||
The first parameter in the signature of the function to call for
|
||||
each cell should be of type RequestContext. There is a timeout for
|
||||
waiting on all results to be gathered.
|
||||
|
||||
:param context: The RequestContext for querying cells
|
||||
:param fn: The function to call for each cell
|
||||
@ -525,4 +527,5 @@ def scatter_gather_all_cells(context, fn, *args, **kwargs):
|
||||
exception will be logged.
|
||||
"""
|
||||
load_cells()
|
||||
return scatter_gather_cells(context, CELLS, 60, fn, *args, **kwargs)
|
||||
return scatter_gather_cells(context, CELLS, CELL_TIMEOUT,
|
||||
fn, *args, **kwargs)
|
||||
|
@ -623,7 +623,8 @@ class HostManager(object):
|
||||
return services, objects.ComputeNodeList.get_all_by_uuids(
|
||||
cctxt, compute_uuids)
|
||||
|
||||
results = context_module.scatter_gather_cells(context, cells, 60,
|
||||
timeout = context_module.CELL_TIMEOUT
|
||||
results = context_module.scatter_gather_cells(context, cells, timeout,
|
||||
targeted_operation)
|
||||
compute_nodes = collections.defaultdict(list)
|
||||
services = {}
|
||||
|
Loading…
Reference in New Issue
Block a user