From b0d0efc246ea90079777eb5b4cebfab93f88c5cf Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 9 Feb 2017 16:41:24 +0900
Subject: [PATCH] stack.logrotate: Fix support for stopped processes.

When a process is stopped:
- it may not have emitted logs since previous rotation: add "missingok"
  As a direct consequence: stop using logrotate recipe.
- its pid file (if applicable) may be missing: test its non-empty presence
  before calling slapos-kill
Also, stop using slapos.cookbook:logrotate.
Update obvious users (cloudooo, neoppod, erp5, monitor, re6stnet).
---
 software/cloudooo/instance-cloudooo.cfg.in    |  6 +--
 software/cloudooo/software-common.cfg         |  2 +-
 software/neoppod/instance-neo-admin.cfg.in    |  4 +-
 software/neoppod/instance-neo-master.cfg.in   |  4 +-
 .../neoppod/instance-neo-storage-mysql.cfg.in | 11 +----
 software/neoppod/software-common.cfg          |  6 +--
 software/re6stnet/instance-re6stnet.cfg.in    |  4 +-
 software/re6stnet/software.cfg                |  2 +-
 stack/erp5/buildout.hash.cfg                  | 10 ++--
 stack/erp5/instance-balancer.cfg.in           |  6 +--
 stack/erp5/instance-kumofs.cfg.in             |  4 +-
 stack/erp5/instance-mariadb.cfg.in            |  4 +-
 stack/erp5/instance-zeo.cfg.in                |  9 +---
 stack/erp5/instance-zope.cfg.in               |  7 +--
 stack/logrotate/buildout.cfg                  | 18 +++++++-
 .../logrotate/instance-logrotate-base.cfg.in  | 46 ++++++++++++++-----
 stack/logrotate/logrotate.conf.in             |  5 ++
 stack/logrotate/logrotate_entry.in            | 18 ++++++++
 stack/monitor/buildout.cfg                    |  2 +-
 stack/monitor/instance-monitor.cfg.jinja2.in  |  4 +-
 20 files changed, 103 insertions(+), 69 deletions(-)
 create mode 100644 stack/logrotate/logrotate.conf.in
 create mode 100644 stack/logrotate/logrotate_entry.in

diff --git a/software/cloudooo/instance-cloudooo.cfg.in b/software/cloudooo/instance-cloudooo.cfg.in
index e45b65252..79a67c020 100644
--- a/software/cloudooo/instance-cloudooo.cfg.in
+++ b/software/cloudooo/instance-cloudooo.cfg.in
@@ -150,12 +150,10 @@ crl =
 {%- endif %}
 
 [apache-logrotate]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = apache
 log = ${apache-conf-parameter-dict:error-log} ${apache-conf-parameter-dict:access-log}
-post = {{ bin_directory }}/slapos-kill --pidfile ${apache-conf-parameter-dict:pid-file} -s USR1
+post = test ! -s ${apache-conf-parameter-dict:pid-file} || {{ bin_directory }}/slapos-kill --pidfile ${apache-conf-parameter-dict:pid-file} -s USR1
 
 [publish]
 recipe = slapos.cookbook:publish.serialised
diff --git a/software/cloudooo/software-common.cfg b/software/cloudooo/software-common.cfg
index 57df41214..9f71bddbd 100644
--- a/software/cloudooo/software-common.cfg
+++ b/software/cloudooo/software-common.cfg
@@ -83,5 +83,5 @@ template-logrotate-base = ${template-logrotate-base:rendered}
 [template-cloudooo-instance]
 recipe = slapos.recipe.build:download
 url = ${:_profile_base_location_}/instance-cloudooo.cfg.in
-md5sum = 3de0b4732e5132448027c1387a4de3c9
+md5sum = e1a4a73aeb8b978e953a3f4f39b98a4d
 mode = 640
