Commit 9235c44a authored by Daniele Venzano's avatar Daniele Venzano

Copying and serializing the image list for each node is very costly, do it only when needed

parent 65976d37
......@@ -25,7 +25,7 @@ from zoe_lib.state import Execution, Service, SQLManager # pylint: disable=unus
from zoe_master.backends.base import BaseBackend
from zoe_master.backends.service_instance import ServiceInstance
from zoe_master.exceptions import ZoeStartExecutionFatalException, ZoeStartExecutionRetryException, ZoeException
from zoe_master.stats import ClusterStats # pylint: disable=unused-import
from zoe_master.stats import ClusterStats, NodeStats # pylint: disable=unused-import
from zoe_master.backends.swarm.backend import SwarmBackend
......@@ -167,12 +167,14 @@ def terminate_execution(execution: Execution) -> None:
def get_platform_state(state: SQLManager) -> ClusterStats:
def get_platform_state(state: SQLManager, with_images=False) -> ClusterStats:
"""Retrieves the state of the platform by querying the container backend. Platform state includes information on free/reserved resources for each node. This information is used for advanced scheduling."""
backend = _get_backend()
platform_state = backend.platform_state()
for node in platform_state.nodes:
for node in platform_state.nodes: # type: NodeStats = state.service_list(, backend_status=Service.BACKEND_START_STATUS)
if not with_images:
node.image_list = []
return platform_state
......@@ -190,7 +190,7 @@ class ZoeElasticScheduler:
log.debug("-> {}".format(job))
platform_state = get_platform_state(self.state)
platform_state = get_platform_state(self.state, with_images=True)
except ZoeException:
log.error('Cannot retrieve platform state, cannot schedule')
for job in jobs_to_attempt_scheduling:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment