From d6e39376c84d4d6f62ea6c5ea92ff588ccc42bc4 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 22 Oct 2020 11:27:21 -0400 Subject: [PATCH] Improve handling of 0 and negative thresholds in the profile_sql command - output a profiling disabled message when appropriate - specify that we are doing SQL profiling in the enabled case - treat negative thresholds the same as zero, disabling profiling --- awx/main/management/commands/profile_sql.py | 10 ++++++---- awx/main/tasks.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/awx/main/management/commands/profile_sql.py b/awx/main/management/commands/profile_sql.py index 5bbc4c80ca..585fb3d706 100644 --- a/awx/main/management/commands/profile_sql.py +++ b/awx/main/management/commands/profile_sql.py @@ -19,7 +19,9 @@ class Command(BaseCommand): profile_sql.delay( threshold=options['threshold'], minutes=options['minutes'] ) - print(f"Logging initiated with a threshold of {options['threshold']} second(s) and a duration of" - f" {options['minutes']} minute(s), any queries that meet criteria can" - f" be found in /var/log/tower/profile/." - ) + if options['threshold'] > 0: + print(f"SQL profiling initiated with a threshold of {options['threshold']} second(s) and a" + f" duration of {options['minutes']} minute(s), any queries that meet criteria can" + f" be found in /var/log/tower/profile/.") + else: + print("SQL profiling disabled.") diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 0e03055055..19669a0f27 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -313,7 +313,7 @@ def delete_project_files(project_path): @task(queue='tower_broadcast_all') def profile_sql(threshold=1, minutes=1): - if threshold == 0: + if threshold <= 0: cache.delete('awx-profile-sql-threshold') logger.error('SQL PROFILING DISABLED') else: