fix(docker): cap swarm config name at 64 chars via sha256 fallback #17

Merged
admin merged 1 commits from hermes/brencher:fix-truncate-swarm-config-name into main 2026-08-29 22:54:09 +02:00
Contributor

What

Since #5 (Fix/show pipeline errors), brencher appends a version tail to every swarm config name so each deploy creates a new config object (swarm configs are immutable). For long base names plus the version string, the resulting prefixed name (stack_name_ + name) can exceed docker swarm's 64-char limit and docker stack deploy fails with InvalidArgument.

Repro

[2026-08-29 19:38:46,063] failed to create config hermes_infra_brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220: Error response from daemon: rpc error: code = InvalidArgument desc = invalid name, only 64 [a-zA-Z0-9-_.] characters allowed

brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220 is 57 chars, plus the 13-char hermes_infra_ stack prefix = 70, over the 64-char limit.

Fix

When the would-be full prefixed name is longer than 64 chars, replace the suffix with sha256(full)[:32]. 32 hex chars is comfortably unique per (base_name, version) pair and the prefixed name ends up at 12 + 1 + 32 = 45 chars, well under the limit.

Short names keep the readable <name>_<version> form (no change for the common case).

Verified

Manual sanity check on the four configs currently in hermes_squid:

base version compose name docker name length
squid_conf auto-4cb8eeae-bfb3c220 squid_conf_auto-4cb8eeae-bfb3c220 hermes_infra_squid_conf_auto-4cb8eeae-bfb3c220 46
brencher_state_proxy_conf auto-16875f17-4cb8eeae-bfb3c220 7644a2983c7f6c7b09c6ed84bff0096d hermes_infra_7644a2983c7f6c7b09c6ed84bff0096d 45
brencher_state_proxy_conf auto-4cb8eeae-bfb3c220 brencher_state_proxy_conf_auto-4cb8eeae-bfb3c220 hermes_infra_brencher_state_proxy_conf_auto-4cb8eeae-bfb3c220 61
nginx_hermes_conf auto-16875f17-4cb8eeae-bfb3c220 nginx_hermes_conf_auto-16875f17-4cb8eeae-bfb3c220 hermes_infra_nginx_hermes_conf_auto-16875f17-4cb8eeae-bfb3c220 62

All under 64 chars; sha256 fallback only kicks in for the long case.

Impact

  • Fixes deploys of stacks that have a config with a long base name (e.g. brencher_state_proxy_conf in hermes_infra).
  • Other stacks (gitea, immich, torrserv_proxy, etc.) are unaffected because their config names are short enough to fit the existing readable form.
  • After merge + brencher self-deploy, the failed hermes_infra stack at brencher-state-proxy (failed since 2026-08-26) can finally be re-deployed and pick up the new brencher-state-proxy.conf with the resolver fix from #5's companion config rename.

Related

  • This unblocks admin/ansible#21 (feat/stt-voice-faster-whisper) whose deploy was failing on the same length error.
  • The companion nginx-side fix in admin/ansible#21 (brencher-state-proxy.conf: resolver + set $upstream) will start working once this lands and the config object is actually recreated.
