I'm asking for help with what I think is a non-trivial question that I've been trying to solve for a few weeks now.
I recently upgraded my project to Symfony 5.4. However, after deploying the project to a Kubernetes cluster, php-fpm stopped working in pods. I wrote more about this process here. I was immediately sent to look at logs, conifigs and so on, but I made sure that there was no problem with that. And here's why:
The fact is that in order to reproduce the problem, ALWAYS(!) two conditions are needed:
In all other cases, the problem does NOT(!) reproduce.
This means that if I, while in a Kubernetes cluster, rollback packages to version 4.4 and everything works fine. On the other hand, on my local machine where there is no Kubernetes cluster, after updating the project to version 5.4, php-fpm also works fine. Both configs are the same, php-fpm versions are the same. Everything is literally identical. From this I conclude that the remote configs are configured correctly and there is no fundamental incompatibility of Symfony packages with the installed fpm.
I thought that maybe not enough resources to start/update the system, but:
So, what can be the problem?
UPD:
I can watch the pod logs and I can see how my entrypoint
file is executed, by this:
After performing all migrations, the log file shows the entry [OK] Already at the latest version ("App\Migrations\Version20230427064413")
. From this I conclude that the migrations worked successfully and didn't break my application.
Cache warming up is successful, as evidenced by the line in the logs [OK] Cache for the "prod" environment (debug=false) was successfully warmed.
In the entrypoint given here I really don't use the $ php-fpm --test
command, however, I can assure you that I have run the command with the -t
flag and --debug
flag before and there were no errors. The logs show NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
.
This is my problem, yes.
My Symfony 4.4 project runs on the same base image php:8.0-fpm-alpine3.16
in exactly the same Kubernetes pod configuration, from which I conclude that OPcache is compatible with PHP version 8.0. However, to be even more sure, I commented out the lines ;opcache.preload=/var/www/app/var/cache/prod/srcCimple_KernelProdContainer.preload.php ;opcache.preload_user=www-data
in my php.ini
and the problem did not go away
UPD 2
I tried to print out the code that the php-fpm -F
command returns. The output is 0
, which indicates successful completion of the command, with no errors.
That's what I tried to do, I first separately update the recipes, prepare the code and make sure that at each step the project runs. The problem is that the project runs locally even with a fully updated Symfony. The problem with php-fpm happens as soon as I update composer update "symfony/*"
from 4.4 to 5.1 or higher. Or should I try to update packages one by one ? Is it possible ?
I left only one line in index.php
- require dirname(__DIR__).'/vendor/autoload.php;
and the problem is still there.
I was able to find out some more information about this bug: there are lines in the entrypoint
file
php-fpm -F &
nginx -g 'daemon off;' &
So, I commented out the line with nginx
and found out that php-fpm
works correctly in this case. Hence, no problem with PHP FPM as such, the problem is that the command nginx -g 'daemon off;' &
somehow blocks my fpm. Could it be related to the new rules for nginx config in Symfony 5.4 ?
I have created a new question.
The problem was that OPcache
was configured incorrectly.
However, you should be careful when checking. When I was told to turn off the JIT (OPcache)
, I just commented out the settings in php.ini
:
;opcache.preload=/var/www/app/var/cache/prod/srcCimple_KernelProdContainer.preload.php
;opcache.preload_user=www-data
But this is not enough. I also had to rebuild the project.