ashb commented on a change in pull request #6026: [AIRFLOW-5419] - Marking task failed doesn't kill the task when it is run through impersonation URL: https://github.com/apache/airflow/pull/6026#discussion_r321656029
########## File path: airflow/utils/helpers.py ########## @@ -305,6 +305,9 @@ def on_terminate(p): except OSError as err: if err.errno == errno.ESRCH: return + # If operation not permitted error is thrown due to run_as_user, use sudo to kill the process + if err.errno == errno.EPERM: + os.system('sudo kill -' + str(sig) + ' ' + str(os.getpgid(pid))) Review comment: Two things: 1. Add `−-non-interactive` to the command line - we don't ever want to prompt for a password (as there's no user to give it) 2. Instead of using `os.system` and passing it a string we should use subprocess with an array: https://docs.python.org/2/library/subprocess.html#replacing-bin-sh-shell-backquote ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services