dockersetup: move TASK_LOG_DIR with --app-dir
PATCH 1/1 dockersetup: move TASK_LOG_DIR with --app-dir
With --app-dir, dockersetup.py mounts the task logs volume under the application directory, but left TASK_LOG_DIR in docker/settings.py at /opt/layerindex-task-logs, so the Celery worker wrote the task logs outside the volume and the task page could not show them. Set TASK_LOG_DIR from the application directory, as is already done for LAYER_FETCH_DIR.
AI-Generated: Claude Opus 5.5
Signed-off-by Tim Orling <[email protected]>
---
Found while reviewing the task logs volume for the Update Layer button series ("Dockerfile: create the task logs directory" creates ${APP_DIR}/layerindex-task-logs, which this matches). Covered by a new test in tests/test_dockersetup.py.
dockersetup.py | 3 +++ tests/test_dockersetup.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+)
dockersetup.py +3 -0
@@ -427,6 +427,9 @@ def edit_settings_py(emailaddr, app_dir='/opt'): elif line.lstrip().startswith('LAYER_FETCH_DIR'): newlines.append("LAYER_FETCH_DIR = \"%s/workdir\"\n" % app_dir) continue + elif line.lstrip().startswith('TASK_LOG_DIR'): + newlines.append("TASK_LOG_DIR = \"%s/layerindex-task-logs\"\n" % app_dir) + continue newlines.append(line + "\n") writefile("docker/settings.py", ''.join(newlines))
tests/test_dockersetup.py +14 -0
@@ -22,6 +22,7 @@ TRACKED_FILES = [ '.env.dev.app', '.env.dev.celery', '.env.dev.db', '.env.dev.rabbit', 'Dockerfile', 'docker/git-proxy', 'docker/.gitconfig', 'docker/nginx-ssl.conf', + 'docker/settings.py', ]
@@ -115,6 +116,19 @@ def test_compose_uses_local_env_files(workdir): assert 'layerscertbot' not in services +def test_app_dir_moves_task_logs_with_the_volume(workdir): + # The task logs volume and TASK_LOG_DIR must agree, or the task log page + # can't find the logs the Celery worker writes + dockersetup.edit_dockercompose('layers.example.com', '8080:80,8081:443', False, app_dir='/srv/li') + dockersetup.edit_settings_py(None, app_dir='/srv/li') + services = load_compose(workdir)['services'] + settings = (workdir / 'docker' / 'settings.py').read_text() + for service in ('layersapp', 'layerscelery'): + assert 'logvolume:/srv/li/layerindex-task-logs:z' in services[service]['volumes'] + assert 'TASK_LOG_DIR = "/srv/li/layerindex-task-logs"' in settings + assert 'LAYER_FETCH_DIR = "/srv/li/workdir"' in settings + + def test_compose_enables_certbot_for_letsencrypt(workdir): dockersetup.edit_dockercompose('layers.example.com', '80:80,443:443', True) services = load_compose(workdir)['services']
base-commit: 08e58cdece30019a6f9e5d14af16ebe20afa6177
Signature · 1 line
2.56.0