From 9d931e7f7e74a991ae1c9aa99948dbc96e13ca0f Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 10 Aug 2017 16:21:20 -0400 Subject: [PATCH] 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 --- awx/main/management/commands/inventory_import.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index 03d7ccffe9..1de39baccb 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -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,