immich-app / immich

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

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

Open frebib opened 1 week ago

frebib commented 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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 1 week ago

cc @mertalev

mertalev commented 1 week ago

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