tobybatch / kimai2

Docker containers for the kimai2 web application including docker-compose and kubernetes/helm deployment.
MIT License
183 stars 97 forks source link

[BUG] vesion 2.x mis-tagged as 1.xx #467

Closed marcus905 closed 1 year ago

marcus905 commented 1 year ago

Describe the bug After updating from 1.30.5 to latest the container doesn't start and the app returns 500.

Most probably the apache tag now mistakenly points to 2.0.0

Logs: running

localhost:8001 127.0.0.1 - - [09/Feb/2023:17:31:50 +0100] "GET / HTTP/1.1" 500 211 "-" "curl/7.64.0"
[Thu Feb 09 17:32:10.228992 2023] [php:error] [pid 54] [client 127.0.0.1:45594] PHP Fatal error:  Uncaught Error: Undefined constant Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_ALL in /opt/kimai/public/index.php:23\nStack trace:\n#0 {main}\n  thrown in /opt/kimai/public/index.php on line 23

after a restart

tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-regular-400.eot: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-brands-400.eot: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-brands-400.woff: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-brands-400.ttf: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-solid-900.woff2: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-brands-400.woff2: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-solid-900.woff: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/fonts/fa-regular-400.woff: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/tabler.js: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/manifest.json: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/tabler-rtl.js.LICENSE.txt: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/tabler.css: Cannot open: No such file or directory
tar: public/bundles/tabler: Cannot mkdir: Permission denied
tar: public/bundles/tabler/tabler.js.LICENSE.txt: Cannot open: No such file or directory
tar: public/bundles: Cannot utime: Operation not permitted
tar: public: Cannot utime: Operation not permitted
tar: Exiting with failure status due to previous errors
Kimai installation running ...
==============================
Database `kimai` for connection named default already exists. Skipped.
 [OK] Already at the latest version ("DoctrineMigrations\Version20230126002049")
 Rebuilding your cache, please be patient ...
 // Clearing the cache for the prod environment with debug false                
 [ERROR] Failed to clear cache: Failed to remove file                           
         "/opt/kimai/var/cache/..41Y/pools/system/-zSvM4yc9c/B/Y/86oFB6EKJ3qXDOp
         obJwA":                                                                
         unlink(/opt/kimai/var/cache/..41Y/pools/system/-zSvM4yc9c/B/Y/86oFB6EKJ
         3qXDOpobJwA): Permission denied                                        
 [OK] Congratulations! Successfully installed Kimai version 2.0.0               
Kimai updates running ...
=========================
 [OK] Already at the latest version ("DoctrineMigrations\Version20230126002049")
 Rebuilding your cache, please be patient ...
 // Clearing the cache for the prod environment with debug false                
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /opt/kimai/vendor/twig/twig/src/Compiler.php on line 108
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/kimai/vendor/symfony/var-dumper/Dumper/CliDumper.php on line 1

  The command "kimai:reset:locales" does not exist.  


Kimai2 ready
Reloading configurations ...
============================
 [OK] All 25 YAML files contain valid syntax.                                   
 [OK] All 513 XLIFF files contain valid syntax.                                 
 Rebuilding your cache, please be patient ...
 // Clearing the cache for the prod environment with debug false                
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/kimai/var/cache/pro_/twig/cb/cb06d92a2f750d1e03d3d938724f96b7.php on line 288
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/kimai/vendor/symfony/var-dumper/Dumper/CliDumper.php on line 1
[Thu Feb 09 17:35:34.393199 2023] [core:warn] [pid 42] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Feb 09 17:35:34.396156 2023] [mpm_prefork:notice] [pid 42] AH00163: Apache/2.4.38 (Debian) PHP/8.1.12 configured -- resuming normal operations
[Thu Feb 09 17:35:34.396189 2023] [core:notice] [pid 42] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND'

To Reproduce Steps to reproduce the behaviour:

  1. Start the container with apache as update from 1.30.5
  2. Connect to app

Desktop (please complete the following information):

Command used to run the container

Docker compose file (with passwords redacted)

version: '3.5'
services:

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: redacted
      MYSQL_USER: redacted
      MYSQL_PASSWORD: redacted
      MYSQL_ROOT_PASSWORD: edacted
    volumes:
      - mysql:/var/lib/mysql
    command: --default-storage-engine innodb
    restart: unless-stopped

  kimai:
    image: kimai/kimai2:apache
    environment:
      ADMINMAIL: redacted
      ADMINPASS: redacted
      DATABASE_URL: redacted
      VIRTUAL_HOST: redacted.example.com
      VIRTUAL_PORT: 8001
      TRUSTED_HOSTS: localhost,127.0.0.1,REMOTE_ADDR,redacted.example.com
    depends_on:
      - mysql
    volumes:
      - public:/opt/kimai/public
      - var:/opt/kimai/var
      # - ./ldap.conf:/etc/openldap/ldap.conf:z
      # - ./ROOT-CA.pem:/etc/ssl/certs/ROOT-CA.pem:z
    restart: unless-stopped
    networks:
      - default
      - nginx-internal

