don't run debug_tree for production inventory imports

the output of the `debug_tree` function is *very* verbose, and is most
useful for people who are debugging inventory import code

pexpect reads large stdout/stderr streams *very slowly*;
when verbosity is set to `DEBUG` for inventory imports, it's not
uncommon for this function to write 50MB+ of data into stderr, causing
pexpect to read over a pseudoterminal for 30+ minutes

see: https://github.com/ansible/ansible-tower/issues/7414#issuecomment-321615104
This commit is contained in:
Ryan Petrello 2017-08-10 16:21:20 -04:00
parent 0c652f2a3a
commit 9d931e7f7e

View File

@ -952,7 +952,17 @@ class Command(NoArgsCommand):
self.host_filter_re,
self.exclude_empty_groups,
self.is_custom)
self.all_group.debug_tree()
if settings.DEBUG:
# depending on inventory source, this output can be
# *exceedingly* verbose - crawling a deeply nested
# inventory/group data structure and printing metadata about
# each host and its memberships
#
# it's easy for this scale of data to overwhelm pexpect,
# (and it's likely only useful for purposes of debugging the
# actual inventory import code), so only print it if we have to:
# https://github.com/ansible/ansible-tower/issues/7414#issuecomment-321615104
self.all_group.debug_tree()
with batch_role_ancestor_rebuilding():
# Ensure that this is managed as an atomic SQL transaction,