## What Since #5 (Fix/show pipeline errors), brencher appends a version tail to every swarm config name so each deploy creates a new config object (swarm configs are immutable). For long base names plus the version string, the resulting prefixed name (stack_name_ + name) can exceed docker swarm's 64-char limit and `docker stack deploy` fails with `InvalidArgument`. ## Repro ``` [2026-08-29 19:38:46,063] failed to create config hermes_infra_brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220: Error response from daemon: rpc error: code = InvalidArgument desc = invalid name, only 64 [a-zA-Z0-9-_.] characters allowed ``` `brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220` is 57 chars, plus the 13-char `hermes_infra_` stack prefix = 70, over the 64-char limit. ## Fix When the would-be full prefixed name is longer than 64 chars, replace the suffix with `sha256(full)[:32]`. 32 hex chars is comfortably unique per `(base_name, version)` pair and the prefixed name ends up at 12 + 1 + 32 = 45 chars, well under the limit. Short names keep the readable `<name>_<version>` form (no change for the common case). ## Verified Manual sanity check on the four configs currently in `hermes_squid`: | base | version | compose name | docker name | length | |---|---|---|---|---| | squid_conf | auto-4cb8eeae-bfb3c220 | squid_conf_auto-4cb8eeae-bfb3c220 | hermes_infra_squid_conf_auto-4cb8eeae-bfb3c220 | 46 | | brencher_state_proxy_conf | auto-16875f17-4cb8eeae-bfb3c220 | 7644a2983c7f6c7b09c6ed84bff0096d | hermes_infra_7644a2983c7f6c7b09c6ed84bff0096d | 45 | | brencher_state_proxy_conf | auto-4cb8eeae-bfb3c220 | brencher_state_proxy_conf_auto-4cb8eeae-bfb3c220 | hermes_infra_brencher_state_proxy_conf_auto-4cb8eeae-bfb3c220 | 61 | | nginx_hermes_conf | auto-16875f17-4cb8eeae-bfb3c220 | nginx_hermes_conf_auto-16875f17-4cb8eeae-bfb3c220 | hermes_infra_nginx_hermes_conf_auto-16875f17-4cb8eeae-bfb3c220 | 62 | All under 64 chars; sha256 fallback only kicks in for the long case. ## Impact - Fixes deploys of stacks that have a config with a long base name (e.g. `brencher_state_proxy_conf` in `hermes_infra`). - Other stacks (`gitea`, `immich`, `torrserv_proxy`, etc.) are unaffected because their config names are short enough to fit the existing readable form. - After merge + brencher self-deploy, the failed hermes_infra stack at `brencher-state-proxy` (failed since 2026-08-26) can finally be re-deployed and pick up the new `brencher-state-proxy.conf` with the resolver fix from #5's companion config rename. ## Related - This unblocks `admin/ansible#21` (feat/stt-voice-faster-whisper) whose deploy was failing on the same length error. - The companion nginx-side fix in `admin/ansible#21` (`brencher-state-proxy.conf`: `resolver` + `set $upstream`) will start working once this lands and the config object is actually recreated.
hermes added 1 commit 2026-08-29 21:51:04 +02:00
fix(docker): cap swarm config name at 64 chars via sha256 fallback
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Successful in 43s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Successful in 37s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Successful in 58s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Successful in 58s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Successful in 38s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Successful in 36s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Successful in 1m44s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Successful in 2m2s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Successful in 2m5s
Python package / build (pip list, 3.12.3) (pull_request) Successful in 34s
Python package / build (pip list, 3.13) (pull_request) Successful in 33s
Python package / build (pip list, 3.14) (pull_request) Successful in 30s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Successful in 31s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Successful in 34s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Successful in 34s
87fab9cd95
Since e4f90b1f, brencher appends the version tail to every swarm
config name so deploys actually create a new config object (the old
config is immutable in docker swarm). For long base names plus a
multi-commit version tail, the resulting name can exceed docker
swarm's 64-char limit and 'docker stack deploy' fails with:

  failed to create config <stack>_<name>_auto-<sha>-<sha>-<sha>:
  rpc error: code = InvalidArgument
  desc = invalid name, only 64 [a-zA-Z0-9-_.] characters allowed

For example, brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220
becomes hermes_infra_brencher_state_proxy_conf_auto-16875f17-4cb8eeae-bfb3c220
in the swarm (70 chars), which docker rejects.

When the would-be name (with stack prefix) is longer than 64 chars,
replace the suffix with sha256(name)[:32]. 32 hex chars is comfortably
unique per (base_name, version) pair and keeps the docker-side
prefixed name under 64 chars (12 + 1 + 32 = 45).

Compose authors no longer need to invent short config names to
work around the limit.
admin approved these changes 2026-08-29 21:54:09 +02:00
admin merged commit 98ee950a1f into main 2026-08-29 22:54:09 +02:00
admin deleted branch fix-truncate-swarm-config-name 2026-08-29 22:54:10 +02:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/brencher#17