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

Merge branch 'devel/fixes' into 'master'

Various small fixes

See merge request !16
parents bb86ce58 e1a88f0f
Pipeline #4530 passed with stages
in 4 minutes and 53 seconds
{% extends "base_user.html" %}
{% block title %}Inspect execution {{ }}{% 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>
function format_timestamp(ts) {
var m = moment.utc(ts);
{% endblock %}
{% block content %}
<h1>Zoe - Analytics on demand</h1>
<h2>Detailed information for execution {{ }}</h2>
......@@ -17,6 +17,7 @@
This module contains the entrypoint for the commandline Zoe client
import datetime
import json
import logging
import os
......@@ -30,6 +31,7 @@ from zoe_cmd import utils
from import ZoeInfoAPI
from zoe_lib.exceptions import ZoeAPIException, InvalidApplicationDescription
from zoe_lib.executions import ZoeExecutionsAPI
from import ZoeServiceAPI
from zoe_lib.applications import app_validate
from zoe_lib.version import ZOE_API_VERSION
......@@ -80,6 +82,51 @@ def exec_list_cmd(auth, args):
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(
if execution is None:
print('Execution not found')
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('Time submit: {}'.format(datetime.datetime.fromtimestamp(execution['time_submit'])))
if execution['time_start'] is None:
print('Time start: {}'.format('not yet'))
print('Time start: {}'.format(datetime.datetime.fromtimestamp(execution['time_start'])))
if execution['time_end'] is None:
print('Time end: {}'.format('not yet'))
print('Time end: {}'.format(datetime.datetime.fromtimestamp(execution['time_end'])))
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]))
print('This ZApp does not expose any endpoint')
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 '']
headers = ['ID', 'Name', 'Essential', 'Zoe status', 'Backend status', 'Error message']
print(tabulate(tabular_data, headers))
def exec_rm_cmd(auth, args):
"""Delete an execution and kill it if necessary."""
exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass'])
......@@ -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_execution_get = subparser.add_parser('exec-get', help="Get execution status")
argparser_execution_get.add_argument('id', type=int, help="Execution id")
argparser_execution_rm = subparser.add_parser('exec-rm', help="Deletes an execution")
argparser_execution_rm.add_argument('id', type=int, help="Execution id")
......@@ -338,6 +338,8 @@ class SwarmClient:
ret = self.cli.containers.list(all=True)
except docker.errors.APIError as ex:
raise ZoeException(str(ex))
except requests.exceptions.RequestException as ex:
raise ZoeException(str(ex))
conts = []
for cont_info in ret:
match = True
"""Classes to hold the system state and simulated container/service placements"""
import logging
from zoe_lib.state.sql_manager import Execution, Service
from zoe_master.stats import ClusterStats, NodeStats
log = logging.getLogger(__name__)
class SimulatedNode:
"""A simulated node where containers can be run"""
......@@ -72,6 +76,7 @@ class SimulatedPlatform:
if len(candidate_nodes) == 0: # this service does not fit anywhere
log.debug('Cannot fit essential service {}, bailing out'.format(
return False
candidate_nodes.sort(key=lambda n: n.container_count) # smallest first
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