diff mbox series

[layerindex-web] dockersetup: move TASK_LOG_DIR with --app-dir

Message ID 20261114024050.63499-1-tim.orling@konsulko.com
State Under Review
Delegated to: Tim Orling
Headers show
Series [layerindex-web] dockersetup: move TASK_LOG_DIR with --app-dir | expand

Commit Message

Tim Orling Nov. 14, 2026, 2:40 a.m. UTC
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 <tim.orling@konsulko.com>
---
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(+)


base-commit: 08e58cdece30019a6f9e5d14af16ebe20afa6177
diff mbox series

Patch

diff --git a/dockersetup.py b/dockersetup.py
index 406bdf9..9e4d05e 100755
--- a/dockersetup.py
+++ b/dockersetup.py
@@ -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))
 
diff --git a/tests/test_dockersetup.py b/tests/test_dockersetup.py
index 0109c80..97a78f6 100644
--- a/tests/test_dockersetup.py
+++ b/tests/test_dockersetup.py
@@ -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']