mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
fix(web-app-weblate): let beat alone populate the volumes the tier shares
weblate, beat and worker mount the same weblate_data and weblate_cache. Docker fills a fresh named volume from the image once per POST /containers/create, and that copy does an Lstat plus os.Mkdir per directory without tolerating EEXIST. Compose created all three at once, two populations of the image's /app/data raced, and the deploy died with "failed to mkdir /var/lib/docker/volumes/weblate_data/_data/python: file exists" in CI run 38818071194. The daemon log names the route as containers/create, so this is the population path, not a mount of a pre-existing file. Make weblate and worker depend on beat. The lever is not startup order but the Create phase, which compose runs in dependency order: beat populates both volumes alone, and by the time the other two are created no copy runs. The failing run proves that phase is ordered - COMPOSE_PARALLEL_LIMIT was 4, yet only the two existing depends_on targets reached Created before the other three began. This is compose-only. In swarm, container_depends_on drops to a bare list (plugins/lookup/container_depends_on.py:103) and docker stack deploy ignores it, so swarm behaviour is unchanged and the same race stays reachable there. A mode-independent fix needs nocopy on the non-owning mounts, which plugins/lookup/container_volumes.py cannot express today. The test reads meta/volumes.yml, collects every service sharing a volume and requires each non-beat sharer to name beat. Against the previous template it yields weblate False, beat True, worker False, so it fails without this change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9d42d0851c
commit
b38bb6dba5
3 files changed
+59
-2
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,53 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from utils.cache.files import PROJECT_ROOT, read_text
|
||||
from utils.cache.yaml import load_yaml_str
|
||||
from utils.roles.mapping import ROLE_FILE_META_VOLUMES, ROLE_FILE_TEMPL_COMPOSE
|
||||
|
||||
ROLE = PROJECT_ROOT / "roles" / "web-app-weblate"
|
||||
COMPOSE = ROLE / ROLE_FILE_TEMPL_COMPOSE
|
||||
VOLUMES = ROLE / ROLE_FILE_META_VOLUMES
|
||||
POPULATING_SERVICE = "beat"
|
||||
|
||||
|
||||
def service_blocks(template: str) -> dict[str, str]:
|
||||
"""Split a compose template into one text block per ``service_name``.
|
||||
|
||||
Args:
|
||||
template: the raw ``compose.yml.j2`` source.
|
||||
|
||||
Returns:
|
||||
Mapping of service name to the template text that renders it.
|
||||
"""
|
||||
parts = re.split(r"{%\s*set service_name = '([^']+)'\s*%}", template)
|
||||
return dict(zip(parts[1::2], parts[2::2], strict=True))
|
||||
|
||||
|
||||
class TestSharedVolumePopulationOrder(unittest.TestCase):
|
||||
def test_every_other_sharer_waits_for_the_service_that_fills_the_volume(
|
||||
self,
|
||||
) -> None:
|
||||
volumes = load_yaml_str(read_text(str(VOLUMES)))
|
||||
sharers = {
|
||||
mount["service"]
|
||||
for entry in volumes.values()
|
||||
for mount in entry.get("mounts") or []
|
||||
}
|
||||
blocks = service_blocks(read_text(str(COMPOSE)))
|
||||
for service in sorted(sharers - {POPULATING_SERVICE}):
|
||||
self.assertIn(
|
||||
POPULATING_SERVICE,
|
||||
blocks[service],
|
||||
f"docker fills a fresh named volume from the image once per container "
|
||||
f"create and the copy's mkdir is not EEXIST-safe, so '{service}' must "
|
||||
f"depend on '{POPULATING_SERVICE}' instead of being created beside it, "
|
||||
f"or the deploy dies on 'mkdir /var/lib/docker/volumes/weblate_data/"
|
||||
f"_data/python: file exists'",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user