Commit 629f2f13 authored by Daniele Venzano's avatar Daniele Venzano

Rename the scheduled state: queued is a better description

parent 2acb9dba
...@@ -131,7 +131,7 @@ Will return a JSON document like this:: ...@@ -131,7 +131,7 @@ Will return a JSON document like this::
Where: Where:
* ``status`` is the execution status. It can be on of "submitted", "scheduled", "starting", "error", "running", "cleaning up", "terminated" * ``status`` is the execution status. It can be on of "submitted", "queued", "starting", "error", "running", "cleaning up", "terminated"
* ``description`` is the full ZApp description as submitted by the user * ``description`` is the full ZApp description as submitted by the user
* ``error_message`` contains the error message in case ``status`` is equal to error * ``error_message`` contains the error message in case ``status`` is equal to error
* ``time_submit`` is the time the execution was submitted to Zoe * ``time_submit`` is the time the execution was submitted to Zoe
...@@ -203,7 +203,7 @@ You need to pass via the URL (GET parameters) the criteria to be used for filter ...@@ -203,7 +203,7 @@ You need to pass via the URL (GET parameters) the criteria to be used for filter
Valid criteria that can be used are: Valid criteria that can be used are:
* status: one of submitted, scheduled, starting, error, running, cleaning up, terminated * status: one of submitted, queued, starting, error, running, cleaning up, terminated
* name: execution mane * name: execution mane
* user_id: user_id owning the execution (admin only) * user_id: user_id owning the execution (admin only)
* limit: limit the number of returned entries * limit: limit the number of returned entries
......
...@@ -77,7 +77,7 @@ class APIEndpoint: ...@@ -77,7 +77,7 @@ class APIEndpoint:
running_execs = self.sql.executions.select(**{'status': 'running', 'user_id': user.id}) running_execs = self.sql.executions.select(**{'status': 'running', 'user_id': user.id})
running_execs += self.sql.executions.select(**{'status': 'starting', 'user_id': user.id}) running_execs += self.sql.executions.select(**{'status': 'starting', 'user_id': user.id})
running_execs += self.sql.executions.select(**{'status': 'scheduled', 'user_id': user.id}) running_execs += self.sql.executions.select(**{'status': 'queued', 'user_id': user.id})
running_execs += self.sql.executions.select(**{'status': 'image download', 'user_id': user.id}) running_execs += self.sql.executions.select(**{'status': 'image download', 'user_id': user.id})
running_execs += self.sql.executions.select(**{'status': 'submitted', 'user_id': user.id}) running_execs += self.sql.executions.select(**{'status': 'submitted', 'user_id': user.id})
if quota.concurrent_executions != 0 and len(running_execs) >= quota.concurrent_executions: if quota.concurrent_executions != 0 and len(running_execs) >= quota.concurrent_executions:
...@@ -408,7 +408,7 @@ class APIEndpoint: ...@@ -408,7 +408,7 @@ class APIEndpoint:
"""Scan the active executions and kill all those that exceed the runtime_limit quota.""" """Scan the active executions and kill all those that exceed the runtime_limit quota."""
running_execs = self.sql.executions.select(**{'status': 'running'}) running_execs = self.sql.executions.select(**{'status': 'running'})
running_execs += self.sql.executions.select(**{'status': 'starting'}) running_execs += self.sql.executions.select(**{'status': 'starting'})
running_execs += self.sql.executions.select(**{'status': 'scheduled'}) running_execs += self.sql.executions.select(**{'status': 'queued'})
running_execs += self.sql.executions.select(**{'status': 'image download'}) running_execs += self.sql.executions.select(**{'status': 'image download'})
running_execs += self.sql.executions.select(**{'status': 'submitted'}) running_execs += self.sql.executions.select(**{'status': 'submitted'})
......
...@@ -83,7 +83,7 @@ class ExecutionCollectionAPI(ZoeAPIRequestHandler): ...@@ -83,7 +83,7 @@ class ExecutionCollectionAPI(ZoeAPIRequestHandler):
The list can be filtered by passing a non-empty JSON dictionary. Any combination of the following filters is supported: The list can be filtered by passing a non-empty JSON dictionary. Any combination of the following filters is supported:
* status: one of submitted, scheduled, starting, error, running, cleaning up, terminated * status: one of submitted, queued, starting, error, running, cleaning up, terminated
* name: execution mane * name: execution mane
* user_id: user_id owning the execution (admin only) * user_id: user_id owning the execution (admin only)
* limit: limit the number of returned entries * limit: limit the number of returned entries
......
...@@ -91,7 +91,7 @@ class HomeWeb(ZoeWebRequestHandler): ...@@ -91,7 +91,7 @@ class HomeWeb(ZoeWebRequestHandler):
filters = { filters = {
"user_id": self.current_user.id, "user_id": self.current_user.id,
"status": "scheduled" "status": "queued"
} }
last_running_executions += self.api_endpoint.execution_list(self.current_user, **filters) last_running_executions += self.api_endpoint.execution_list(self.current_user, **filters)
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
{% else %} {% else %}
{% if e.status == "running" %} {% if e.status == "running" %}
<p>This execution does not have any active endpoint</p> <p>This execution does not have any active endpoint</p>
{% elif e.status == "submitted" or e.status == "starting" or e.status == "scheduled" %} {% elif e.status == "submitted" or e.status == "starting" or e.status == "queued" %}
<p>Please wait, the execution is starting up. This page will refresh automatically.</p> <p>Please wait, the execution is starting up. This page will refresh automatically.</p>
{% else %} {% else %}
<p>No endpoints are available</p> <p>No endpoints are available</p>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<th>User</th> <th>User</th>
{% endif %} {% endif %}
<th>Status</th> <th>Status</th>
<th>Scheduled</th> <th>Submitted</th>
<th>Started</th> <th>Started</th>
<th>Finished</th> <th>Finished</th>
<th class="sorttable_nosort">Actions</th> <th class="sorttable_nosort">Actions</th>
......
...@@ -67,7 +67,7 @@ class ZoeExecutionsAPI(ZoeAPIBase): ...@@ -67,7 +67,7 @@ class ZoeExecutionsAPI(ZoeAPIBase):
The list can be filtered by passing arguments. Any combination of the following filters is supported: The list can be filtered by passing arguments. Any combination of the following filters is supported:
* status: one of submitted, scheduled, starting, error, running, cleaning up, terminated * status: one of submitted, queued, starting, error, running, cleaning up, terminated
* name: execution mane * name: execution mane
* user_id: user_id owning the execution (admin only) * user_id: user_id owning the execution (admin only)
* limit: limit the number of returned entries * limit: limit the number of returned entries
......
...@@ -97,9 +97,9 @@ def exec_start_cmd(api: ZoeAPI, args): ...@@ -97,9 +97,9 @@ def exec_start_cmd(api: ZoeAPI, args):
app_descr = json.load(args.jsonfile) app_descr = json.load(args.jsonfile)
exec_id = api.executions.start(args.name, app_descr) exec_id = api.executions.start(args.name, app_descr)
if not args.synchronous: if not args.synchronous:
print("Application scheduled successfully with ID {}, use the exec-get command to check its status".format(exec_id)) print("Execution created successfully with ID {}, use the exec-get command to check its status".format(exec_id))
else: else:
print("Application scheduled successfully with ID {}, waiting for status change".format(exec_id)) print("Execution created successfully with ID {}, waiting for status change".format(exec_id))
old_status = 'submitted' old_status = 'submitted'
while True: while True:
execution = api.executions.get(exec_id) execution = api.executions.get(exec_id)
...@@ -224,7 +224,7 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]: ...@@ -224,7 +224,7 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]:
argparser_app_list = subparser.add_parser('exec-ls', help="List all executions for the calling user") argparser_app_list = subparser.add_parser('exec-ls', help="List all executions for the calling user")
argparser_app_list.add_argument('--limit', type=int, help='Limit the number of executions') argparser_app_list.add_argument('--limit', type=int, help='Limit the number of executions')
argparser_app_list.add_argument('--name', help='Show only executions with this name') argparser_app_list.add_argument('--name', help='Show only executions with this name')
argparser_app_list.add_argument('--status', choices=["submitted", "scheduled", "starting", "error", "running", "cleaning up", "terminated"], help='Show only executions with this status') argparser_app_list.add_argument('--status', choices=["submitted", "queued", "starting", "error", "running", "cleaning up", "terminated"], help='Show only executions with this status')
argparser_app_list.add_argument('--earlier-than-submit', help='Show only executions submitted earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-submit', help='Show only executions submitted earlier than this timestamp (seconds since UTC epoch)')
argparser_app_list.add_argument('--earlier-than-start', help='Show only executions started earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-start', help='Show only executions started earlier than this timestamp (seconds since UTC epoch)')
argparser_app_list.add_argument('--earlier-than-end', help='Show only executions ended earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-end', help='Show only executions ended earlier than this timestamp (seconds since UTC epoch)')
......
...@@ -404,7 +404,7 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]: ...@@ -404,7 +404,7 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]:
argparser_app_list.add_argument('--limit', type=int, help='Limit the number of executions') argparser_app_list.add_argument('--limit', type=int, help='Limit the number of executions')
argparser_app_list.add_argument('--name', help='Show only executions with this name') argparser_app_list.add_argument('--name', help='Show only executions with this name')
argparser_app_list.add_argument('--user_id', help='Show only executions belonging to this user') argparser_app_list.add_argument('--user_id', help='Show only executions belonging to this user')
argparser_app_list.add_argument('--status', choices=["submitted", "scheduled", "starting", "error", "running", "cleaning up", "terminated"], help='Show only executions with this status') argparser_app_list.add_argument('--status', choices=["submitted", "queued", "starting", "error", "running", "cleaning up", "terminated"], help='Show only executions with this status')
argparser_app_list.add_argument('--earlier-than-submit', help='Show only executions submitted earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-submit', help='Show only executions submitted earlier than this timestamp (seconds since UTC epoch)')
argparser_app_list.add_argument('--earlier-than-start', help='Show only executions started earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-start', help='Show only executions started earlier than this timestamp (seconds since UTC epoch)')
argparser_app_list.add_argument('--earlier-than-end', help='Show only executions ended earlier than this timestamp (seconds since UTC epoch)') argparser_app_list.add_argument('--earlier-than-end', help='Show only executions ended earlier than this timestamp (seconds since UTC epoch)')
......
...@@ -37,7 +37,7 @@ class Execution(BaseRecord): ...@@ -37,7 +37,7 @@ class Execution(BaseRecord):
""" """
SUBMIT_STATUS = "submitted" SUBMIT_STATUS = "submitted"
SCHEDULED_STATUS = "scheduled" QUEUED_STATUS = "queued"
STARTING_STATUS = "starting" STARTING_STATUS = "starting"
ERROR_STATUS = "error" ERROR_STATUS = "error"
RUNNING_STATUS = "running" RUNNING_STATUS = "running"
...@@ -98,9 +98,9 @@ class Execution(BaseRecord): ...@@ -98,9 +98,9 @@ class Execution(BaseRecord):
def __eq__(self, other): def __eq__(self, other):
return self.id == other.id return self.id == other.id
def set_scheduled(self): def set_queued(self):
"""The execution has been added to the scheduler queues.""" """The execution has been added to the scheduler queues."""
self._status = self.SCHEDULED_STATUS self._status = self.QUEUED_STATUS
self.sql_manager.executions.update(self.id, status=self._status) self.sql_manager.executions.update(self.id, status=self._status)
def set_starting(self): def set_starting(self):
...@@ -150,7 +150,7 @@ class Execution(BaseRecord): ...@@ -150,7 +150,7 @@ class Execution(BaseRecord):
Returns False if the execution ended completely Returns False if the execution ended completely
:return: :return:
""" """
return self._status == self.SUBMIT_STATUS or self._status == self.SCHEDULED_STATUS or self._status == self.RUNNING_STATUS or self._status == self.STARTING_STATUS or self._status == self.CLEANING_UP_STATUS return self._status == self.SUBMIT_STATUS or self._status == self.QUEUED_STATUS or self._status == self.RUNNING_STATUS or self._status == self.STARTING_STATUS or self._status == self.CLEANING_UP_STATUS
@property @property
def is_running(self): def is_running(self):
......
...@@ -97,7 +97,7 @@ def service_list_to_containers(execution: Execution, service_list: List[Service] ...@@ -97,7 +97,7 @@ def service_list_to_containers(execution: Execution, service_list: List[Service]
log.warning('Temporary failure starting service {} of execution {}: {}'.format(service.id, execution.id, ex.message)) log.warning('Temporary failure starting service {} of execution {}: {}'.format(service.id, execution.id, ex.message))
service.set_error(ex.message) service.set_error(ex.message)
terminate_execution(execution, reason=ex.message) terminate_execution(execution, reason=ex.message)
execution.set_scheduled() execution.set_queued()
return "requeue" return "requeue"
except ZoeStartExecutionFatalException as ex: except ZoeStartExecutionFatalException as ex:
log.error('Fatal error trying to start service {} of execution {}: {}'.format(service.id, execution.id, ex.message)) log.error('Fatal error trying to start service {} of execution {}: {}'.format(service.id, execution.id, ex.message))
......
...@@ -83,18 +83,23 @@ def _digest_application_description(state: SQLManager, execution: Execution): ...@@ -83,18 +83,23 @@ def _digest_application_description(state: SQLManager, execution: Execution):
def execution_submit(state: SQLManager, scheduler: ZoeBaseScheduler, execution: Execution): def execution_submit(state: SQLManager, scheduler: ZoeBaseScheduler, execution: Execution):
"""Submit a new execution to the scheduler.""" """Submit a new execution to the scheduler."""
if execution.status != execution.SUBMIT_STATUS:
log.warning('Trying to start an execution in state {}'.format(execution.status))
return
if _digest_application_description(state, execution): if _digest_application_description(state, execution):
execution.set_scheduled() execution.set_queued()
scheduler.incoming(execution) scheduler.incoming(execution)
def execution_terminate(scheduler: ZoeBaseScheduler, execution: Execution, reason: str): def execution_terminate(scheduler: ZoeBaseScheduler, execution: Execution, reason: str):
"""Remove an execution from the scheduler.""" """Remove an execution from the scheduler."""
if execution.is_running or execution.status == execution.SCHEDULED_STATUS: if execution.is_running or execution.status == execution.QUEUED_STATUS:
execution.set_cleaning_up() execution.set_cleaning_up()
execution.set_error_message(reason) execution.set_error_message(reason)
scheduler.terminate(execution) scheduler.terminate(execution)
elif execution.status == execution.SUBMIT_STATUS or execution.status == execution.STARTING_STATUS: elif execution.status == execution.SUBMIT_STATUS:
execution.set_terminated(reason)
elif execution.status == execution.STARTING_STATUS:
return # It is unsafe to terminate executions in these statuses return # It is unsafe to terminate executions in these statuses
elif execution.status == execution.ERROR_STATUS or execution.status == execution.CLEANING_UP_STATUS: elif execution.status == execution.ERROR_STATUS or execution.status == execution.CLEANING_UP_STATUS:
terminate_execution(execution, reason) terminate_execution(execution, reason)
...@@ -108,7 +113,7 @@ def restart_resubmit_scheduler(state: SQLManager, scheduler: ZoeBaseScheduler): ...@@ -108,7 +113,7 @@ def restart_resubmit_scheduler(state: SQLManager, scheduler: ZoeBaseScheduler):
for e in submitted_execs: for e in submitted_execs:
execution_submit(state, scheduler, e) execution_submit(state, scheduler, e)
sched_execs = state.executions.select(status=Execution.SCHEDULED_STATUS) sched_execs = state.executions.select(status=Execution.QUEUED_STATUS)
for e in sched_execs: for e in sched_execs:
scheduler.incoming(e) scheduler.incoming(e)
......
...@@ -354,7 +354,7 @@ class ZoeElasticScheduler: ...@@ -354,7 +354,7 @@ class ZoeElasticScheduler:
execution.set_cleaning_up() execution.set_cleaning_up()
self.terminate(execution) self.terminate(execution)
break break
# Check for executions that need to be rescheduled because one of the elastic components died # Check for executions that need to be re-queued because one of the elastic components died
# Do it in two loops to prevent rescheduling executions that need to be terminated # Do it in two loops to prevent rescheduling executions that need to be terminated
for execution in self.queue_running: for execution in self.queue_running:
for service in execution.services: for service in execution.services:
......
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