From 946f16f7c1eec78a3d6cf011fc000519198b1c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 5 Apr 2019 02:12:46 +0200 Subject: [PATCH] caddy-frontend: Make sure etc/log-access.conf is never empty When there are no shared instances, the file was empty, but caddy refuses to start when using an import statement on an empty file, with this error: ``` Error during parsing: Could not read tokens while importing .../etc/log-access.conf: EOF ``` /reviewed-on https://lab.nexedi.com/nexedi/slapos/merge_requests/545 --- software/caddy-frontend/buildout.hash.cfg | 2 +- .../templates/apache-custom-slave-list.cfg.in | 8 ++++++++ .../test.TestMasterRequest.test_file_list_log-CADDY.txt | 2 ++ .../test.TestMasterRequest.test_file_list_run-CADDY.txt | 1 + ...st.TestMasterRequest.test_promise_run_plugin-CADDY.txt | 6 +++--- ...test.TestMasterRequest.test_supervisor_state-CADDY.txt | 2 +- ...t.TestMasterRequestDomain.test_file_list_log-CADDY.txt | 2 ++ ...t.TestMasterRequestDomain.test_file_list_run-CADDY.txt | 1 + ...tMasterRequestDomain.test_promise_run_plugin-CADDY.txt | 6 +++--- ...estMasterRequestDomain.test_supervisor_state-CADDY.txt | 2 +- 10 files changed, 23 insertions(+), 9 deletions(-) diff --git a/software/caddy-frontend/buildout.hash.cfg b/software/caddy-frontend/buildout.hash.cfg index d2373fa64..9820033c1 100644 --- a/software/caddy-frontend/buildout.hash.cfg +++ b/software/caddy-frontend/buildout.hash.cfg @@ -30,7 +30,7 @@ md5sum = 37edefdb9963daa67b01e5d55d97c17d [template-slave-list] filename = templates/apache-custom-slave-list.cfg.in -md5sum = 61919290d810518eba2e74e821dc9de8 +md5sum = f9efdfe7a7e3a78f0b15f414b5469316 [template-slave-configuration] filename = templates/custom-virtualhost.conf.in diff --git a/software/caddy-frontend/templates/apache-custom-slave-list.cfg.in b/software/caddy-frontend/templates/apache-custom-slave-list.cfg.in index 62081d060..feebb42a8 100644 --- a/software/caddy-frontend/templates/apache-custom-slave-list.cfg.in +++ b/software/caddy-frontend/templates/apache-custom-slave-list.cfg.in @@ -475,6 +475,13 @@ template = inline: rendered = ${:file} +[caddy-log-access-header] +# Caddy refuse to start if an `import`ed file is empty, so we prepend a header +# so that the file is never empty. +< = jinja2-template-base +template = inline: # This file contain directives to serve directories with log files +rendered = {{frontend_configuration.get('log-access-configuration')}} + [buildout] extends = {{ common_profile }} @@ -482,6 +489,7 @@ extends = parts += kedifa-updater + caddy-log-access-header {% for part in part_list %} {{ ' %s' % part }} {% endfor %} diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt index ddcfa1116..4f3011ef3 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_log-CADDY.txt @@ -1,6 +1,8 @@ T-0/var/log/monitor-httpd-error.log T-0/var/log/slapgrid-T-0-error.log T-1/var/log/expose-csr_id.log +T-2/var/log/frontend-access.log +T-2/var/log/frontend-error.log T-2/var/log/httpd-csr_id/expose-csr_id.log T-2/var/log/nginx-access.log T-2/var/log/nginx-error.log diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_run-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_run-CADDY.txt index 2e3144f84..d8f905551 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_run-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_file_list_run-CADDY.txt @@ -4,6 +4,7 @@ T-1/var/run/kedifa.pid T-2/var/run/caddy_graceful_signature T-2/var/run/caddy_validate_signature T-2/var/run/caddy_validate_signature.status +T-2/var/run/httpd.pid T-2/var/run/monitor/monitor-bootstrap.pid T-2/var/run/nginx.pid T-2/var/run/nginx_graceful_signature diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_promise_run_plugin-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_promise_run_plugin-CADDY.txt index 9a353c40a..a8199e154 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_promise_run_plugin-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_promise_run_plugin-CADDY.txt @@ -4,13 +4,13 @@ T-0/etc/plugin/monitor-bootstrap-status.py: OK T-0/etc/plugin/monitor-httpd-listening-on-tcp.py: OK T-2/etc/plugin/buildout-T-2-status.py: OK T-2/etc/plugin/caddy_cached.py: ERROR -T-2/etc/plugin/caddy_frontend_ipv4_http.py: ERROR -T-2/etc/plugin/caddy_frontend_ipv4_https.py: ERROR +T-2/etc/plugin/caddy_frontend_ipv4_http.py: OK +T-2/etc/plugin/caddy_frontend_ipv4_https.py: OK T-2/etc/plugin/caddy_frontend_ipv6_http.py: OK T-2/etc/plugin/caddy_frontend_ipv6_https.py: OK T-2/etc/plugin/caddy_ssl_cached.py: ERROR T-2/etc/plugin/check-free-disk-space.py: OK -T-2/etc/plugin/frontend-caddy-configuration-promise.py: ERROR +T-2/etc/plugin/frontend-caddy-configuration-promise.py: OK T-2/etc/plugin/monitor-bootstrap-status.py: OK T-2/etc/plugin/monitor-httpd-listening-on-tcp.py: OK T-2/etc/plugin/nginx-configuration-promise.py: OK diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_supervisor_state-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_supervisor_state-CADDY.txt index 6aa2a844e..d3b921625 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_supervisor_state-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequest.test_supervisor_state-CADDY.txt @@ -20,7 +20,7 @@ T-2:crond-{hash}-on-watch RUNNING T-2:expose-csr_id-{hash}-on-watch RUNNING T-2:frontend-caddy-safe-graceful EXITED T-2:frontend-nginx-safe-graceful EXITED -T-2:frontend_caddy-{hash}-on-watch EXITED +T-2:frontend_caddy-{hash}-on-watch RUNNING T-2:frontend_nginx-{hash}-on-watch RUNNING T-2:kedifa-login-certificate-caucase-updater-on-watch RUNNING T-2:kedifa-updater-{hash}-on-watch RUNNING diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt index ddcfa1116..4f3011ef3 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_log-CADDY.txt @@ -1,6 +1,8 @@ T-0/var/log/monitor-httpd-error.log T-0/var/log/slapgrid-T-0-error.log T-1/var/log/expose-csr_id.log +T-2/var/log/frontend-access.log +T-2/var/log/frontend-error.log T-2/var/log/httpd-csr_id/expose-csr_id.log T-2/var/log/nginx-access.log T-2/var/log/nginx-error.log diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_run-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_run-CADDY.txt index 2e3144f84..d8f905551 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_run-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_file_list_run-CADDY.txt @@ -4,6 +4,7 @@ T-1/var/run/kedifa.pid T-2/var/run/caddy_graceful_signature T-2/var/run/caddy_validate_signature T-2/var/run/caddy_validate_signature.status +T-2/var/run/httpd.pid T-2/var/run/monitor/monitor-bootstrap.pid T-2/var/run/nginx.pid T-2/var/run/nginx_graceful_signature diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_promise_run_plugin-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_promise_run_plugin-CADDY.txt index 9a353c40a..a8199e154 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_promise_run_plugin-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_promise_run_plugin-CADDY.txt @@ -4,13 +4,13 @@ T-0/etc/plugin/monitor-bootstrap-status.py: OK T-0/etc/plugin/monitor-httpd-listening-on-tcp.py: OK T-2/etc/plugin/buildout-T-2-status.py: OK T-2/etc/plugin/caddy_cached.py: ERROR -T-2/etc/plugin/caddy_frontend_ipv4_http.py: ERROR -T-2/etc/plugin/caddy_frontend_ipv4_https.py: ERROR +T-2/etc/plugin/caddy_frontend_ipv4_http.py: OK +T-2/etc/plugin/caddy_frontend_ipv4_https.py: OK T-2/etc/plugin/caddy_frontend_ipv6_http.py: OK T-2/etc/plugin/caddy_frontend_ipv6_https.py: OK T-2/etc/plugin/caddy_ssl_cached.py: ERROR T-2/etc/plugin/check-free-disk-space.py: OK -T-2/etc/plugin/frontend-caddy-configuration-promise.py: ERROR +T-2/etc/plugin/frontend-caddy-configuration-promise.py: OK T-2/etc/plugin/monitor-bootstrap-status.py: OK T-2/etc/plugin/monitor-httpd-listening-on-tcp.py: OK T-2/etc/plugin/nginx-configuration-promise.py: OK diff --git a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_supervisor_state-CADDY.txt b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_supervisor_state-CADDY.txt index 6aa2a844e..d3b921625 100644 --- a/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_supervisor_state-CADDY.txt +++ b/software/caddy-frontend/test/test_data/test.TestMasterRequestDomain.test_supervisor_state-CADDY.txt @@ -20,7 +20,7 @@ T-2:crond-{hash}-on-watch RUNNING T-2:expose-csr_id-{hash}-on-watch RUNNING T-2:frontend-caddy-safe-graceful EXITED T-2:frontend-nginx-safe-graceful EXITED -T-2:frontend_caddy-{hash}-on-watch EXITED +T-2:frontend_caddy-{hash}-on-watch RUNNING T-2:frontend_nginx-{hash}-on-watch RUNNING T-2:kedifa-login-certificate-caucase-updater-on-watch RUNNING T-2:kedifa-updater-{hash}-on-watch RUNNING -- 2.30.9