-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add warning to log, when fpm socket was not registered on the expected path #11066
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
Add warning to log, when fpm socket was not registered on the expected path #11066
Conversation
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 makes sense but needs some tests.
@bukka I am happy to write some tests for it. Can you give me a reference test that I can copy or extend for my feature? |
Check this one out: https://github.com/php/php-src/blob/414f71a90254cc33896bb3ba953f979f743c198c/sapi/fpm/tests/socket-uds-numeric-ugid-nonroot.phpt . It should hopefully give you some idea. You will need to create a custom address so something with a long suffix should hopefully do. |
Hi @bukka I created two tests. One for actually running fpm and one for the test. I added a section in the upgrade notes. I am up to any wording changes :) With this I noticed I affected other tests as well. For example I broke bug68591-conf-test-listen-group.log:
I was able to unbreak it but therefore I changed code in the Tester class. This might affect more than I can grasp right now but it fights the fact on Mac the temp folder is not /tmp and therefore not a shorter but rather longer option for a socket file path. Sidenote: Are you interested in feedback on my experience as first time contributor? |
We're definitely interested in making contributions a more pleasant experience for everyone. 🙂 Let me know if there's something we can improve. |
@iluuu1994 thank you :) for taking the feedback: |
There's https://www.phpinternalsbook.com/, which is likely the most up to date resource atm. But that doesn't help much when it's linked nowhere 😄 Adding a basic contributors guide is certainly a good idea. |
Without having a detailed look into it it looks promising :D I will give it a go next time I am up to change something |
@JoshuaBehrens I created a PR here: #11155 Feel free to comment if you have any other suggestions! |
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.
The C part looks good. Just the tests need some changes (mostly smaller one - it looks good in general).
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-but-starts-anyway.phpt
Outdated
Show resolved
Hide resolved
$files = []; | ||
|
||
foreach (glob($socketFilePrefix . '*') as $file) { | ||
$files[] = $file; | ||
} |
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.
NIT: Can't you just do this:
$files = []; | |
foreach (glob($socketFilePrefix . '*') as $file) { | |
$files[] = $file; | |
} | |
$files = glob($socketFilePrefix . '*'); |
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-but-starts-anyway.phpt
Outdated
Show resolved
Hide resolved
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-but-starts-anyway.phpt
Outdated
Show resolved
Hide resolved
$socketFile = $socketFilePrefix . '-that-is-too-long-0000-1111-2222-3333-4444-5555-6666-7777-8888-9999-aaaa-bbbb-cccc-dddd-eeee-ffff-gggg-hhhh-iiii.sock'; | ||
|
||
if (is_file($socketFile)) { |
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.
is this actually correct if it creates trimmed file? It should probably glob it and delete the trimmed file, right?
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.
is this actually correct if it creates trimmed file?
this is what happens already today. I just try to make one aware of it so one can bind to the right socket
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-for-test.phpt
Outdated
Show resolved
Hide resolved
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-for-test.phpt
Outdated
Show resolved
Hide resolved
I rebased and amend the code in previous commits so it is a bit cleaner to read the history. I suggest an UPGRADE notice like:
|
70c3036
to
4396f3d
Compare
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.
Apology for slightly late review. Completely forgot about this when doing FPM stuff last month... Just some minor suggestions and one question added.
sapi/fpm/tests/gh11066-fpm-unix-socket-too-long-filename-but-starts-anyway.phpt
Outdated
Show resolved
Hide resolved
4396f3d
to
0cb3074
Compare
I rebased, amend previous commits to the given feedback. I hope I got the helper for the socket directory into a more welcome solution. I need feedback on the log type so I can amend this as well :) |
This might happen if the UDS length limit is exceeded. Co-authored-by: Jakub Zelenka <[email protected]> Closes phpGH-11066
0cb3074
to
4aa1bf9
Compare
So I have been testing this and it was actually failing due to incorrect test (the one for FPM test error check) which I needed to rewrite. Also pipeline build was failing because it requires using |
Thank you for the collaborative work and investment to get it in before the feature freeze <3 |
Trying to build for Alpinelinux getting the test to fail
|
Running within |
That's because socket maxpath is 108 chars |
I decided it to be a warning, because you can still run against the newly created socket file but fail it for the configuration test. It felt right to do it like that.
Where am I coming from?
I have an experiments folder deep down in a folder structure on my work machine (
/home/name/projects/delete-to-free-storage/experiments
). In there I cloned a project where I wanted to try out devenv for a part in a subfolder (/home/name/projects/delete-to-free-storage/experiments/foobar/php-web
). I set up devenv, it uses process-compose to orchestrate php-fpm for me and it places the php-fpm socket file in a project specific sub directory (/home/name/projects/delete-to-free-storage/experiments/foobar/php-web/.devenv/state/php-fpm/web
). When I opened up the nginx served page, all I get is a white page and nginx prints into the logdialing backend: dial unix /home/name/projects/delete-to-free-storage/experiments/foobar/php-web/.devenv/state/php-fpm/web.sock: connect: invalid argument
.So now try to debug this. You have multiple sources for this error (devenv, process-compose, nix, a nix package for php, php itself, nginx, a nix package for nginx). I was looking into to this with @jochenmanz for several days. Our question was: "Why is the file extension missing?" We were looking through the different tools but no solution
Just today I just received the message "What OS are you on and did you know that socket file names are limited in length?" After just moving the project into a directory with a shorter path, we saw, that it was working and the socket file had the .sock extension as expected. "the extension .sock was missing" is just a coincidence in after a string length cut. So we found the issue it was on binding the socket. We found some checks against in php for every socket access. But for some reason not for php-fpm. The socket will just get cut off. So I decided to fix that so have other people minds less stressed :)