Commit 865df6c8 authored by Daniele Venzano's avatar Daniele Venzano 🏇

Merge branch 'devel/fixes' into 'master'

Various small fixes

See merge request !16
parents bb86ce58 e1a88f0f
{% extends "base_user.html" %} {% extends "base_user.html" %}
{% block title %}Inspect execution {{ e.name }}{% endblock %} {% block title %}Inspect execution {{ e.name }}{% endblock %}
{% block custom_head %}
<script src="/static/moment.min.js" type="application/javascript"></script>
<script src="/static/moment-timezone.min.js" type="application/javascript"></script>
<script>
function format_timestamp(ts) {
var m = moment.utc(ts);
m.local();
document.write(m.calendar());
}
</script>
{% endblock %}
{% block content %} {% block content %}
<h1>Zoe - Analytics on demand</h1> <h1>Zoe - Analytics on demand</h1>
<h2>Detailed information for execution {{ e.name }}</h2> <h2>Detailed information for execution {{ e.name }}</h2>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
This module contains the entrypoint for the commandline Zoe client This module contains the entrypoint for the commandline Zoe client
""" """
import datetime
import json import json
import logging import logging
import os import os
...@@ -30,6 +31,7 @@ from zoe_cmd import utils ...@@ -30,6 +31,7 @@ from zoe_cmd import utils
from zoe_lib.info import ZoeInfoAPI from zoe_lib.info import ZoeInfoAPI
from zoe_lib.exceptions import ZoeAPIException, InvalidApplicationDescription from zoe_lib.exceptions import ZoeAPIException, InvalidApplicationDescription
from zoe_lib.executions import ZoeExecutionsAPI from zoe_lib.executions import ZoeExecutionsAPI
from zoe_lib.services import ZoeServiceAPI
from zoe_lib.applications import app_validate from zoe_lib.applications import app_validate
from zoe_lib.version import ZOE_API_VERSION from zoe_lib.version import ZOE_API_VERSION
...@@ -80,6 +82,51 @@ def exec_list_cmd(auth, args): ...@@ -80,6 +82,51 @@ def exec_list_cmd(auth, args):
print(tabulate(tabular_data, headers)) print(tabulate(tabular_data, headers))
def exec_get_cmd(auth, args):
"""Gather information about an execution."""
exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass'])
cont_api = ZoeServiceAPI(auth['url'], auth['user'], auth['pass'])
execution = exec_api.get(args.id)
if execution is None:
print('Execution not found')
else:
print('Execution {} (ID: {})'.format(execution['name'], execution['id']))
print('Application name: {}'.format(execution['description']['name']))
print('Status: {}'.format(execution['status']))
if execution['status'] == 'error':
print('Last error: {}'.format(execution['error_message']))
print()
print('Time submit: {}'.format(datetime.datetime.fromtimestamp(execution['time_submit'])))
if execution['time_start'] is None:
print('Time start: {}'.format('not yet'))
else:
print('Time start: {}'.format(datetime.datetime.fromtimestamp(execution['time_start'])))
if execution['time_end'] is None:
print('Time end: {}'.format('not yet'))
else:
print('Time end: {}'.format(datetime.datetime.fromtimestamp(execution['time_end'])))
print()
endpoints = exec_api.endpoints(execution['id'])
if endpoints is not None and len(endpoints) > 0:
print('Exposed endpoints:')
for endpoint in endpoints:
print(' - {}: {}'.format(endpoint[0], endpoint[1]))
else:
print('This ZApp does not expose any endpoint')
print()
tabular_data = []
for c_id in execution['services']:
service = cont_api.get(c_id)
service_data = [service['id'], service['name'], 'true' if service['essential'] else 'false', service['status'], service['backend_status'], service['error_message'] if service['error_message'] is not None else '']
tabular_data.append(service_data)
headers = ['ID', 'Name', 'Essential', 'Zoe status', 'Backend status', 'Error message']
print(tabulate(tabular_data, headers))
def exec_rm_cmd(auth, args): def exec_rm_cmd(auth, args):
"""Delete an execution and kill it if necessary.""" """Delete an execution and kill it if necessary."""
exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass']) exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass'])
...@@ -127,6 +174,10 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]: ...@@ -127,6 +174,10 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]:
argparser_app_list.add_argument('--later-than-end', help='Show only executions ended later than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--later-than-end', help='Show only executions ended later than this timestamp (seconds since UTC epoch)')
argparser_app_list.set_defaults(func=exec_list_cmd) argparser_app_list.set_defaults(func=exec_list_cmd)
argparser_execution_get = subparser.add_parser('exec-get', help="Get execution status")
argparser_execution_get.add_argument('id', type=int, help="Execution id")
argparser_execution_get.set_defaults(func=exec_get_cmd)
argparser_execution_rm = subparser.add_parser('exec-rm', help="Deletes an execution") argparser_execution_rm = subparser.add_parser('exec-rm', help="Deletes an execution")
argparser_execution_rm.add_argument('id', type=int, help="Execution id") argparser_execution_rm.add_argument('id', type=int, help="Execution id")
argparser_execution_rm.set_defaults(func=exec_rm_cmd) argparser_execution_rm.set_defaults(func=exec_rm_cmd)
......
...@@ -338,6 +338,8 @@ class SwarmClient: ...@@ -338,6 +338,8 @@ class SwarmClient:
ret = self.cli.containers.list(all=True) ret = self.cli.containers.list(all=True)
except docker.errors.APIError as ex: except docker.errors.APIError as ex:
raise ZoeException(str(ex)) raise ZoeException(str(ex))
except requests.exceptions.RequestException as ex:
raise ZoeException(str(ex))
conts = [] conts = []
for cont_info in ret: for cont_info in ret:
match = True match = True
......
"""Classes to hold the system state and simulated container/service placements""" """Classes to hold the system state and simulated container/service placements"""
import logging
from zoe_lib.state.sql_manager import Execution, Service from zoe_lib.state.sql_manager import Execution, Service
from zoe_master.stats import ClusterStats, NodeStats from zoe_master.stats import ClusterStats, NodeStats
log = logging.getLogger(__name__)
class SimulatedNode: class SimulatedNode:
"""A simulated node where containers can be run""" """A simulated node where containers can be run"""
...@@ -72,6 +76,7 @@ class SimulatedPlatform: ...@@ -72,6 +76,7 @@ class SimulatedPlatform:
candidate_nodes.append(node) candidate_nodes.append(node)
if len(candidate_nodes) == 0: # this service does not fit anywhere if len(candidate_nodes) == 0: # this service does not fit anywhere
self.deallocate_essential(execution) self.deallocate_essential(execution)
log.debug('Cannot fit essential service {}, bailing out'.format(service.id))
return False return False
candidate_nodes.sort(key=lambda n: n.container_count) # smallest first candidate_nodes.sort(key=lambda n: n.container_count) # smallest first
candidate_nodes[0].service_add(service) candidate_nodes[0].service_add(service)
......
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