diff --git a/software/theia/buildout.hash.cfg b/software/theia/buildout.hash.cfg index 3d0c55fe801799e875212163ab5204dfeb00ad1d..dc9179bd282c63c2121aa4b4f497beed6cfcd19a 100644 --- a/software/theia/buildout.hash.cfg +++ b/software/theia/buildout.hash.cfg @@ -23,7 +23,7 @@ md5sum = a7d78b4002266c69ece05a476df82791 [instance-import] _update_hash_filename_ = instance-import.cfg.jinja.in -md5sum = b1e1a31b0ca3fc0be7de259f05f80c5d +md5sum = 861ef130f27175c2978a9b946b138dd5 [instance-export] _update_hash_filename_ = instance-export.cfg.jinja.in diff --git a/software/theia/instance-import.cfg.jinja.in b/software/theia/instance-import.cfg.jinja.in index 9b5257e7cba8afc2c7e296cde0a720f9e59e36f0..109d370315d3bb4b39db7cd962368359c865192b 100644 --- a/software/theia/instance-import.cfg.jinja.in +++ b/software/theia/instance-import.cfg.jinja.in @@ -119,6 +119,50 @@ template = {%- endraw %} +# Add a promise to check that the import script has run +# successfully and recently (at most 2 days ago). +[promises] +import-promises = + $${import-promise:name} + +[import-promise] +<= monitor-promise-base +module = check_command_execute +name = resiliency-import-promise.py +config-command = $${import-promise-script:rendered} + +[initial-import-exitcode-file] +recipe = slapos.recipe.template:jinja2 +rendered = $${theia-import-script:exitcode-file} +template = inline:0 +once = $${:rendered} + +[import-promise-script] +recipe = slapos.recipe.template:jinja2 +rendered = $${directory:bin}/import-promise-script +exitcode-file = $${initial-import-exitcode-file:rendered} +context = + key exitcodefile :exitcode-file + key errorfile theia-import-script:error-file +{%- raw %} +template = + inline:#!/bin/sh + if [ -z $(find {{ repr(exitcodefile) }} -mtime -2) ] + then + echo "ERROR import script last ran on " $(date -r {{ repr(exitcodefile) }}) + exit 1 + elif [ $( cat {{ repr(exitcodefile) }}) -ne 0 ] + then + echo "ERROR import script failed on " $(date -r {{ repr(exitcodefile) }}) + cat {{ repr(errorfile) }} + exit 1 + else + echo "OK import script last ran on " $(date -r {{ repr(exitcodefile) }}) + exit 0 + fi +{%- endraw %} + + # Resilient connection parameters of import instance are published # through the resilient stack. # Extend resilient parameters with normal theia connection parameters