Page MenuHomePhabricator

PHP and Scala Heroku upstream buildpacks crash if ran with the Toolforge tool uid (instead of uid=1000)
Closed, ResolvedPublic

Description

PHP: P47397
Scala: P48196

Event Timeline

Currently the default buildpack fails with:

1tools.db-names@tools-sgebastion-11:~$ kubectl logs db-names-78fb4c799b-ndxph
2cp: cannot create regular file '/app/.heroku/php/etc/php/php-cli.ini': Permission denied
3/layers/heroku_php/profile/profile.d/100-php.sh: line 19: /app/.heroku/php/etc/php/php-cli.ini: Permission denied
4/layers/heroku_php/profile/profile.d/100-php.sh: line 20: /app/.heroku/php/etc/php/php-cli.ini: Permission denied
5Detected 536870912 Bytes of RAM
6PHP memory_limit is 128M Bytes
7Starting php-fpm with 4 workers...
8Starting httpd...
9(13)Permission denied: AH00091: httpd: could not open error log file /app/.heroku/php/var/apache2/log/error_log.
10AH00015: Unable to open logs
11Process exited unexpectedly: httpd, shutting down...
12Stopping php-fpm gracefully...
13Shutdown complete.

taavi renamed this task from Toolforge Buildpacks PHP support to Several Heroku upstream buildpacks crash if ran with the Toolforge tool uid (instead of uid=1000).Thu, May 11, 2:37 PM
taavi updated the task description. (Show Details)
taavi renamed this task from Several Heroku upstream buildpacks crash if ran with the Toolforge tool uid (instead of uid=1000) to PHP and Scala Heroku upstream buildpacks crash if ran with the Toolforge tool uid (instead of uid=1000).Thu, May 11, 2:47 PM

There's some details on how to configure php from heroku, have not read it yet, pasting for future reference: https://devcenter.heroku.com/articles/custom-php-settings

There's an option to use nginx too (described in the docs there)

There's an option to use nginx too (described in the docs there)

Does not work either:

/workspace/vendor/bin/heroku-php-nginx: line 33: /workspace/vendor/heroku/heroku-buildpack-php/conf/nginx/default_include.conf: Permission denied
/workspace/vendor/bin/heroku-php-nginx: line 33: /workspace/vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf: Permission denied
Assuming 512MB of RAM
PHP memory_limit is 128M Bytes
Starting php-fpm with 4 workers...
Starting nginx...
nginx: [alert] could not open error log file: open() "/app/.heroku/php/var/log/nginx/error.log" failed (13: Permission denied)
2023/05/11 15:11:52 [emerg] 167#0: open() "/workspace/vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf" failed (2: No such file or directory) in command line
Process exited unexpectedly: nginx, shutting down...
Stopping php-fpm gracefully...
Shutdown complete.

There's some details on how to configure php from heroku, have not read it yet, pasting for future reference: https://devcenter.heroku.com/articles/custom-php-settings

Unfortunately it doesn't seem to include anything about the error logs (which are the main issue here apparently).

Hmm... maybe we can do something by passing the config file, but feels cumbersome :/

This is a workaround (not very nice) on how to change the log path:

12:28 AM <toolforge-cli-python3> ~/Work/wikimedia/heroku_tests/php-getting-started  (main|✚ 1…1) 
dcaro@vulcanus$ cat Procfile 
web: heroku-php-apache2 -C httpd.inc.conf web/
12:28 AM <toolforge-cli-python3> ~/Work/wikimedia/heroku_tests/php-getting-started  (main|✚ 1…1) 
dcaro@vulcanus$ cat httpd.inc.conf 
DirectoryIndex index.php index.html index.htm

ErrorLog /data/project/test/heroku.apache2_error.${PORT}.log
CustomLog /data/project/test/heroku.apache2_access.${PORT}.log heroku

If we set an env var with TOOL_DATA_DIR, we can then avoid harcodding the path and use something like:

12:28 AM <toolforge-cli-python3> ~/Work/wikimedia/heroku_tests/php-getting-started  (main|✚ 1…1) 
dcaro@vulcanus$ cat httpd.inc.conf 
DirectoryIndex index.php index.html index.htm

ErrorLog ${TOOL_DATA_DIR}/heroku.apache2_error.${PORT}.log
CustomLog ${TOOL_DATA_DIR}/heroku.apache2_access.${PORT}.log heroku

That would be a bit better.

The scala one seems more tricky, the problem is that the entrypoint binary is not executable except by the user:

12:35 AM <toolforge-cli-python3> ~/Work/wikimedia/heroku_tests/scala-getting-started  (main|✔) 
dcaro@vulcanus$ docker run  --rm --entrypoint bash -ti test 
heroku@845cfa035800:/workspace$ ls -la target/universal/stage/bin/scala-getting-started
-rwxr--r-- 1 heroku heroku 13426 Jan  1  1980 target/universal/stage/bin/scala-getting-started

This is a workaround (not very nice) on how to change the log path:

I can't seem to get this to work:

taavi@runko:~/src/db-names main(+1/-1)* $ cat Procfile 
web: heroku-php-apache2 -C httpd.inc.conf .
taavi@runko:~/src/db-names main(+1/-1)* $ cat httpd.inc.conf 
CustomLog /dev/stdout heroku
ErrorLog /dev/stdout
taavi@runko:~/src/db-names main(+1/-1)* $ docker run --user 51000:51000 -p 8000:8000 --rm --entrypoint web db-names
DOCUMENT_ROOT changed to './'
Using Apache2 VirtualHost-level configuration include 'httpd.inc.conf'
Assuming 512MB of RAM
PHP memory_limit is 128M Bytes
Starting php-fpm with 4 workers...
Starting httpd...
(13)Permission denied: AH00091: httpd: could not open error log file /app/.heroku/php/var/apache2/log/error_log.
AH00015: Unable to open logs
Process exited unexpectedly: httpd, shutting down...
Stopping php-fpm gracefully...
Shutdown complete.

Despite changing ErrorLog to use a custom log file it also tries to open the non-custom log file.

dcaro changed the task status from Open to In Progress.Fri, May 19, 10:43 AM
dcaro claimed this task.
dcaro moved this task from Backlog to Doing on the Toolforge Build Service (Beta release) board.

Sent https://github.com/toolforge/buildservice/pull/22, that should workaround the issue (I hope it's not a permanent fix, but unblock us for now).

Can you try it out? (you'll need to setup buildservice locally though, and build there as it has a "custom" build step that pack does not know about)

Feel free to deploy in toolsbeta to test if you want ;)

Mentioned in SAL (#wikimedia-cloud) [2023-05-24T12:26:17Z] <dcaro> deploy latest buildservice (T335865)

Mentioned in SAL (#wikimedia-cloud) [2023-05-24T12:28:45Z] <dcaro> deploy latest buildservice (T335865)

dcaro moved this task from Doing to Done on the Toolforge Build Service (Beta release) board.