diff --git a/software/neoppod/instance-neo-admin.cfg.in b/software/neoppod/instance-neo-admin.cfg.in
index 518a171b9..baf386661 100644
--- a/software/neoppod/instance-neo-admin.cfg.in
+++ b/software/neoppod/instance-neo-admin.cfg.in
@@ -22,9 +22,7 @@ port = ${neo-admin:port}
 path = ${directory:promises}/neo-admin-promise
 
 [logrotate-admin]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = neo-admin
 log = ${neo-admin:logfile}
 post = {{ bin_directory }}/slapos-kill -n neoadmin -s RTMIN+1 ${:log}
diff --git a/software/neoppod/instance-neo-master.cfg.in b/software/neoppod/instance-neo-master.cfg.in
index c649e3411..65cd151fc 100644
--- a/software/neoppod/instance-neo-master.cfg.in
+++ b/software/neoppod/instance-neo-master.cfg.in
@@ -30,9 +30,7 @@ port = ${neo-master:port}
 path = ${directory:promises}/neo-master-promise
 
 [logrotate-master]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = neo-master
 log = ${neo-master:logfile}
 post = {{ bin_directory }}/slapos-kill -n neomaster -s RTMIN+1 ${:log}
diff --git a/software/neoppod/instance-neo-storage-mysql.cfg.in b/software/neoppod/instance-neo-storage-mysql.cfg.in
index 92f25da70..f17432670 100644
--- a/software/neoppod/instance-neo-storage-mysql.cfg.in
+++ b/software/neoppod/instance-neo-storage-mysql.cfg.in
@@ -88,11 +88,6 @@ database-adapter = MySQL
 wait-database = 60
 engine = {{ slapparameter_dict.get('engine', '') }}
 
-[logrotate-storage]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
-
 {% for i in range(slapparameter_dict.get('storage-count', 1)) -%}
 {%   set storage_id = 'neo-storage-' ~ i -%}
 [{{ section(storage_id) }}]
@@ -103,7 +98,7 @@ logfile = ${directory:log}/{{ 'neostorage-' ~ i }}.log
 database-parameters = root@neo{{ i }}${my-cnf-parameters:socket}
 
 [{{ section('logrotate-storage-' ~ i) }}]
-< = logrotate-storage
+< = logrotate-entry-base
 name = {{ storage_id }}
 log = {{ '${' +  storage_id + ':logfile}' }}
 post = {{ bin_directory }}/slapos-kill -n neostorage -s RTMIN+1 ${:log}
@@ -129,9 +124,7 @@ log = ${buildout:directory}/var/log
 tmp = ${buildout:directory}/tmp
 
 [logrotate-mysql]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = mariadb
 log = ${my-cnf-parameters:error-log} ${my-cnf-parameters:slow-query-log}
 post = ${mysqld:mysql-base-directory}/bin/mysql --defaults-file="${my-cnf:rendered}" -e "FLUSH LOGS"
diff --git a/software/neoppod/software-common.cfg b/software/neoppod/software-common.cfg
index 7d28e6bf5..64823e677 100644
--- a/software/neoppod/software-common.cfg
+++ b/software/neoppod/software-common.cfg
@@ -89,15 +89,15 @@ md5sum = f3259726bd5d824c569dc7db6b7d26a0
 
 [instance-neo-admin]
 <= download-base-neo
-md5sum = ec1e2d9d2a1da092621f1b01ce6af322
+md5sum = d5eb14e3d83d7787950de913d7e29aad
 
 [instance-neo-master]
 <= download-base-neo
-md5sum = 82f3f76f54ee9db355966a7ada61f56e
+md5sum = c6e0db7344a26a55580102e3cc33c984
 
 [instance-neo-storage-mysql]
 <= download-base-neo
-md5sum = cd2a978a09c5686205592923866f6584
+md5sum = 22206396eff084af3e0587494a012174
 
 [template-neo-my-cnf]
 <= download-base-neo
diff --git a/software/re6stnet/instance-re6stnet.cfg.in b/software/re6stnet/instance-re6stnet.cfg.in
index b3f2f35aa..2f16e8d47 100644
--- a/software/re6stnet/instance-re6stnet.cfg.in
+++ b/software/re6stnet/instance-re6stnet.cfg.in
@@ -102,7 +102,7 @@ context =
 < = logrotate-entry-base
 name = apache
 log = ${apache-conf:error-log} ${apache-conf:access-log}
