Commit 4078d3d7 authored by Xavier Thompson's avatar Xavier Thompson

software/theia: Fix a resiliency bug

Fix takoever of a theia with initial embedded instance. The issue was
that the promise checking that the embedded instance was successfully
requested relied on files which were not transferred to backup theia.

The location of these files has been changed in order to transfer them;
therefore the old location is still checked for upgrade-compatibility.
parent e95f1e0c
......@@ -15,7 +15,7 @@
[instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = d8fa4bed6b7d7c77b0aec53abae32426
md5sum = b406265f591f54a0d5a6aa3ff8522764
[instance]
_update_hash_filename_ = instance.cfg.in
......@@ -23,11 +23,11 @@ md5sum = f322033a7670b9be29b1bf1bf9024b87
[instance-import]
_update_hash_filename_ = instance-import.cfg.jinja.in
md5sum = a343818079d4fc106594e5850cc1853a
md5sum = 6520d2aa0c1c6094cbf276080594ec1a
[instance-export]
_update_hash_filename_ = instance-export.cfg.jinja.in
md5sum = 84ceb4c9ee0f07fce8518ef7517ce1d4
md5sum = bb6d26c56b4bb9cf553c130fdd51000d
[instance-resilient]
_update_hash_filename_ = instance-resilient.cfg.jinja
......@@ -35,7 +35,7 @@ md5sum = ad9499e7355ded4975ad313442cecb7a
[slapos-standalone-script]
_update_hash_filename_ = slapos_standalone_script.py.jinja
md5sum = 93c492cc5c186989f104f37de43f25c5
md5sum = 3572b3fa458505ae25ebcea9b1ed3267
[theia-common]
_update_hash_filename_ = theia_common.py
......
......@@ -42,6 +42,7 @@ context =
raw slapos_cfg $${directory:runner}/etc/slapos.cfg
raw project_path $${directory:project}
raw public_path $${directory:frontend-static-public}
raw statefiles_path $${directory:statefiles}
key exitfile :exitcode-file
key errorfile :error-file
{%- raw %}
......@@ -55,6 +56,7 @@ inline =
--cfg {{ slapos_cfg }} \
--dirs {{ project_path }} \
--dirs {{ public_path }} \
--dirs {{ statefiles_path }} \
--exitfile {{ exitfile }} \
--errorfile {{ errorfile }}
{%- endraw %}
......
......@@ -102,6 +102,7 @@ context =
raw slapos_cfg $${directory:runner}/etc/slapos.cfg
raw project_path $${directory:project}
raw public_path $${directory:frontend-static-public}
raw statefiles_path $${directory:statefiles}
key exitfile :exitcode-file
key errorfile :error-file
{%- raw %}
......@@ -122,6 +123,7 @@ inline =
--cfg {{ slapos_cfg }} \
--dirs {{ project_path }} \
--dirs {{ public_path }} \
--dirs {{ statefiles_path }} \
--exitfile {{ exitfile }} \
--errorfile {{ errorfile }}
{%- endraw %}
......
......@@ -50,6 +50,7 @@ bin = $${:home}/bin
tmp = $${:home}/tmp
dot-theia = $${:home}/.theia/
pidfiles = $${:var}/run
statefiles = $${:var}/state
services = $${:etc}/service
runner = $${:srv}/runner
......@@ -589,7 +590,8 @@ inline =
[slapos-standalone-script]
recipe = slapos.recipe.template:jinja2
output = $${directory:bin}/$${:_buildout_section_name_}
embedded-request-exitcode-file = $${directory:etc}/embedded-request-exitcode
embedded-request-exitcode-file = $${directory:statefiles}/embedded-request.exitcode
standalone-ran-before-flag = $${directory:statefiles}/standalone-ran-before.flag
shared-part-list =
{{ """${buildout:shared-part-list}""" | indent(2) }}
context =
......@@ -599,6 +601,7 @@ context =
key request_script_template request-script-example:inline
key shared_part_list :shared-part-list
key embedded_request_exitcode_file :embedded-request-exitcode-file
key standalone_ran_before_flag :standalone-ran-before-flag
key embedded_instance_config embedded-instance-config:output
key home_path directory:home
key forward_frontend_requests :forward-frontend-requests
......
......@@ -153,10 +153,28 @@ def main():
with setupStandalone() as standalone:
config_json_file = {{ repr(embedded_instance_config) }}
done_file = config_json_file + '.done'
if not os.path.exists(done_file):
with open(done_file, 'w'): pass
# backwards compatibility
old_flag_file = config_json_file + '.done'
old_exitcode_file = os.path.join(
{{ repr(home_path) }}, 'etc', 'embedded-request-exitcode')
# new state filesstandalone_ran_before_flag
standalone_ran_before_flag = {{ repr(standalone_ran_before_flag) }}
exitcode_file = {{ repr(embedded_request_exitcode_file) }}
# backwards compatibility
if os.path.exists(old_flag_file):
logging.info("Moving old %s to %s", old_flag_file, standalone_ran_before_flag)
os.rename(old_flag_file, standalone_ran_before_flag)
if os.path.exists(old_exitcode_file):
logging.info("Moving old %s to %s", old_exitcode_file, exitcode_file)
os.rename(old_exitcode_file, exitcode_file)
elif not os.path.exists(standalone_ran_before_flag):
logging.info("First run!")
logging.info("Creating flag file %s", standalone_ran_before_flag)
with open(standalone_ran_before_flag, 'x'): pass
try:
config = parseEmbeddedInstanceConfig(config_json_file)
except Exception:
......@@ -172,7 +190,7 @@ def main():
'SLAPOS_CONFIGURATION': standalone._slapos_config,
'SLAPOS_CLIENT_CONFIGURATION': standalone._slapos_config,
})
with open({{ repr(embedded_request_exitcode_file) }}, 'w') as f:
with open(exitcode_file, 'w') as f:
f.write(str(exitcode))
except Exception:
logging.info("Failed to request embedded instance", exc_info=True)
......
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