Commit d0397a57 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

Merge branch 'improve_cleanup' into 'master'

Implement temporary resources cleanup

See merge request !36
parents 88b17e54 0eb75803
Pipeline #24137 passed with stages
in 27 minutes and 39 seconds
...@@ -77,4 +77,5 @@ def enumerate_packages(host, environment_name): ...@@ -77,4 +77,5 @@ def enumerate_packages(host, environment_name):
'version': information[1] 'version': information[1]
}) })
host.rm(container)
return packages return packages
...@@ -152,6 +152,7 @@ class BaseExecutor(object): ...@@ -152,6 +152,7 @@ class BaseExecutor(object):
self.data_sinks = [] self.data_sinks = []
self.errors = [] self.errors = []
self.data = data self.data = data
self.debug = False
# Check that the cache path exists # Check that the cache path exists
if not os.path.exists(self.cache): if not os.path.exists(self.cache):
......
...@@ -34,6 +34,7 @@ Execution utilities ...@@ -34,6 +34,7 @@ Execution utilities
""" """
import os import os
import shutil
import requests import requests
import simplejson import simplejson
import zmq import zmq
...@@ -230,6 +231,7 @@ class DockerExecutor(RemoteExecutor): ...@@ -230,6 +231,7 @@ class DockerExecutor(RemoteExecutor):
#----- (If necessary) Instantiate the docker container that provide the databases #----- (If necessary) Instantiate the docker container that provide the databases
databases_container = None databases_container = None
databases_configuration_path = None
datasets_uid = self.data.pop('datasets_uid', None) datasets_uid = self.data.pop('datasets_uid', None)
network_name = self.data.pop('network_name', 'bridge') network_name = self.data.pop('network_name', 'bridge')
...@@ -423,4 +425,9 @@ class DockerExecutor(RemoteExecutor): ...@@ -423,4 +425,9 @@ class DockerExecutor(RemoteExecutor):
self.message_handler.destroy() self.message_handler.destroy()
self.message_handler = None self.message_handler = None
if not self.debug:
if databases_configuration_path:
shutil.rmtree(databases_configuration_path)
shutil.rmtree(configuration_path)
return retval return retval
...@@ -37,6 +37,7 @@ Execution utilities ...@@ -37,6 +37,7 @@ Execution utilities
from __future__ import absolute_import from __future__ import absolute_import
import os import os
import shutil
import requests import requests
import zmq import zmq
import sys import sys
...@@ -245,6 +246,7 @@ class SubprocessExecutor(RemoteExecutor): ...@@ -245,6 +246,7 @@ class SubprocessExecutor(RemoteExecutor):
#----- (If necessary) Instantiate the subprocess that provide the databases #----- (If necessary) Instantiate the subprocess that provide the databases
databases_process = None databases_process = None
databases_configuration_path = None
database_port = utils.find_free_port() database_port = utils.find_free_port()
if len(self.databases) > 0: if len(self.databases) > 0:
...@@ -370,4 +372,9 @@ class SubprocessExecutor(RemoteExecutor): ...@@ -370,4 +372,9 @@ class SubprocessExecutor(RemoteExecutor):
self.message_handler.destroy() self.message_handler.destroy()
self.message_handler = None self.message_handler = None
if not self.debug:
if databases_configuration_path:
shutil.rmtree(databases_configuration_path)
shutil.rmtree(configuration_path)
return retval return retval
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