Skip to content

Commit e2705cc

Browse files
committed
Allow num < num_proc.
1 parent 5f32e44 commit e2705cc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Options:
3737

3838
--num NUM: How many compute nodes to udpate, 0 means all. Default is 0.
3939

40-
--num_proc NUM_PROC: Maximum subprocess allowed to launch to mimic the nova-compute updates.
40+
--num_proc NUM_PROC: Number of subprocesses to launch to mimic the nova-compute updates.
4141
Each subprocess will update the number of NUM/NUM_PROC compute nodes
4242
at a periodic interval of 60/NUM_PROC seconds. Default is 100.
4343

novadbtest-compute.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
' (Disable by setting to 0)'),
9191
cfg.IntOpt('num_proc',
9292
default=100,
93-
help='maximum allowed subprocess to launch to mimic the nova-compute updates.'
93+
help='number of subprocess to launch to mimic the nova-compute updates.'
9494
'each subprocess will update num/num_proc number of compute nodes'
9595
'at a periodic interval of 60/num_proc'),
9696
cfg.IntOpt('start',
@@ -211,6 +211,7 @@ def _statmap(stats):
211211
num = total
212212
if start <= 0:
213213
start = 0
214+
maximum_data = num / CONF.num_proc or 1
214215

215216
print "# of compute nodes total: %d" % total
216217
print "# of compute nodes to update: %d" % num
@@ -234,13 +235,17 @@ def _statmap(stats):
234235
datas.append((compute_ref, values))
235236

236237
#prepare for the update process
237-
if len(datas) >= num / CONF.num_proc and len(procs) < CONF.num_proc - 1:
238-
p = Process(target=mimic_update, args=(copy.deepcopy(datas), _get_initial_delay()))
238+
if len(datas) == maximum_data and len(procs) < CONF.num_proc - 1:
239+
initial_delay = _get_initial_delay()
240+
p = Process(target=mimic_update, args=(copy.deepcopy(datas), initial_delay))
239241
procs.append(p)
242+
LOG.debug("Prepare new subprocess for %d nodes, initial_dealy %d", len(datas), initial_delay)
240243
datas = []
241244
#remaining data
242245
if len(datas):
243-
p = Process(target=mimic_update, args=(copy.deepcopy(datas), _get_initial_delay()))
246+
initial_delay = _get_initial_delay()
247+
p = Process(target=mimic_update, args=(copy.deepcopy(datas), initial_delay))
248+
LOG.debug("Prepare new subprocess for %d nodes, initial_dealy %d", len(datas), initial_delay)
244249
procs.append(p)
245250
datas = []
246251

0 commit comments

Comments
 (0)