Commit 67c4ac88 authored by Xavier Thompson's avatar Xavier Thompson

software/theia: Fix standalone ready promise

Include the hash of the relevant parameters in the abstract socket path,
so that when changing these instance parameters the promise waits until
the standalone service has taken the new parameters into account.
parent e311101e
......@@ -15,15 +15,15 @@
[instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = 04b0722106393aaa54bab960dc73435a
md5sum = ec79bbbd446750a631898a96c8bd346d
[instance]
_update_hash_filename_ = instance.cfg.in
md5sum = 94703df1104405a5a73aa1bc980ea370
md5sum = f2f01a47d98a980177dc1755e618bbb7
[instance-import]
_update_hash_filename_ = instance-import.cfg.jinja.in
md5sum = 57b707cf0ed83be1959d26a88c131906
md5sum = 28c8867083054f7771db36c544f2c985
[instance-export]
_update_hash_filename_ = instance-export.cfg.jinja.in
......
......@@ -29,6 +29,11 @@ name = Import {{ parameter_dict['additional-frontend-name'] }}
{%- endif %}
# Change standalone socket path to avoid collisions
[slapos-standalone-config]
abstract-socket-path = $${directory:home}/standalone-import-ready
# Change port ranges to avoid race conditions on port allocation
[frontend-instance-port]
minimum = 3200
......
......@@ -151,7 +151,7 @@ config-port = $${slapos-standalone-instance:port}
<= monitor-promise-base
promise = check_socket_listening
name = standalone-ready-promise.py
config-abstract = $${directory:runner}/standalone_ready
config-abstract = $${slapos-standalone-config:abstract-socket-path}
[slapos-autorun-promise]
<= monitor-promise-base
......@@ -476,6 +476,9 @@ template =
{%- endif %}
{%- endif %}
{%- set embedded_digest = str(embedded_sr) + str(embedded_sr_type) + str(embedded_instance_parameters) %}
{%- set embedded_digest_hash = hashlib_module.md5(embedded_digest.encode()).hexdigest() %}
# SlapOS Standalone
# -----------------
......@@ -493,6 +496,7 @@ port = $${slapos-standalone-port:port}
local-software-release-root = $${directory:home}
slapos-configuration = $${directory:runner}/etc/slapos.cfg
computer-id = slaprunner
abstract-socket-path = $${directory:home}/standalone-{{ embedded_digest_hash[:16] }}
[slapos-standalone-activate]
recipe = slapos.recipe.template:jinja2
......@@ -524,6 +528,7 @@ template =
{%- if embedded_sr %}
--slapos_script=$${request-embedded-instance-script:rendered} \
{%- endif %}
--abstract_socket_path='$${slapos-standalone-config:abstract-socket-path}' \
$${slap-connection:server-url} \
$${slap-connection:computer-id} \
$${slap-connection:partition-id} \
......
......@@ -40,6 +40,7 @@ context =
key ipv6_random slap-configuration:ipv6-random
key ipv4_random slap-configuration:ipv4-random
import os_module os
import hashlib_module hashlib
default-parameters =
{
"autorun": "running",
......
......@@ -76,6 +76,7 @@ initialization =
parser.add_argument('local_software_release_root')
parser.add_argument('computer_id')
parser.add_argument('--slapos_script')
parser.add_argument('--abstract_socket_path')
forwarded_arguments = parser.add_argument_group('forwarded')
forwarded_arguments.add_argument('master_url')
forwarded_arguments.add_argument('computer')
......@@ -151,7 +152,7 @@ initialization =
subprocess.call((args.slapos_script,), env=slapos_env)
s = socket.socket(socket.AF_UNIX)
s.bind('\0' + os.path.join(args.base_directory, 'standalone_ready'))
s.bind('\0' + args.abstract_socket_path)
s.listen(5)
print("Standalone SlapOS ready")
while 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