Commit 3f0267a6 authored by Daniele Venzano's avatar Daniele Venzano

Add top-level zapp parameter to disable all services/containers auto restart policy

parent ffbd7546
......@@ -42,6 +42,13 @@ required, number [0, 1024)
For now this value is unused.
disable_autorestart
^^^^^^^^^^^^^^^^^^^
optional, boolean
If set to true, disables all kinds of auorestart on all services of this ZApp.
requires_binary
^^^^^^^^^^^^^^^
......@@ -121,6 +128,8 @@ If set to ``false``, Zoe will configure Docker to automatically restart the serv
Please note that at least one service must be set as a monitor for each ZApp.
All autorestart behaviour is disabled if the global parameter ``disable_autorestart`` (see above) is enabled.
total_count
^^^^^^^^^^^
......
......@@ -150,6 +150,12 @@ def _service_check(data):
if not hasattr(data['constraints'], '__iter__'):
raise InvalidApplicationDescription(msg='networks should be an iterable')
if 'disable_autorestart' in data:
try:
bool(data['disable_autorestart'])
except ValueError:
raise InvalidApplicationDescription(msg="disable_autorestart field should be a boolean")
def _port_check(data):
required_keys = ['name', 'protocol', 'port_number', 'is_main_endpoint']
......
......@@ -87,7 +87,9 @@ def _spawn_service(execution: Execution, service: Service, env_subst_dict: dict)
copts.labels['zoe.monitor'] = 'true'
else:
copts.labels['zoe.monitor'] = 'false'
copts.restart = not service.description['monitor'] # Monitor containers should not restart
if 'disable_autorestart' in execution.description and execution.description['disable_autorestart']:
copts.restart = not service.description['monitor'] # Monitor containers should not restart
_gen_environment(service, env_subst_dict, copts)
......
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