ckarnell opened a new pull request, #71671:
URL: https://github.com/apache/airflow/pull/71671

   `reap_process_group` has two sudo fallbacks for `EPERM`. The first passes a 
signal and the pids:
   
   ```python
   ["sudo", "-n", "kill", "-" + str(int(sig))] + [str(p.pid) for p in 
all_processes_in_the_group]
   ```
   
   The second, fourteen lines below, passes the process group id where the 
signal belongs and names no target at all:
   
   ```python
   subprocess.check_call(["sudo", "-n", "kill", "-" + str(process_group_id)])
   ```
   
   That builds `sudo -n kill -4242`, which `/bin/kill` rejects with a usage 
error and exit 2, so `check_call` raises `CalledProcessError` and the process 
is never signalled. The path needs `killpg` to fail with `ESRCH` and then 
`os.kill` with `EPERM`, which is the `run_as_user` case where the group has 
already gone but the process has not.
   
   Mocking both errnos and capturing the call:
   
   ```
   before: ['sudo', '-n', 'kill', '-4242']
   after:  ['sudo', '-n', 'kill', '-15', '4242']
   ```
   
   #9202 reported this in 2020 against 1.10.9 and named `reap_process_group`. 
It was closed without a fix. The line is unchanged.
   
   The added test fails on current main with `['sudo', '-n', 'kill', '-4242'] 
!= ['sudo', '-n', 'kill', '-15', '4242']` and passes with the change. 
`test_process_utils.py` goes from 27 passing to 28. It mocks the signal calls, 
so it needs no database and carries no `db_test` marker.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to