-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling intelmqctl timeouts #195
Comments
In #80 (comment) @wagner-certat asks:
Yes, that would be a solution. Reading more about sudo and signals just now, it turns out that sudo |
IMHO Please don’t waste time if we can solve that significantly easier in other components at a later point time |
Well, that doesn't work. According to the manpage |
is that still relevant in intelmq-api @schacht-certat ? |
Yes, if used with sudo it is still a problem. Though splitting out the API makes it probably easier to use intelmqctl without sudo, which means setting a timeout would work. |
The PHP backend tries to make sure that the
intelmqctl
calls do nottake too long by implementing some kind of timeout. It tries two
mechanisms, which both fail to work AFAICT.
One is using PHP's
set_time_limit
function. Unfortunately, time spentexecuting subprocesses is not included in that timeout. The Note section
in https://www.php.net/manual/en/function.set-time-limit.php says:
The other method is some shell code that tries to kill the subprocess
after 20s using
kill
. This doesn't work in the usual setup where theweb-server code uses
sudo
to runintelmqctl
as theintelmq
userbecause the
kill
fails due to insufficient permissions (kill: Operation not permitted
).It would probably work when
intelmqctl
is run withoutsudo
.All this does make me wonder why the fix for #164 works, because AFAICT
it shouldn't work, and in my tests (making intelmqctl artificially slow
with a sleep)
set_time_limit
indeed doesn't cause a timeout. The killin the shell code doesn't stop the process and doesn't make PHP send the
response faster, but its error message makes the PHP code produce a 500
response.
I noticed this while working on ther Python-API (#80). The obvious way
to implement a subprocess timeout in Python is the
timeout
parameterof the subprocess module. This doesn't work for exactly the same reason
the shell approach in the PHP code doesn't work: The Python code is not
permitted to send signals to a subprocess that uses sudo.
Before I put more time into coming up with ways to implement timeouts
anyway, it's probably best to decide how important this timeout feature
actually is. Given that it doesn't work in the PHP implementation, and
doesn't seem to be a problem in practice, it seems to be acceptable for
now at least not to drop it.
The text was updated successfully, but these errors were encountered: