Commit 76ad5861 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Alain Takoudjou

[runner] add logging when we remove all instances inside a webrunner

This shall be helpful when debugging why the data disappeared from a webrunner.

/cc @cedric.leninivin  @jerome @Nicolas @alain.takoudjou @rafael

/reviewed-on nexedi/slapos.toolbox!52
parents eeed319f d7496eaf
......@@ -352,15 +352,14 @@ def config_SR_folder(config):
md5sum = md5digest(profile)
link_to_folder(name, md5sum)
# check other links
# XXX-Marco do not shadow 'list'
list = []
software_link_list = []
for path in os.listdir(config['software_link']):
cfg_path = os.path.join(config['software_link'], path, config_name)
if os.path.exists(cfg_path):
cfg = open(cfg_path).read().split("#")
if len(cfg) != 2:
continue # there is a broken config file
list.append(cfg[1])
software_link_list.append(cfg[1])
if os.path.exists(config['software_root']):
folder_list = os.listdir(config['software_root'])
else:
......@@ -368,14 +367,14 @@ def config_SR_folder(config):
if not folder_list:
return
for folder in folder_list:
if folder in list:
if folder in software_link_list:
continue # this folder is already registered
else:
link_to_folder(folder, folder)
def loadSoftwareRList(config):
"""Return list (of dict) of Software Release from symbolik SR folder"""
list = []
sr_list = []
config_name = 'slaprunner.config'
for path in os.listdir(config['software_link']):
cfg_path = os.path.join(config['software_link'], path, config_name)
......@@ -383,8 +382,8 @@ def loadSoftwareRList(config):
cfg = open(cfg_path).read().split("#")
if len(cfg) != 2:
continue # there is a broken config file
list.append(dict(md5=cfg[1], path=cfg[0], title=path))
return list
sr_list.append(dict(md5=cfg[1], path=cfg[0], title=path))
return sr_list
def isInstanceRunning(config):
......@@ -563,6 +562,7 @@ def configNewSR(config, projectpath):
if folder:
sup_process.stopProcess(config, 'slapgrid-cp')
sup_process.stopProcess(config, 'slapgrid-sr')
logger.warning("User opened a new SR. Removing all instances...")
removeCurrentInstance(config)
open(os.path.join(config['etc_dir'], ".project"), 'w').write(projectpath)
return True
......@@ -601,6 +601,7 @@ def newSoftware(folder, config, session):
removeProxyDb(config)
startProxy(config)
#Stop runngin process and remove existing instance
logger.warning("User created a new SR. Removing all instances...")
removeCurrentInstance(config)
session['title'] = getProjectTitle(config)
code = 1
......@@ -679,6 +680,7 @@ def removeSoftwareByName(config, md5, folder_name):
return (0, "Software installation or instantiation in progress, cannot remove")
if getSoftwareReleaseName(config) == folder_name:
logger.warning("User removed the SR currently used. Removing all instances...")
removeCurrentInstance(config)
result = removeSoftwareRootDirectory(config, md5, folder_name)
......
......@@ -215,6 +215,7 @@ def supervisordStatus():
def removeInstance():
logger.warning("User clicked on 'Destroy All Services'. Removing all instances...")
result = removeCurrentInstance(app.config)
if isinstance(result, str):
flash(result)
......
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