Skip to content

Commit

Permalink
Never transition workflows directly to canceled, add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Jul 8, 2022
1 parent a86b82d commit 5bc6146
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion awx/main/dispatch/worker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ def control(self, body):
for worker in self.pool.workers:
task = worker.current_task
if task and task['uuid'] in task_ids:
logger.warn(f'Canceling task with id={task["uuid"]}, task={task.get("task")}, args={task.get("args")}')
logger.warn(f'Sending SIGTERM to task id={task["uuid"]}, task={task.get("task")}, args={task.get("args")}')
os.kill(worker.pid, signal.SIGTERM)
msg.append(task['uuid'])
if task_ids and not msg:
logger.info(f'Could not locate running tasks to cancel with ids={task_ids}')

with pg_bus_conn() as conn:
conn.notify(reply_queue, json.dumps(msg))
Expand Down
2 changes: 2 additions & 0 deletions awx/main/management/commands/run_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def handle(self, *arg, **options):
cancel_data = yaml.safe_load(cancel_str)
except Exception:
cancel_data = [cancel_str]
if not isinstance(cancel_data, list):
cancel_data = [cancel_str]
print(Control('dispatcher').cancel(cancel_data))
return

Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def preferred_instance_groups(self):
def cancel_dispatcher_process(self):
# WorkflowJobs don't _actually_ run anything in the dispatcher, so
# there's no point in asking the dispatcher if it knows about this task
return False
return True


class WorkflowApprovalTemplate(UnifiedJobTemplate, RelatedJobsMixin):
Expand Down

0 comments on commit 5bc6146

Please sign in to comment.