volumes:
    var:
    public:
    mysql:

networks:
  nginx-internal:
marcus905 commented 1 year ago

To try to restart the system, after going back to v 1.30.6 manually it all appears to work but there might be some issues as there was a migration applied for the v2, so a backmigration could be needed, and some unexpected PHP fatal errors.


  Class "App\Entity\Customer" is not a valid entity or mapped super class.  

In MappingException.php line 364:

  Class "App\Entity\Invoice" is not a valid entity or mapped super class.  

In MappingException.php line 364:

  Class "App\Entity\User" is not a valid entity or mapped super class.  

In MappingException.php line 364:

  Class "App\Entity\Configuration" is not a valid entity or mapped super clas  
  s.                                                                           

Kimai updates running ...
=========================
 [WARNING] You have 1 previously executed migrations in the database that are   
           not registered migrations.                                           
 >> 2023-02-09 15:32:00 (DoctrineMigrations\Version20230126002049)
 [OK] Already at the latest version ("DoctrineMigrations\Version20230126002049")
 Rebuilding your cache, please be patient ...
 // Clearing the cache for the prod environment with debug                      
 // false                                                                       
 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.  
 // Warming up the cache for the prod environment with debug                    
 // false                                                                       
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 53248 bytes) in /opt/kimai/vendor/twig/twig/src/Compiler.php on line 121
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/kimai/vendor/symfony/var-dumper/Caster/ExceptionCaster.php on line 180
 [ERROR] email (superadmin)                                                     
             The email is already used.                                         
 [ERROR] username (superadmin)                                                  
             The username is already used.                                      

Kimai2 ready
Reloading configurations ...
============================
 [OK] All 39 YAML files contain valid syntax.                                   
 [OK] All 530 XLIFF files contain valid syntax.                                 
 Rebuilding your cache, please be patient ...
 // Clearing the cache for the prod environment with debug                      
 // false                                                                       
 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.  
 // Warming up the cache for the prod environment with debug                    
 // false                                                                       
 [OK] Cache for the "prod" environment (debug=false) was successfully warmed.   
 [OK] Kimai config was reloaded                                                 
[Thu Feb 09 17:39:55.969994 2023] [mpm_prefork:notice] [pid 61] AH00163: Apache/2.4.38 (Debian) PHP/8.1.12 configured -- resuming normal operations
[Thu Feb 09 17:39:55.970083 2023] [core:notice] [pid 61] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND'
tobybatch commented 1 year ago

You're right. It seems the apache latest image was pointing to the 2.x dev image. I've fixed that now. Did you back up the DB before you ran upgrade?

Restoring that would be the simplest option. If not we'll need to look at what back migrations are needed an how we would craft those

pbek commented 1 year ago

I was hit by the dev-image too yesterday, now it's back the the previous version. Luckily my instance still works.

You're right. It seems the apache latest image was pointing to the 2.x dev image.

Haha, and I was already happy about the new design. 😅 And I was even able to find out which setting was preventing me from stopping time entries, because I worked for more than 8h yesterday. I even updated my end2end tests to check if my instance is up, need to revert that again. 😁 Do you know when will dev hit latest for good, @tobybatch? Thanks again for the great work!

Sim0nW0lf commented 1 year ago

I think this happens with the fpm image too. I used the fpm-latest tag.

Going back to the fpm-1.30.5-prod worked again.

marcus905 commented 1 year ago

You're right. It seems the apache latest image was pointing to the 2.x dev image. I've fixed that now. Did you back up the DB before you ran upgrade?

Restoring that would be the simplest option. If not we'll need to look at what back migrations are needed an how we would craft those

Sadly it was automatically done with watchtower and i noticed it only afterwards. I can try diffing the db schema of a clean 1.30.6 and the one i have now on Monday.

pbek commented 1 year ago

Watchtower too for me, but I didn't seem to have lost anything. How curious

kevinpapst commented 1 year ago

Let me start with the obvious part: sorry guys that it hit you!

Use the backup if you can. The latest migration was renamed at some point between the beta releases and the next automatic update (who does that?) might error out with the message you see above:

You have 1 previously executed migrations in the database that are not registered migrations.                                           
 >> 2023-02-09 15:32:00 (DoctrineMigrations\Version20230126002049 .

The beta release was not meant to be used with production databases and I would strongly suggest to rollback. There is no guarantee, that you got all required SQLs now. Besides of the problem with the unknown migration in the last row in the table migration_versions.

marcus905 commented 1 year ago

Well, we did do that 😂 I have to manually diff databases, the backup was done weekly (as all other non-critical systems... as to why it was deemed non-critical I have no idea) and I cannot reapply a week's worth of timesheets sadly.

I'll try to put a "rollback" script up Monday, hopefully.

kevinpapst commented 1 year ago

Check this migration files, it explains the differences: https://github.com/kimai/kimai/blob/main/migrations/Version20230126002049.php

tobybatch commented 1 year ago

New images are now built and pushed (including multiarch). I'll close this for now, please open a new ticket if issues persist.