-
Notifications
You must be signed in to change notification settings - Fork 24k
Skip forking on a task with a simple when condition or include #70477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
raise ForkShortCircuit(tr) | ||
|
||
def _short_circuit_fork_include(self, host, task, task_vars, templar): | ||
vars_copy = task_vars.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to do the copy in the if statement. Not sure how expensive this operation is but I would have thought task_vars
could be quite large if the host has a lot of vars/facts set on it.
@@ -207,6 +207,9 @@ | |||
become: yes | |||
shell: "echo 'SHOW SERVER_VERSION' | psql --tuples-only --no-align --dbname postgres" | |||
register: postgres_version_resp | |||
until: postgres_version_resp is successful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this meant to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done because the speedup we get from this results in postgres not having enough time to start up. If this ever merges, I think this incidental test will be removed by then.
include_args = task.args.copy() | ||
include_file = include_args.pop('_raw_params', None) | ||
if not include_file: | ||
tr = TaskResult( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You set tr
here but don't do anything with it. The code will just continue along and probably fail at 366 include_file = templar.template(include_file)
because include_file
is None.
8f6d77c
to
a47d343
Compare
SUMMARY
This PR does a conditional evaluation on tasks that do not have loops, and skips forking if the task should be skipped, or if the task is an include.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
Using a playbook with an
import_tasks
andwhen: false
with 100ping
tasks:With this PR:
Without:
A playbook that I have that does 100 recursive task includes (also does some
debug
andset_fact
):With this PR:
Without: