Skip to content

Conversation

@potiuk
Copy link
Member

@potiuk potiuk commented Mar 19, 2023

During refactoring of the internal API background test, it was found that the SIGKILL termination of gunicorn in case it was not responding to SIGTERM (introduced in #11734) has never been working properly. The code assumed that gunicorn_master_process was of the subprocess.Popen type and used .poll() method to check if the process is still running and it would issue sigkill in such case.

However the Process we have there is a psutil.Process and it has no poll() method - instead we can use is_running() method, which has the added advantage that is_running() is also checking if the pid has not been reused by another process after terminating the original gunicorn.

The result of it was this error:

AttributeError: 'Process' object has no attribute 'poll'

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

During refactoring of the internal API background test, it was
found that the SIGKILL termination of gunicorn in case it was not
responding to SIGTERM (introduced in apache#11734) has never been working
properly. The code assumed that gunicorn_master_process was
of the subprocess.Popen type and used .poll() method to check if the
process is still running and it would issue sigkill in such case.

However the Process we have there is a psutil.Process and it has
no poll() method - instead we can use is_running() method, which
has the added advantage that is_running() is also checking if the
pid has not been reused by another process after terminating the
original gunicorn.

The result of it was this error:

```
AttributeError: 'Process' object has no attribute 'poll'
```
@boring-cyborg boring-cyborg bot added area:CLI area:webserver Webserver related Issues labels Mar 19, 2023
@potiuk potiuk added this to the Airflow 2.5.3 milestone Mar 19, 2023
@potiuk
Copy link
Member Author

potiuk commented Mar 20, 2023

I think that one might actually fix not only the production behaviour but also the flakey test we have https://github.com/apache/airflow/actions/runs/4458374125/jobs/7833545103

@potiuk potiuk merged commit fd2db88 into apache:main Mar 20, 2023
@potiuk potiuk deleted the fix-wrong-process-for-gunicorn branch March 20, 2023 09:59
@pierrejeambrun pierrejeambrun added the type:bug-fix Changelog: Bug Fixes label Mar 22, 2023
pierrejeambrun pushed a commit that referenced this pull request Mar 24, 2023
During refactoring of the internal API background test, it was
found that the SIGKILL termination of gunicorn in case it was not
responding to SIGTERM (introduced in #11734) has never been working
properly. The code assumed that gunicorn_master_process was
of the subprocess.Popen type and used .poll() method to check if the
process is still running and it would issue sigkill in such case.

However the Process we have there is a psutil.Process and it has
no poll() method - instead we can use is_running() method, which
has the added advantage that is_running() is also checking if the
pid has not been reused by another process after terminating the
original gunicorn.

The result of it was this error:

```
AttributeError: 'Process' object has no attribute 'poll'
```

(cherry picked from commit fd2db88)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI area:webserver Webserver related Issues type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants