Commit 441f1aba authored by Daniele Venzano's avatar Daniele Venzano

Fix Swarm backend

parent 87694fc8
......@@ -127,7 +127,10 @@ class DockerEngineBackend(zoe_master.backends.base.BaseBackend):
stats = {}
for cont in container_list:
stats[cont['id']] = my_engine.stats(cont['id'], stream=False)
try:
stats[cont['id']] = my_engine.stats(cont['id'], stream=False)
except ZoeException:
continue
node_stats.memory_reserved = sum([cont['memory_soft_limit'] for cont in container_list if cont['memory_soft_limit'] != node_stats.memory_total])
node_stats.memory_in_use = sum([stat['memory_stats']['usage'] for stat in stats.values() if 'usage' in stat['memory_stats']])
......
......@@ -244,12 +244,6 @@ class SwarmClient:
except KeyError:
info['host'] = 'N/A'
for net in container.attrs["NetworkSettings"]["Networks"]:
if len(container.attrs["NetworkSettings"]["Networks"][net]['IPAddress']) > 0:
info["ip_address"][net] = container.attrs["NetworkSettings"]["Networks"][net]['IPAddress']
else:
info["ip_address"][net] = None
if container.status == 'running' or container.status == 'restarting':
info["state"] = Service.BACKEND_START_STATUS
info["running"] = True
......
......@@ -18,7 +18,6 @@
import logging
from zoe_lib.state import Service
from zoe_lib.config import get_conf
from zoe_master.backends.swarm.api_client import SwarmClient
from zoe_master.exceptions import ZoeStartExecutionRetryException, ZoeStartExecutionFatalException, ZoeException, ZoeNotEnoughResourcesException
import zoe_master.backends.base
......@@ -58,7 +57,14 @@ class SwarmBackend(zoe_master.backends.base.BaseBackend):
except ZoeException as e:
raise ZoeStartExecutionFatalException(str(e))
return cont_info["id"], cont_info['ip_address'][get_conf().overlay_network_name], cont_info['ports']
ip_address = None
ports = {}
for port_name, mapping in cont_info['ports'].items():
if mapping is None:
continue
ip_address = mapping[0]
ports[port_name] = mapping[1]
return cont_info["id"], ip_address, ports
def terminate_service(self, service: Service) -> None:
"""Terminate and delete a container."""
......
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