Skip to content
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

#8146 #8147 Support systemd named inherited file descriptors #11691

Merged
merged 24 commits into from Oct 11, 2022

Conversation

exarkun
Copy link
Member

@exarkun exarkun commented Sep 26, 2022

Scope and purpose

Fixes #8146
Fixes #8147

The unit tests for systemd.py were well-intentioned but sadly misguided (nice try though, jean-paul@2012). So I kind of rewrote them (a lot of the tests are the same but the infrastructure they fit into is better now).

@exarkun exarkun force-pushed the 8147-named-systemd-file-descriptors branch from 4243f7f to ba3ae17 Compare September 26, 2022 15:32
@exarkun exarkun changed the title #8147 Support systemd named inherited file descriptors #8146 #8147 Support systemd named inherited file descriptors Sep 26, 2022
@exarkun exarkun marked this pull request as ready for review September 26, 2022 17:02
@chevah-robot chevah-robot requested a review from a team September 26, 2022 17:03
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments.

The code looks good and as long as the tests are green it can be merged.

I am doing these reviews in "emergency" mode, trying not to block the work from @exarkun ... but I am always tired after work and not in the best shape for review.

Doing proper reviews requires a full time job, not after hours work.

Jean-Paul, I will accept this and put it back for review.

If no other Twisted dev will have time for it, I think is best to merge it.

Thanks

docs/core/howto/listings/systemd/www.example.com.socket Outdated Show resolved Hide resolved
@@ -282,7 +282,7 @@ ExecStart

The ``domain=INET`` endpoint argument makes ``twistd`` treat the inherited file descriptor as an IPv4 socket.

The ``index=0`` endpoint argument makes ``twistd`` adopt the first file descriptor inherited from ``systemd``\ .
The ``name=www`` endpoint argument makes ``twistd`` adopt the file descriptor inherited from ``systemd`` named ``www``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know where to comment.

But at line 261 we have

This configuration file contains the following important directives:

I think FileDescriptorName should be in the list.


Also at line line 272 I think the following diff is requried

-You also need to modify the ``systemd.service`` file as follows:
+You also need to modify the ``www.example.com.service`` file as follows:

And besides NonBlocking I think we also make sure the service is configured with Accept=false

Maybe false is the default value, but I think is important to make sure systemd will not spawn a separate twistd process for each connection, and will let twistd to handle the lower level networking.

docs/core/howto/systemd.rst Outdated Show resolved Hide resolved
src/twisted/python/test/strategies.py Outdated Show resolved Hide resolved
src/twisted/python/test/test_systemd.py Outdated Show resolved Hide resolved
"""
items = list(expected.items())
names = [name for name, _ in items]
descriptors = [fd for _, fd in items]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok...but when you are tired, this is harder to read, in comparison with passing a static input data.

just some feedback about hypothesis

I try to have the test code as simple as possible...as when I am refactoring something, I will see other tests failing, and then I need to read the test to see if the test is valid, or if there was a bug in the previous test itself.

src/twisted/python/systemd.py Show resolved Hide resolved
src/twisted/python/systemd.py Show resolved Hide resolved
src/twisted/python/systemd.py Show resolved Hide resolved
src/twisted/python/systemd.py Outdated Show resolved Hide resolved
@adiroiban
Copy link
Member

just asking a review from another team member to make sure I don't miss anything needs-review

@adiroiban
Copy link
Member

I think that if no other review is made in the next few days, is better to merge this.

I think this is already a bit of improvement over trunk.

Thanks for the docs updates. All the comments that I left are minor and should not block the merge.

Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks reasonable to me. I'd echo Adi in the sentiment that Hypothesis seems like overkill here, but no need to change that. Thanks!

docs/core/howto/systemd.rst Outdated Show resolved Hide resolved
@exarkun exarkun merged commit ca4ca07 into twisted:trunk Oct 11, 2022
@exarkun exarkun deleted the 8147-named-systemd-file-descriptors branch October 11, 2022 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support named systemd sockets Document non-determinism for binding systemd sockets
5 participants