Commit 9d493c1c authored by Nicolas Wavrant's avatar Nicolas Wavrant

slaprunner/resilient: generate and store random value using publish_early.

This commit is a fix for 8787716d. It allows to get the random cron string
generated previously through parameters, and not reading manually .installed.cfg.
parent abd1d19a
......@@ -53,7 +53,7 @@ parts =
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
md5sum = bb7e0bf9959c4437ff1e23e645315ccf
md5sum = 62c2ad4b0e2fe3edad27bdb885dee626
mode = 0644
[template-runner]
......@@ -92,7 +92,7 @@ mode = 0644
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-runner-export.cfg.in
output = ${buildout:directory}/instance-runner-export.cfg
md5sum = ec92773be8f8a2ad20dc0661d58d7717
md5sum = fb0974c51380eef28d4839318e0ef6e2
mode = 0644
[template-resilient]
......
[buildout]
extends = template-runner.cfg
${pbsready-export:output}
pbsready-exporter.cfg
parts +=
nginx_conf
......
[buildout]
parts =
template-pbsready-export
switch_softwaretype
eggs-directory = ${buildout:eggs-directory}
......@@ -58,10 +59,18 @@ context =
key slapparameter_dict slap-configuration:configuration
mode = 0644
[template-pbsready-export]
recipe = slapos.recipe.template:jinja2
template = ${pbsready-export:output}
rendered = $${buildout:directory}/pbsready-exporter.cfg
mode = 640
context =
key slapparameter_dict slap-configuration:configuration
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
cert = $${slap-connection:cert-file}
\ No newline at end of file
......@@ -59,7 +59,7 @@ mode = 0644
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/pbsready-export.cfg.in
output = ${buildout:directory}/pbsready-export.cfg
md5sum = 2f88afa7878ce60a5f8874a002b1a33e
md5sum = 7539454fff5b9d271acf06615f333653
mode = 0644
[template-pull-backup]
......
......@@ -48,6 +48,7 @@ ip = $${notifier:host}
[resilient-publish-connection-parameter]
notification-id = http://[$${notifier:host}]:$${notifier:port}/get/$${notifier-exporter:name}
-extends = publish-early
[notifier-exporter]
# notifier.notify launches an (exporter) executable, and when finished,
......@@ -83,10 +84,22 @@ rendered = $${basedirectory:promises}/exporter-status
<= cron
recipe = slapos.cookbook:cron.d
name = backup
frequency = $${slap-parameter:resiliency-backup-periodicity}
once-a-day = true
{% set resiliency_backup_periodicity = slapparameter_dict.get('resiliency-backup-periodicity') %}
{% if resiliency_backup_periodicity %}
frequency = {{ resiliency_backup_periodicity }}
{% else %}
time = $${publish-early:resiliency-backup-periodicity}
{% endif %}
command = ${logrotate:location}/sbin/logrotate -s $${basedirectory:run}/logrotate.status $${logrotate-entry-notifier:output}; $${notifier-exporter:wrapper} --transaction-id `date +%s`
[gen-resiliency-backup-periodicity]
recipe = slapos.cookbook:cron.random.time
[publish-early]
recipe = slapos.cookbook:publish-early
-init =
resiliency-backup-periodicity gen-resiliency-backup-periodicity:time
[slap-parameter]
# In cron.d format (i.e things like */15 * * * * are accepted).
resiliency-backup-periodicity =
  • @jm @rafael @alain.takoudjou

    This commit tries to fix 8787716d, after Julien's comment. This is the way on which Julien and me worked to store correctly the randomly generated parameter used for the cron.d frequency.

    This commit can still be improved to render pbsready-export.cfg.in only for the runner-export instance, and the KVM SR must be updated too, but I want first to get a opinion from everybody about it.

    From now, the random "frequency" cron string is generated from a custom recipe (see parent's commit). Thanks to Jinja templating, we can or force the generation of it, or override it thanks to slap-parameters.

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