Commit 8693304a authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Locally update statuses and log OOM errors

parent 4690e69a
......@@ -328,6 +328,7 @@ class Service(Base):
DOCKER_OOM_STATUS = 'oom-killed'
def __init__(self, d, sql_manager):
super().__init__(d, sql_manager)
......@@ -367,28 +368,35 @@ class Service(Base):
def set_terminating(self):
"""The service is being killed."""
self.sql_manager.service_update(, status=self.TERMINATING_STATUS)
self.status = self.TERMINATING_STATUS
def set_inactive(self):
"""The service is not running."""
self.sql_manager.service_update(, status=self.INACTIVE_STATUS, docker_id=None)
self.status = self.INACTIVE_STATUS
def set_starting(self):
"""The service is being created by Docker."""
self.sql_manager.service_update(, status=self.STARTING_STATUS)
self.status = self.STARTING_STATUS
def set_active(self, docker_id):
"""The service is running and has a valid docker_id."""
self.sql_manager.service_update(, status=self.ACTIVE_STATUS, docker_id=docker_id, error_message=None)
self.error_message = None
self.status = self.ACTIVE_STATUS
def set_error(self, error_message):
"""The service could not be created/started."""
self.sql_manager.service_update(, status=self.ERROR_STATUS, error_message=error_message)
self.status = self.ERROR_STATUS
self.error_message = error_message
def set_docker_status(self, new_status):
"""Docker has emitted an event related to this service."""
self.sql_manager.service_update(, docker_status=new_status)
log.debug("service {}, status updated to {}".format(, new_status))
self.docker_status = new_status
def ip_address(self):
......@@ -82,7 +82,8 @@ class ZoeMonitor(threading.Thread):
elif 'die' in event['Action'] or 'kill' in event['Action'] or 'stop' in event['Action']:
elif 'oom' in event['Action']:
log.warning('Service {} got killed by an OOM condition'.format(
elif 'destroy' in event['Action']:
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