Commit 7e10cad3 authored by Łukasz Nowak's avatar Łukasz Nowak

rapid-cdn: Fix logrotate-setup-validate race-condition

Call to logrotate-setup-validate can take a lot of time and fill the state
file with some message from logrotate and in the same time the promise can
kick in resulting with false-positive alarm.

By using the temporary file such race condition is avoided. Promise running
periodically will detect problem with logrotate setup.
parent a039c8cf
Pipeline #30275 passed with stage
in 0 seconds
......@@ -22,7 +22,7 @@ md5sum = 5784bea3bd608913769ff9a8afcccb68
[profile-frontend]
filename = instance-frontend.cfg.in
md5sum = 5c2f79d0773bd8594ccf1c34a7d27d53
md5sum = 9a33900d735ef074b5887d61bca54243
[profile-master]
filename = instance-master.cfg.in
......@@ -102,7 +102,7 @@ md5sum = e82ccdb0b26552a1c88ff523d8fae24a
[profile-kedifa]
filename = instance-kedifa.cfg.in
md5sum = a9854d48e750b3599043715c95138d5d
md5sum = 669da915003122e48646dc75fec239a5
[template-frontend-haproxy-rsyslogd-conf]
_update_hash_filename_ = templates/frontend-haproxy-rsyslogd.conf.in
......
......@@ -1105,12 +1105,16 @@ delaycompress =
url = {{ software_parameter_dict['template_wrapper'] }}
output = ${directory:scripts}/logrotate-setup-validate
command =
if ${logrotate:wrapper-path} -d > ${:state-file} 2>&1 ; then
if ${logrotate:wrapper-path} -d > ${:state-file-tmp} 2>&1 ; then
cat /dev/null > ${:state-file}
rm -f ${:state-file-tmp}
else
mv ${:state-file-tmp} ${:state-file}
fi
extra-context =
key content :command
state-file = ${directory:run}/logrotate-setup.state
state-file-tmp = ${:state-file}.tmp
[promise-logrotate-setup]
<= monitor-promise-base
......
......@@ -329,12 +329,16 @@ monitor-base-url = ${monitor-instance-parameter:monitor-base-url}
url = {{ software_parameter_dict['template_wrapper'] }}
output = ${directory:scripts}/logrotate-setup-validate
command =
if ${logrotate:wrapper-path} -d > ${:state-file} 2>&1 ; then
if ${logrotate:wrapper-path} -d > ${:state-file-tmp} 2>&1 ; then
cat /dev/null > ${:state-file}
rm -f ${:state-file-tmp}
else
mv ${:state-file-tmp} ${:state-file}
fi
extra-context =
key content :command
state-file = ${directory:run}/logrotate-setup.state
state-file-tmp = ${:state-file}.tmp
[promise-logrotate-setup]
<= monitor-promise-base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment