Skip to content

Make socket path shorter for socket_cmsg_{rights|credentials}.phpt #8617

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

Closed

Conversation

andypost
Copy link
Contributor

When running in CI it fails when path/address is longer 108 with following message

Fatal error: Uncaught ValueError: socket_bind(): Argument #2 ($address) must be less than 108 in ...

@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from 1bb6d51 to 0246874 Compare May 24, 2022 01:42
@andypost andypost marked this pull request as ready for review May 24, 2022 09:46
@cmb69
Copy link
Member

cmb69 commented May 24, 2022

Oh, indeed, these paths may be too long. I wonder whether we want to go with relative paths, though, or whether we want to use sys_get_temp_dir() as prefix. I'm not too happy with either.

@andypost
Copy link
Contributor Author

@cmb69 tmp dir also can be longer 108 chars, the great explanation I found is https://unix.stackexchange.com/a/367158

@andypost
Copy link
Contributor Author

At least inside tests dir the test runner must be able to create files, so socksts too, as I get we are not supposed to move any files while tests are running, maybe just tune socket names according test to allow parallel

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

I'm not concerned that relative filenames won't work as socket names, but rather that we would create the files in a folder relative to the CWD (so not necessarily besides the test files as usual), so the names might conflict. Not a big problem in this case, and your argument that the temporary directory might be too long makes sense.

@arnaud-lb
Copy link
Member

We could chdir() to __DIR__ in the test so that we are in a known dir

@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from 0246874 to 8e922a3 Compare May 30, 2022 20:34
@andypost
Copy link
Contributor Author

@arnaud-lb I think this is more readable

1 similar comment
@andypost
Copy link
Contributor Author

@arnaud-lb I think this is more readable

@arnaud-lb
Copy link
Member

@cmb69 I think that this addresses your concerns

@cmb69
Copy link
Member

cmb69 commented May 31, 2022

Thank you!

@cmb69 cmb69 reopened this May 31, 2022
@cmb69
Copy link
Member

cmb69 commented May 31, 2022

Ugh, the new tests apparently fail for ZTS builds; I've reverted for now.

@cmb69
Copy link
Member

cmb69 commented May 31, 2022

Hmm, I think that chdir() approach can't work due to the different CWD PHP and the OS see on ZTS builds. So either drop chdir() and stick with the relative filenames, or reconsider using the temporary directory (and skip the test if the path is too long).

@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from 8e922a3 to 47b12ce Compare May 31, 2022 18:57
@andypost
Copy link
Contributor Author

So I changed to chdir(sys_get_temp_dir()); and moved the CLEAN block to the same place as other file

@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from 47b12ce to efd234c Compare May 31, 2022 20:05
@andypost
Copy link
Contributor Author

It also fails on ZTS so only relative path works

@andypost
Copy link
Contributor Author

andypost commented Jun 1, 2022

Not clear why CI failed this time

@cmb69
Copy link
Member

cmb69 commented Jun 1, 2022

On NTS builds, chdir() calls chrdir(2), so the system knows where we are. On ZTS builds, chdir() only modifies PHP internal state, but doesn't call chdir(2). However, PHP resolves the path to the socket (file) in any case, so if the OS has a different notion of the CWD, that won't work.

@github-actions
Copy link

github-actions bot commented Aug 4, 2022

There has not been any recent activity in this PR. It will automatically be closed in 7 days if no further action is taken.

@github-actions github-actions bot added the Stale label Aug 4, 2022
@andypost
Copy link
Contributor Author

andypost commented Aug 4, 2022

@cmb69 I have no idea how to fix path for zts build

@bukka
Copy link
Member

bukka commented Aug 4, 2022

@andypost Maybe try to not use chdir and do sys_get_temp_dir() . '/socket_cmsg_credentials.sock' instead...

@cmb69
Copy link
Member

cmb69 commented Aug 4, 2022

@bukka, see #8617 (comment). :(

@bukka
Copy link
Member

bukka commented Aug 4, 2022

Well it's quite unlikely to happen in our pipeline and it's already used elsewhere and working fine:

return sys_get_temp_dir().'/'.
hash('crc32', dirname($address)).'-'.
basename($address);
. It's just a test so we don't need to account for every system setup out there IMHO...

@github-actions github-actions bot removed the Stale label Aug 5, 2022
@bukka
Copy link
Member

bukka commented Sep 29, 2022

@andypost What's the status of this? Are you happy to do the suggested change in #8617 (comment) ? As I mentioned it should be fine because we are already using that for FPM tests.

@andypost
Copy link
Contributor Author

@bukka I can change it but already faced with it in #8617 (comment)

And @cmb69 also mentioned it #8617 (comment)

@bukka
Copy link
Member

bukka commented Sep 29, 2022

@andypost Are you actually working / running test on the platform where sys_get_temp_dir() is longer than 108? What I try to say is that on such platform all our tests won't already run (specifically the FPM ones). The sys_get_temp_dir() has been there for years and no one complained about it so I assume there are not many users that would have any issue with it. So unless there's a better solution, I would just use it here as well.

@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from efd234c to e2a8892 Compare September 29, 2022 21:01
@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from e2a8892 to 36291e1 Compare September 29, 2022 21:02
@andypost
Copy link
Contributor Author

@bukka I checked both builders and CI returns /tmp for sys_get_temp_dir()

@cmb69
Copy link
Member

cmb69 commented Sep 29, 2022

Then let's go with sys_get_temp_dir(). However, I think the --CLEAN-- section should come after the --FILE-- section, not the other way round.

…edentials}.phpt

When running in CI it fails when path/address is longer 108
@andypost andypost force-pushed the socket-path-is-too-long-in-ci branch from 36291e1 to 6125d40 Compare September 29, 2022 22:58
@andypost
Copy link
Contributor Author

Fixed! hope tests will be green)

@bukka
Copy link
Member

bukka commented Sep 30, 2022

Just to clarify, where is this currently failing? Just considering what branch to merge this to. I guess if this is failing for someone already and they need to fix it, we could potentially target 8.0 but if it's just more theoretical, I might just merge it to master...

@andypost
Copy link
Contributor Author

@bukka it fails in CI when there's "home/whateber/subdir..hash" used and ext/sockets/tests/socket_cmsg_credentials.phpt itself is 46 chars

@bukka
Copy link
Member

bukka commented Sep 30, 2022

Yeah I understand when this happens. I was more asking in which pipeline this is failing as it is fine in ours... Anyway I guess it might be failing in yours pipelines so I just merged it to 8.0 ( c58241a ) as it's not a big deal to get it there anyway.

@bukka bukka closed this Sep 30, 2022
@andypost andypost deleted the socket-path-is-too-long-in-ci branch September 30, 2022 16:45
@andypost
Copy link
Contributor Author

Thank you a lot, I'm using it in Alpinelinux (it adds extra depth in builders and CI)

@andypost
Copy link
Contributor Author

andypost commented Oct 4, 2022

@bukka I faced it only on PHP 8.2 build, others works fine

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.

6 participants