2050 Configured sendmail in dev / ci environments to return immediate…#2055
2050 Configured sendmail in dev / ci environments to return immediate…#2055osaerdna wants to merge 7 commits into
Conversation
…ly instead of trying to send mail
|
Very nice profiling to find out the bottleneck! But I do think it would be nice to check with logic wether mail is configured instead before sending an email. The thing is that it is not a requirement for a production setup to have mail configured, so then they will run into this bottleneck. Probably the easiest way would be to check the existence of the ssmtp.conf file. But if you can find another solution that would be good aswell |
|
I have had a look at it and I cant seem to find a good way that satisfies all scenarios, the One could check the actual configuration in the Another potential check would be to look at our configuration values, the Maybe an easy solution would be to add an email notification on and off switch in the settings, Thoughts are welcome |
|
I went with @jessevz s idea about checking the ssmtp.conf existence. For that to work the container image build Dockerfile do install the ssmtp program but removes the default configuration file, the assumption is that if you have mail configured you probably mounted the real config into /etc/ssmtp/ directory at container start. The unit tests cover this change, for the |
|
|
||
| # Install composer | ||
| COPY composer.json ${HASHTOPOLIS_DOCUMENT_ROOT}/../ | ||
| COPY composer.json composer.lock ${HASHTOPOLIS_DOCUMENT_ROOT}/../ |
There was a problem hiding this comment.
I am actually not sure about this change, I merged dev branch and had problems getting ci to build properly. Advice appreciated, it seems using the lock would prevent unstable builds?
There was a problem hiding this comment.
Ah yes I think we forgot to actually copy the .lock file before installing. the .lock file is so that we have reproducable builds and no change in dependencies until we update the .lock file
…ly instead of trying to send mail
I did notice that the user creation was somewhat slow in my dev environment, a profile of the request gave
...
800,815,612 (95.49%) 2,152 ( 0.09%) /var/www/html/src/inc/Util.php:Hashtopolis\inc\Util::sendMail
800,811,639 (95.49%) 880 ( 0.04%) php:internal:php::mail
21,322,474 ( 2.54%) 296 ( 0.01%) /var/www/html/src/inc/Encryption.php:Hashtopolis\inc\Encryption::passwordHash
21,319,117 ( 2.54%) 96 ( 0.00%) php:internal:php::password_hash
7,164,671 ( 0.85%) 402,800 (16.43%) /var/www/html/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php:Slim\Middleware\RoutingMiddleware->performRouting
...
Which I interpret as lots of time is spent in php:internal:php::mail. Since I don't have any sendmail config in my environment I guess it tries with default config and traps waiting for something.
I guess that we don't see this in many production environments since most of them probably have mail configured correctly and then there is not much time taken for the send to complete.
About the fix, I took what I got from copilot, now we configure the environments (devcontainers and ci) to use /bin/true to simulate successful mail sending. I guess there are cases where we really would like the email to be sent and verified but that might be the exception and then will require some specific mail configuration to be done.
Profiling after the fix the send mail function is not noticed as significant enough to report (my guess) and the integration tests in
test_user.pyis faster to run, and my local setup of server / web-ui is runs with expected latency.