From ec3b7b7de87f117bebd5c314ac2ca16bc6c56b55 Mon Sep 17 00:00:00 2001 From: Tomasz Kontusz Date: Tue, 5 Jan 2016 20:19:47 +0100 Subject: [PATCH 1/2] linear strategy: don't look at tasks from the next block --- lib/ansible/plugins/strategy/linear.py | 33 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 7bb227dbaea..7b821af4e95 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -62,19 +62,32 @@ class StrategyModule(StrategyBase): num_rescue = 0 num_always = 0 - lowest_cur_block = len(iterator._blocks) - display.debug("counting tasks in each state of execution") - for (k, v) in iteritems(host_tasks): - if v is None: - continue - + host_tasks_to_run = [(host, state_task) + for host, state_task in iteritems(host_tasks) + if state_task and state_task[1]] + # Drop noops + host_tasks_to_run = [ + (host, (state, task)) + for host, (state, task) in host_tasks_to_run + if task.action != 'meta' or task.args.get('_raw_params') != 'noop' + ] + + if host_tasks_to_run: + lowest_cur_block = min( + (s.cur_block for h, (s, t) in host_tasks_to_run + if s.run_state != PlayIterator.ITERATING_COMPLETE)) + else: + # empty host_tasks_to_run will just run till the end of the function + # without ever touching lowest_cur_block + lowest_cur_block = None + + for (k, v) in host_tasks_to_run: (s, t) = v - if t is None: - continue - if s.cur_block < lowest_cur_block and s.run_state != PlayIterator.ITERATING_COMPLETE: - lowest_cur_block = s.cur_block + if s.cur_block > lowest_cur_block: + # Not the current block, ignore it + continue if s.run_state == PlayIterator.ITERATING_SETUP: num_setups += 1 From 93f37f5969685e6f566d1a03c427b01924c11038 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 6 Jan 2016 09:58:20 -0500 Subject: [PATCH 2/2] Don't drop noops from task counting code in linear strategy --- lib/ansible/plugins/strategy/linear.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 7b821af4e95..383c069b3a7 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -66,12 +66,6 @@ class StrategyModule(StrategyBase): host_tasks_to_run = [(host, state_task) for host, state_task in iteritems(host_tasks) if state_task and state_task[1]] - # Drop noops - host_tasks_to_run = [ - (host, (state, task)) - for host, (state, task) in host_tasks_to_run - if task.action != 'meta' or task.args.get('_raw_params') != 'noop' - ] if host_tasks_to_run: lowest_cur_block = min(