-
Notifications
You must be signed in to change notification settings - Fork 96
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
Socket activation and systemd supervision #171
Conversation
fwiw, i think the travis CI test is failing because the test wants to listen on port 8025 when something else (maybe another test) is already listening on it. i don't think that failure is due to any of the changes proposed here. |
Hi @dkg, thanks for the contribution! Have you run these tests locally? My experience is that there's no such thing as unrelated test failures. Either the tests are poorly written or the code has side effects that weren't accounted for. I'm thinking that might be the case here, as I haven't seen this error show up before... but I could be wrong! |
d293dee
to
cae5c06
Compare
@waynew -- you were right, somehow i'd mixed up my local tests. I've just pushed a fix (my changes to Looks like |
aiosmtpd/main.py
Outdated
loop.create_server(factory, host=args.host, port=args.port)) | ||
if args.supervised: | ||
log.info('Server listening on socket-activated file descriptor') | ||
stage = loop.create_server(factory, sock=socket.fromfd(3, socket.AF_INET, socket.SOCK_STREAM)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these are the lines that aren't actually getting tested, according to what I can glean from Travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just tried to add tests to exercise that code, but i'm not sure whether they are what you want. please let me know if you'd rather they were done differently! |
@dkg I think that fits with the existing pattern, so it seems reasonable to me. Looks like there are a couple of more problems though: https://travis-ci.com/aio-libs/aiosmtpd/jobs/248965906#L487 |
95c4744
to
f2bc73e
Compare
@waynew -- i've fixed the flake complaints, but i don't understand the coverage complaint:
looking at the relevant lines in
i don't understand this for two reasons:
|
9e4dedb
to
dfe3636
Compare
OK, flake complaints are all actually fixed now, but i'm stumped on how to get this additional coverage, because it looks like it should already be covered to me. If you can help me understand the coverage test suite better, i'd be happy to take pointers. |
@waynew, any hints ? |
The overlap is because there are two branches there - neither is getting exercised. Which tests should be exercising that code? I'm not seeing anything... |
systemd-style socket-activation is a nice safe way to launch a process that is already unprivileged. It works by the parent process opening a socket, and then doing its own privilege dropping. This means the child process starts with an already-listening file descriptor, but no elevated privileges. To make use of this, the user needs to be able to pass an existing socket to the aiosmtpd controller. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
We only try to test --supervised on non-Windows platforms. This uses the strategy outlined in sd_listen_fds(), where file descriptor 3 is the first socket passed in. I chose an arbitrary different port (19666) to make sure that the right socket is getting through.
dfe3636
to
7320bc4
Compare
if the branch from 39-44 is not getting exercised at all, then surely none of the sub-branches within it are being exercised. so either i would expect no sub-branches to be listed, or both sub-branches to be listed. but instead, only the 42-44 sub-branch is listed, and the 40-41 sub-branch is not listed. This makes me doubt my understanding of the report :/ Anyway, the two cases identified are in
But Sorry if i'm asking obvious questions -- feel free to point me to answers even if they're things that you think i should already know. |
You're doing fine 🙂 I'm not super familiar with those tests myself. What I would do is run the tests I'm expecting to hit that code, and perhaps throw |
|
This is an old PR, more than 6 months old, only brought up recently due to CLAassistant. Is there desire to continue with this PR? If not, I will close this. |
Note to anyone wanting to implement similar functionality, either by picking up this PR or submitting a new one: I'm -1 on changing If Adding a new class will also make merging much easier :-) |
Okay, no activities for more than 3 weeks. I'm closing this PR for now. If anyone wants to pick this up, feel free to reopen. |
Please consider these changes to enable eaiser integration of aiosmtpd implementations with systemd and other comparable systems.