Commit 59017890 authored by Daniele Venzano's avatar Daniele Venzano

Fix status page crash when service is in transient state being terminated

parent 86a496e3
......@@ -160,6 +160,10 @@ class APIEndpoint:
"""Retrieve statistics about the scheduler."""
success, message = self.master.scheduler_statistics()
if success:
for node in message['platform_stats']['nodes']: # JSON does not like hash keys to be integers, so we need to convert manually
for str_service_id in list(node['service_stats'].keys()):
node['service_stats'][int(str_service_id)] = node['service_stats'][str_service_id]
del node['service_stats'][str_service_id]
return message
def cleanup_dead_executions(self):
......
......@@ -101,7 +101,7 @@ class APIManager:
}
return self._request_reply(msg)
def scheduler_statistics(self) -> APIReturnType:
def scheduler_statistics(self):
"""Query scheduler statistics."""
msg = {
'command': 'scheduler_stats'
......
......@@ -222,7 +222,7 @@
<td class="cell-host">{{ node.name }}</td>
{% for service in services_per_node[node.name] %}
{% if service.backend_status == "started" %}
<td><a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a> (M: <script>format_bytes({{ node.service_stats[service['id']|string]['mem_limit'] }});</script> C: {{ '%0.2f'|format(node.service_stats[service['id']|string]['core_limit']|float) }})</td>
<td><a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a> (M: <script>format_bytes({{ node.service_stats[service['id']]['mem_limit'] }});</script> C: {{ '%0.2f'|format(node.service_stats[service['id']]['core_limit']|float) }})</td>
{% endif %}
{% endfor %}
</tr>
......
......@@ -226,7 +226,6 @@ class Service(BaseRecord):
def assign_backend_host(self, backend_host):
"""Assign this service to a host in particular."""
self.sql_manager.services.update(self.id, backend_host=backend_host)
log.debug('service {} assigned to host {}'.format(self.id, backend_host))
self.backend_host = backend_host
@property
......
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