Reduce number of iterations through PlayIterator (#74175)

* Reduce number of iterations through PlayIterator

ci_complete

* Use the new set method

ci_complete
pull/76341/head
Martin Krizek 4 years ago committed by GitHub
parent d8aeffc8b7
commit 0ddaf6edd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- Reduce number of iterations through PlayIterator (https://github.com/ansible/ansible/pull/74175)

@ -232,8 +232,7 @@ class PlayIterator(metaclass=MetaPlayIterator):
task.get_name() == play_context.start_at_task or fnmatch.fnmatch(task.get_name(), play_context.start_at_task): task.get_name() == play_context.start_at_task or fnmatch.fnmatch(task.get_name(), play_context.start_at_task):
start_at_matched = True start_at_matched = True
break break
else: self.set_state_for_host(host.name, s)
self.get_next_task_for_host(host)
# finally, reset the host's state to IteratingStates.SETUP # finally, reset the host's state to IteratingStates.SETUP
if start_at_matched: if start_at_matched:

@ -156,9 +156,9 @@ class StrategyModule(StrategyBase):
if same_tasks >= throttle: if same_tasks >= throttle:
break break
# pop the task, mark the host blocked, and queue it # advance the host, mark the host blocked, and queue it
self._blocked_hosts[host_name] = True self._blocked_hosts[host_name] = True
(state, task) = iterator.get_next_task_for_host(host) iterator.set_state_for_host(host.name, state)
try: try:
action = action_loader.get(task.action, class_only=True, collection_list=task.collections) action = action_loader.get(task.action, class_only=True, collection_list=task.collections)

@ -156,13 +156,13 @@ class StrategyModule(StrategyBase):
host_state_task = host_tasks.get(host.name) host_state_task = host_tasks.get(host.name)
if host_state_task is None: if host_state_task is None:
continue continue
(s, t) = host_state_task (state, task) = host_state_task
s = iterator.get_active_state(s) s = iterator.get_active_state(state)
if t is None: if task is None:
continue continue
if s.run_state == cur_state and s.cur_block == cur_block: if s.run_state == cur_state and s.cur_block == cur_block:
new_t = iterator.get_next_task_for_host(host) iterator.set_state_for_host(host.name, state)
rvals.append((host, t)) rvals.append((host, task))
else: else:
rvals.append((host, noop_task)) rvals.append((host, noop_task))
display.debug("done advancing hosts to next task") display.debug("done advancing hosts to next task")

Loading…
Cancel
Save