Commit 4500adda authored by Daniele Venzano's avatar Daniele Venzano 🏇
Browse files

Merge branch 'devel/platform_status' into 'master'

Fix resource limits set from the web interface

See merge request !44
parents 1953fe8d b0932ad8
...@@ -146,24 +146,34 @@ class ZAppStartWeb(ZoeRequestHandler): ...@@ -146,24 +146,34 @@ class ZAppStartWeb(ZoeRequestHandler):
if service['name'] == param.name: if service['name'] == param.name:
service['command'] = self.get_argument(argument_name) service['command'] = self.get_argument(argument_name)
break break
elif param.kind == 'resource_memory_min' and role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)):
for service in app_descr['services']:
if service['name'] == param.name:
if self.get_argument(argument_name) >= get_conf().max_memory_limit * (1024 ** 3):
val = get_conf().max_memory_limit * (1024 ** 3)
else:
val = self.get_argument(argument_name)
service["resources"]["memory"]["min"] = val
break
elif param.kind == 'resource_cores_min' and role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)):
for service in app_descr['services']:
if service['name'] == param.name:
if self.get_argument(argument_name) >= get_conf().max_core_limit:
val = get_conf().max_core_limit
else:
val = self.get_argument(argument_name)
service["resources"]["cores"]["min"] = val
break
else: else:
log.warning('Unknown parameter kind: {}, ignoring...'.format(param.kind)) log.warning('Unknown parameter kind: {}, ignoring...'.format(param.kind))
if role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)):
for service in app_descr['services']:
argument_name = service['name'] + '-resource_memory_min'
try:
self.get_argument(argument_name)
except MissingArgumentError:
pass
else:
if float(self.get_argument(argument_name)) >= get_conf().max_memory_limit:
val = int(get_conf().max_memory_limit * (1024 ** 3))
else:
val = int(float(self.get_argument(argument_name)) * (1024 ** 3))
service["resources"]["memory"]["min"] = val
argument_name = service['name'] + '-resource_cores_min'
try:
self.get_argument(argument_name)
except MissingArgumentError:
pass
else:
if float(self.get_argument(argument_name)) >= get_conf().max_core_limit:
val = get_conf().max_core_limit
else:
val = float(self.get_argument(argument_name))
service["resources"]["cores"]["min"] = val
break
return app_descr return app_descr
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