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