From 5be53d4a79ca67c90c3a7f1a14b1e717d8760a65 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 28 Sep 2015 15:43:46 -0400 Subject: [PATCH 1/2] Add a sleep step to job runs if configured If the extra var PEXPECT_SLEEP is given to a job then it will artificially delay the job run by that number of seconds allowing QA to hook in and cancel the job --- awx/main/tasks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index e91259f249..b92b965dd8 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -425,6 +425,9 @@ class BaseTask(Task): ''' logfile = stdout_handle logfile_pos = logfile.tell() + if hasattr(instance, "extra_vars_dict") and "PEXPECT_SLEEP" in instance.extra_vars_dict: + logger.info("Suspending Job Execution for QA Work") + time.sleep(int(instance.extra_vars_dict["PEXPECT_SLEEP"])) child = pexpect.spawnu(args[0], args[1:], cwd=cwd, env=env) child.logfile_read = logfile canceled = False From 29b4865af8ff4531f465a2c279d0182a0aca0995 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 29 Sep 2015 11:36:31 -0400 Subject: [PATCH 2/2] Ability to pause pexpect output with env var Since inventory updates don't support extra vars --- awx/main/tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index b92b965dd8..ac4f3006a9 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -426,8 +426,14 @@ class BaseTask(Task): logfile = stdout_handle logfile_pos = logfile.tell() if hasattr(instance, "extra_vars_dict") and "PEXPECT_SLEEP" in instance.extra_vars_dict: + pexpect_sleep = int(instance.extra_vars_dict['PEXPECT_SLEEP']) + elif 'PEXPECT_SLEEP' in os.environ: + pexpect_sleep = int(os.environ['PEXPECT_SLEEP']) + else: + pexpect_sleep = None + if pexpect_sleep is not None: logger.info("Suspending Job Execution for QA Work") - time.sleep(int(instance.extra_vars_dict["PEXPECT_SLEEP"])) + time.sleep(pexpect_sleep) child = pexpect.spawnu(args[0], args[1:], cwd=cwd, env=env) child.logfile_read = logfile canceled = False