immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
52.78k stars 2.8k forks source link

machine-learning image fails to start with IMMICH_HOST= set to bare IPv6 address #13782

Open frebib opened 4 weeks ago

frebib commented 4 weeks ago

The bug

Setting IMMICH_HOST=:: causes the container to crashloop

+ gunicorn app.main:app -k app.config.CustomUvicornWorker -c gunicorn_conf.py -b :::3003 -w 1 -t 120 --log-config-json log_conf.json --keep-alive 2 --graceful-timeout 0

Error: '' is not a valid port number.

Setting IMMICH_HOST=[::] allows it to start

IMMICH_HOST=:: is the correct representation here. The container needs to identify that it's an IPv6 address and handle it correctly/add the square brackets.

The OS that Immich Server is running on

Debian, Docker

Version of Immich Server

v1.119.0

mmomjian commented 4 weeks ago

This looks to be behaving according to the gunicorn docs: https://docs.gunicorn.org/en/stable/settings.html#bind

Either way, not an Immich issue, so I am closing this for now. Will reopen if other info is available.

frebib commented 4 weeks ago

@mmomjian Problem is, it's not consistent with the immich server container. That behaves the opposite way. :: works but [::] is invalid. I'm not entirely sure how gunicorn is invoked, but this is squarely a "immich doesn't work as it should" problem, regardless of how the backing software works. Crashlooping is never "expected behaviour"

frebib commented 4 weeks ago

The issue is that you're not correctly invoking gunicorn here https://github.com/immich-app/immich/blob/main/machine-learning/start.sh#L21

frebib commented 4 weeks ago

See https://datatracker.ietf.org/doc/html/rfc6874#section-2 for how IPv6 should be treated. As a bare literal, it should be raw hex and colos, e.g. abcd:1234:: and in a URI it should be enclosed in square brackets e.g. [abcd:1234::]:567 The IMMICH_HOST variable as per your documentation is a raw literal: https://immich.app/docs/install/environment-variables#ports and thus I would expect IMMICH_HOST=abcd:1234:: to work for both the immich server and immich machine-learning services to work the same, but it does not as per 1.119.0

mmomjian commented 4 weeks ago

I see the issue now, thanks

the main issue is the inconsistency. Clearly a crash loop is acceptable if the server is grossly misconfigured, as the server cannot start without a HOST to listen on. Falling back to a default is not an option as this can introduce security issues and other bugs

bo0tzz commented 4 weeks ago

cc @mertalev

mertalev commented 4 weeks ago

We can check if it's a valid IPv6 address in start.sh and add braces if so.