Closed clyso-dr closed 1 year ago
Try php -D memory_limit=1G ../../bin/console kimai:reload
yes, with -d instead of -D its working
www-data@kimai-kimai2-68c4b57fd-lgl9n:/opt/kimai/var/plugins$ php -d memory_limit=1G ../../bin/console kimai:reload
Reloading configurations ...
============================
[OK] All 40 YAML files contain valid syntax.
[OK] All 514 XLIFF files contain valid syntax.
Rebuilding your cache, please be patient ...
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
// Warming up the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully warmed.
[OK] Kimai config was reloaded
added docs for the next one #427
But I get the memory error also on the start up of the container not only by the reload.
https://tobybatch.github.io/kimai2/runtime-args.html#runtime-arguments
If 512M is not sufficient, something is wrong.
Its 256M:
www-data@kimai-kimai2-68c4b57fd-lgl9n:/opt/kimai/var/plugins$ env | grep memory
memory_limit=256
And if I do this with 256M its working, with 128 not:
www-data@kimai-kimai2-68c4b57fd-lgl9n:/opt/kimai/var/plugins$ php -d memory_limit=256M ../../bin/console kimai:reload
Reloading configurations ...
============================
[OK] All 40 YAML files contain valid syntax.
[OK] All 514 XLIFF files contain valid syntax.
Rebuilding your cache, please be patient ...
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
// Warming up the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully warmed.
[OK] Kimai config was reloaded
With 128M:
www-data@kimai-kimai2-68c4b57fd-lgl9n:/opt/kimai/var/plugins$ php -d memory_limit=128M ../../bin/console kimai:reload
Reloading configurations ...
============================
[OK] All 40 YAML files contain valid syntax.
[OK] All 514 XLIFF files contain valid syntax.
Rebuilding your cache, please be patient ...
// Clearing the cache for the dev environment with debug true
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/kimai/var/cache/de_/twig/1e/1e5e0c3831f3cffe97cf0bbb29bf4ede.php on line 87
[2022-11-07 12:33:35] php.CRITICAL: Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\OutOfMemoryError(code: 0): Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) at /opt/kimai/var/cache/de_/twig/1e/1e5e0c3831f3cffe97cf0bbb29bf4ede.php:87)"} []
12:33:35 CRITICAL [php] Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) ["exception" => Symfony\Component\ErrorHandler\Error\OutOfMemoryError^ { …}]
In 1e5e0c3831f3cffe97cf0bbb29bf4ede.php line 87:
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes)
kimai:reload [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
So as I said by opening the ticket, the feature is not working...
@clyso-dr which kimai image are you using?
container version: apache-latest (1.28.1)
I don't use helm to start containers but it seems to work on the CLI. Could you confirm that if your run the same command you see the same outcome.
tobias@tobias:~$ docker run --rm -ti -e memory_limit=512 --entrypoint /bin/bash kimai/kimai2:apache-latest
Unable to find image 'kimai/kimai2:apache-latest' locally
apache-latest: Pulling from kimai/kimai2
4b7b4a8876e2: Already exists
... snipped ...
804217f9c0ce: Pull complete
Digest: sha256:c40f2b5edc14579de187db1e7fb82bdbf07e1ae0f6d1e08bdc281348b4033f1f
Status: Downloaded newer image for kimai/kimai2:apache-latest
www-data@6d4c41c76ea1:~/html$ env | grep memory_limit
memory_limit=512
www-data@6d4c41c76ea1:~/html$
That we do not miss understand us, the variable is there and I added the feature to adjust it via the helm chart (https://github.com/robjuz/helm-charts/pull/26/files) so this is working, I just added 256M instead of 512M but the php of the container is still using 128M, expect I set manually "php -d....". So variable is there but without function in my perspective.
www-data@kimai-kimai2-68c4b57fd-lgl9n:/opt/kimai/var/plugins$ env | grep memory
memory_limit=256
So I'd guess that this is an issue with how the helm chart is starting the container. When it starts using the native docker daemon it correctly sets the env variable and the docker memory limit.
I don't use helm to deploy images so don't really know but it looks like that sets the virtual machine memory limit for php, the container also tries to set it's limit: https://github.com/tobybatch/kimai2/blob/main/assets/startup.sh#L39
Can you try passing the equivalent of -e memory_limit=512
How do you pass in other environment settings, like DATABASE_URL? Could it me that as memory_limit
mirrors the php setting name it is being masked during tear up?
We could try a dev build that used KIMAI_MEMORY_LIMIT
instead of memory_limit
DATABASE_URL is a secret and will be also set as environment variable in the container as everything else. (https://github.com/robjuz/helm-charts/blob/master/charts/kimai2/templates/secret.yaml)
$ env | grep DATA
DATABASE_URL=mysql://USER:PASSWORD@kimai-mariadb/kimai
On the helm chart its always values.yaml -> configmap or secret -> environment variable
So your secrets look something like
{{- if not .Values.existingSecret -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kimai2.name" . }}-secret
labels:
{{- include "kimai2.labels" . | nindent 4 }}
type: Opaque
stringData:
ADMINPASS: {{ .Values.kimaiAdminPassword }}
APP_SECRET: {{ .Values.kimaiAppSecret }}
DATABASE_URL: {{ include "kimai2.databaseUrl" . }}
MAILER_URL: {{ .Values.kimaiMailerUrl }}
memory_limit: 512
{{- end -}}
Is that right?
No because it must not be secure so it will just set as environment variabel ... but I think I found the problem:
/startup.sh: line 42: /usr/local/etc/php/php.ini: Permission denied
Because the container is running as www-data and the file permission is root:
www-data@kimai-kimai2-5b8b976f-5b7ff:/$ ls -la /usr/local/etc/php/php.ini
-rw-r--r-- 1 root root 72909 Oct 30 11:40 /usr/local/etc/php/php.ini
Maybe as idea - Example 1 php.ini Environment Variables: https://www.php.net/manual/en/configuration.file.php#example-36
Yes, you can totally override the php ini files my mounting your own. In fact that will be the wuickest way to fix this issue. I'm going to need to re-think how the container starts before I can both; override system config files, and run as a delegated user. Ironically this used to the how we advised containers to be set up.
i solved this problem by copying the content of the container php.ini
to a php.ini
located in my home directory of the docker compose. than i mounted this php.ini
to /usr/local/etc/php/php.ini
inside the container. i changed the memory limit to 512M.
that do the trick. it works with docker-compose and also on the truenas scale truechart.
@leuchtrakete666 Yes, thanks. That would work with any file you wanted to override.
Maybe as idea - Example 1 php.ini Environment Variables: https://www.php.net/manual/en/configuration.file.php#example-36
We changed it to use the above solution. Works good for us.
The memory_limit
has to be changed to 256M
, because the environment variable will be read as is.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This does work in the current build:
phpinfo.php
file<?php
phpinfo();
environment:
- ADMINMAIL=admin@kimai.local
- memory_limit=512
...
phpinfo.php
filedocker cp phpinfo.php CONTAINERNAME:/opt/kimai/publid/phpinfo.php
Describe the bug The environment variable does not work.
To Reproduce
Desktop (please complete the following information):
Command used to run the container