-post = {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${apache-conf:pid-file} -s USR1
+post = test ! -s ${apache-conf:pid-file} || {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${apache-conf:pid-file} -s USR1
 
 [re6st-registry-conf-dict]
 port = 9201
@@ -192,7 +192,7 @@ command = {{ python_bin }} ${re6st-registry:drop-service-wrapper}
 < = logrotate-entry-base
 name = re6stnet
 log = ${re6st-registry-conf-dict:logfile}
-post = {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${re6st-registry:pid-file} -s USR1
+post = test ! -s ${re6st-registry:pid-file} || {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${re6st-registry:pid-file} -s USR1
 
 [re6st-registry-promise]
 recipe = slapos.cookbook:check_port_listening
diff --git a/software/re6stnet/software.cfg b/software/re6stnet/software.cfg
index 5a3eaf64c..aef288512 100644
--- a/software/re6stnet/software.cfg
+++ b/software/re6stnet/software.cfg
@@ -88,7 +88,7 @@ extra-context =
 [template-re6stnet]
 < = download-base
 filename = instance-re6stnet.cfg.in
-md5sum = c5f535e1e25cb91f66d28f04684f0858 
+md5sum = 6e9452d283e82e2f512a9f9edb17fe3a
 
 [template-apache-conf]
 < = download-base
diff --git a/stack/erp5/buildout.hash.cfg b/stack/erp5/buildout.hash.cfg
index 622d3b6af..d85a909f4 100644
--- a/stack/erp5/buildout.hash.cfg
+++ b/stack/erp5/buildout.hash.cfg
@@ -19,11 +19,11 @@ md5sum = 372e5247d0a1514f3406228407b10d77
 
 [template-mariadb]
 filename = instance-mariadb.cfg.in
-md5sum = 5eaf56d0f5c70a12980d3c4cea27c36d
+md5sum = 11e7faca5233868c1643854e4c898588
 
 [template-kumofs]
 filename = instance-kumofs.cfg.in
-md5sum = 763db0c4a94649296e74fe1f53c03940
+md5sum = 42d2a2c7cb5bf5122b6cfd8f53a5576f
 
 [template-cloudooo]
 filename = instance-cloudoo.cfg.in
@@ -83,15 +83,15 @@ md5sum = b5f49c90017684aa3389ef3f97ece509
 
 [template-zeo]
 filename = instance-zeo.cfg.in
-md5sum = 84aba4fa10d3087fbcc1d979df90fab9
+md5sum = 7610bafda245c008ccf0b6ea58ce21c2
 
 [template-zope]
 filename = instance-zope.cfg.in
-md5sum = 3a029d0d94e4f60395b8b202f5422e91
+md5sum = 70caadf8819a76875cf5abf2f979f4d6
 
 [template-balancer]
 filename = instance-balancer.cfg.in
-md5sum = aa2092e478131d7c6d55fa9d12b6b0f2
+md5sum = d71c49f91b3455e6866f4b2db591009f
 
 [template-haproxy-cfg]
 filename = haproxy.cfg.in
diff --git a/stack/erp5/instance-balancer.cfg.in b/stack/erp5/instance-balancer.cfg.in
index 68f4a65dc..44bc452ad 100644
--- a/stack/erp5/instance-balancer.cfg.in
+++ b/stack/erp5/instance-balancer.cfg.in
@@ -185,12 +185,10 @@ crl =
 {%- endif %}
 
 [logrotate-apache]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = apache
 log = ${apache-conf-parameter-dict:error-log} ${apache-conf-parameter-dict:access-log}
-post = {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${apache-conf-parameter-dict:pid-file} -s USR1
+post = test ! -s ${apache-conf-parameter-dict:pid-file} || {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${apache-conf-parameter-dict:pid-file} -s USR1
 
 [directory]
 recipe = slapos.cookbook:mkdirectory
diff --git a/stack/erp5/instance-kumofs.cfg.in b/stack/erp5/instance-kumofs.cfg.in
index 7f0ea9970..0d68ef2b0 100644
--- a/stack/erp5/instance-kumofs.cfg.in
+++ b/stack/erp5/instance-kumofs.cfg.in
@@ -63,9 +63,7 @@ kumo-server-binary = {{ parameter_dict['kumo-location'] }}/bin/kumo-server
 shell-path = {{ parameter_dict['dash-location'] }}/bin/dash
 
 [logrotate-entry-kumofs]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = kumofs
 log = ${kumofs-instance:kumo-gateway-log} ${kumofs-instance:kumo-manager-log} ${kumofs-instance:kumo-server-log}
 
diff --git a/stack/erp5/instance-mariadb.cfg.in b/stack/erp5/instance-mariadb.cfg.in
index 117de881a..ecdb92a69 100644
--- a/stack/erp5/instance-mariadb.cfg.in
+++ b/stack/erp5/instance-mariadb.cfg.in
@@ -174,9 +174,7 @@ template = inline:#!{{ parameter_dict['dash-location'] }}/bin/dash
 rendered = ${directory:services}/mariadb
 
 [logrotate-entry-mariadb]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
+< = logrotate-entry-base
 name = mariadb
 log = ${my-cnf-parameters:error-log} ${my-cnf-parameters:slow-query-log}
 post = "${binary-wrap-mysql:wrapper-path}" -B -u root -e "FLUSH LOGS"
diff --git a/stack/erp5/instance-zeo.cfg.in b/stack/erp5/instance-zeo.cfg.in
index c2ffb4005..6c94969c9 100644
--- a/stack/erp5/instance-zeo.cfg.in
+++ b/stack/erp5/instance-zeo.cfg.in
@@ -8,11 +8,6 @@
 {% set default_backup_path = buildout_directory ~ '/srv/backup/zodb' -%}
 {% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
 
-[logrotate-base]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
-
 [zeo-base]
 recipe = slapos.cookbook:zeo
 log-path = ${directory:log}/${:base-name}.log
@@ -53,10 +48,10 @@ port = {{ current_port }}
 storage = {{ dumps(storage_list) }}
 
 [{{ section("logrotate-" ~ zeo_section_name) }}]
-< = logrotate-base
+< = logrotate-entry-base
 name = {{ "${" ~ zeo_section_name ~ ":base-name}" }}
 log = {{ "${" ~ zeo_section_name ~ ":log-path}" }}
-post = {{ bin_directory }}/slapos-kill --pidfile {{ "${" ~ zeo_section_name ~ ":pid-path}" }} -s USR2
+post = test ! -s {{ "${" ~ zeo_section_name ~":pid-path}" }} || {{ bin_directory }}/slapos-kill --pidfile {{ "${" ~ zeo_section_name ~ ":pid-path}" }} -s USR2
 
 [{{ section(zeo_section_name ~ "-promise") }}]
 recipe = slapos.cookbook:check_port_listening
diff --git a/stack/erp5/instance-zope.cfg.in b/stack/erp5/instance-zope.cfg.in
index 247a7ed6f..d26b4207c 100644
--- a/stack/erp5/instance-zope.cfg.in
+++ b/stack/erp5/instance-zope.cfg.in
@@ -260,11 +260,6 @@ timerserver-interval = {{ dumps(timerserver_interval) }}
 < = jinja2-template-base
 template = {{ parameter_dict['zope-conf-template'] }}
 
-[logrotate-entry-base]
-recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
-backup = ${logrotate:backup}
-
 {% macro zope(
   index,
   port,
@@ -356,7 +351,7 @@ path = ${directory:promises}/{{ zope_tunnel_base_name }}
 < = logrotate-entry-base
 name = {{ name }}
 log = {{ '${' ~ conf_parameter_name ~ ':event-log}' }} {{ '${' ~ conf_parameter_name ~ ':z2-log}' }} {{ '${' ~ conf_parameter_name ~ ':longrequest-logger-file}' }} {{ ' '.join(log_list) }}
-post = {{ bin_directory }}/slapos-kill --pidfile {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} -s USR2
+post = test ! -s {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} || {{ bin_directory }}/slapos-kill --pidfile {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} -s USR2
 {% endmacro -%}
 
 {% for i in range(slapparameter_dict['instance-count']) -%}
diff --git a/stack/logrotate/buildout.cfg b/stack/logrotate/buildout.cfg
index babfa6399..8f241fe25 100644
--- a/stack/logrotate/buildout.cfg
+++ b/stack/logrotate/buildout.cfg
@@ -6,13 +6,29 @@ extends =
 parts =
   template-logrotate-base
 
+[logrotate-conf-template]
+recipe = slapos.recipe.build:download
+url = ${:_profile_base_location_}/logrotate.conf.in
+md5sum = 24f021a248f2802ee70857cf3d8832f2
+# XXX: following mode should be the default
+mode = 644
+
+[logrotate-entry-template]
+recipe = slapos.recipe.build:download
+url = ${:_profile_base_location_}/logrotate_entry.in
+md5sum = 7a5ec8f141c61826a14db8619acba314
+# XXX: following mode should be the default
+mode = 644
+
 [template-logrotate-base]
 recipe = slapos.recipe.template:jinja2
 template = ${:_profile_base_location_}/${:filename}.in
 rendered = ${buildout:directory}/${:filename}
 filename = instance-logrotate-base.cfg
-md5sum = 4f940a5b5a6abac039738b45633c709c
+md5sum = 3e3e572c5537f77e83b1ee157d1c9852
 context =
     key dcron_location dcron:location
     key gzip_location gzip:location
     key logrotate_location logrotate:location
+    key logrotate_conf_template logrotate-conf-template:target
+    key logrotate_entry_template logrotate-entry-template:target
diff --git a/stack/logrotate/instance-logrotate-base.cfg.in b/stack/logrotate/instance-logrotate-base.cfg.in
index b4d4a049c..d3a3d0f5e 100644
--- a/stack/logrotate/instance-logrotate-base.cfg.in
+++ b/stack/logrotate/instance-logrotate-base.cfg.in
@@ -17,27 +17,52 @@ recipe = slapos.cookbook:simplelogger
 wrapper = ${logrotate-directory:bin}/cron_simplelogger
 log = ${logrotate-directory:log}/cron.log
 
-[logrotate]
-recipe = slapos.cookbook:logrotate
-logrotate-entries = ${logrotate-directory:logrotate-entries}
-backup = ${logrotate-directory:logrotate-backup}
-logrotate-binary = {{ logrotate_location }}/usr/sbin/logrotate
+[logrotate-conf-parameter]
 gzip-binary = {{ gzip_location }}/bin/gzip
 gunzip-binary = {{ gzip_location }}/bin/gunzip
-wrapper = ${logrotate-directory:bin}/logrotate
-conf = ${logrotate-directory:etc}/logrotate.conf
-state-file = ${logrotate-directory:srv}/logrotate.status
+logrotate-entries = ${logrotate-directory:logrotate-entries}
+
+[logrotate-conf]
+recipe = slapos.recipe.template:jinja2
+template = {{ logrotate_conf_template }}
+rendered = ${logrotate-directory:etc}/logrotate.conf
+context =
+  section parameter_dict logrotate-conf-parameter
+
+[logrotate-entry-base]
+# User must define keys:
+# - "name" to generate configuration path (must be unique in partition)
+# - "log" space-separated list of file paths to be rotated
+# User may override keys:
+# - "post" with commands to execute after rotation
+# - "pre" with commands to execute before rotation
+recipe = slapos.recipe.template:jinja2
+template = {{ logrotate_entry_template }}
+rendered = ${logrotate-conf-parameter:logrotate-entries}/${:name}
+context =
+  key backup logrotate-directory:logrotate-backup
+  key log :log
+  key post :post
+  key pre :pre
+post =
+pre =
+
+[logrotate]
+recipe = slapos.cookbook:wrapper
+parameters-extra = true
+command-line = {{ logrotate_location }}/usr/sbin/logrotate -s "${logrotate-directory:srv}/logrotate.status" "${logrotate-conf:rendered}"
+wrapper-path = ${logrotate-directory:bin}/logrotate
 
 [cron-entry-logrotate]
 recipe = slapos.cookbook:cron.d
 cron-entries = ${cron:cron-entries}
 name = logrotate
 frequency = 0 0 * * *
-command = ${logrotate:wrapper}
+command = ${logrotate:wrapper-path}
 
 [logrotate-entry-base]
 recipe = slapos.cookbook:logrotate.d
-logrotate-entries = ${logrotate:logrotate-entries}
+logrotate-entries = ${logrotate-directory:logrotate-entries}
 backup = ${logrotate-directory:backup}
 
 [logrotate-entry-cron]
@@ -58,4 +83,3 @@ backup = ${:srv}/backup
 etc = ${buildout:directory}/etc
 services = ${:etc}/run
 log = ${buildout:directory}/var/log
-
diff --git a/stack/logrotate/logrotate.conf.in b/stack/logrotate/logrotate.conf.in
new file mode 100644
index 000000000..eb9808221
--- /dev/null
+++ b/stack/logrotate/logrotate.conf.in
@@ -0,0 +1,5 @@
+compresscmd {{ parameter_dict['gzip-binary'] }}
+compressoptions -9
+uncompresscmd {{ parameter_dict['gunzip-binary'] }}
+include {{ parameter_dict['logrotate-entries'] }}
+
diff --git a/stack/logrotate/logrotate_entry.in b/stack/logrotate/logrotate_entry.in
new file mode 100644
index 000000000..22d9c28da
--- /dev/null
+++ b/stack/logrotate/logrotate_entry.in
@@ -0,0 +1,18 @@
+{{ log }} {
+  daily
+  dateext
+  rotate 3650
+  compress
+  delaycompress
+  notifempty
+  sharedscripts
+  create
+  olddir {{ backup }}
+  missingok
+  {% if pre %}prerotate {
+    {{ pre }}
+  }{% endif %}
+  {% if post %}postrotate {
+    {{ post }}
+  }{% endif %}
+}
diff --git a/stack/monitor/buildout.cfg b/stack/monitor/buildout.cfg
index 03d19d892..2b51be1e0 100644
--- a/stack/monitor/buildout.cfg
+++ b/stack/monitor/buildout.cfg
@@ -102,7 +102,7 @@ recipe = slapos.recipe.template:jinja2
 filename = template-monitor.cfg
 template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
 rendered = ${buildout:directory}/template-monitor.cfg
-md5sum = 8433adc2ad0bc3a443ff941580593fb0
+md5sum = be07297494e08377c4dfecb26c2919ef
 context =
     key apache_location apache:location
     key gzip_location gzip:location
diff --git a/stack/monitor/instance-monitor.cfg.jinja2.in b/stack/monitor/instance-monitor.cfg.jinja2.in
index f9bae9b37..41a3f1f13 100644
--- a/stack/monitor/instance-monitor.cfg.jinja2.in
+++ b/stack/monitor/instance-monitor.cfg.jinja2.in
@@ -82,7 +82,7 @@ base-url = ${monitor-instance-parameter:monitor-base-url}
 monitor-hal-json = ${monitor-directory:public}/monitor.hal.json
 service-pid-folder = ${monitor-directory:pids}
 crond-folder = ${logrotate-directory:cron-entries}
-logrotate-folder = ${logrotate:logrotate-entries}
+logrotate-folder = ${logrotate-directory:logrotate-entries}
 promise-runner = {{ monitor_runpromise }}
 promise-folder = ${directory:promises}
 monitor-promise-folder = ${monitor-directory:promises}
@@ -385,4 +385,4 @@ monitor-setup-url = ${monitor-instance-parameter:interface-url}/#page=settings_c
 [buildout]
 
 extends = 
-  {{ template_logrotate_base }}
\ No newline at end of file
+  {{ template_logrotate_base }}
-- 
2.30.9