Commit 8c1c123b authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: factorizes code from runSoftwareWithLock and runInstanceWithLock

parent 05f828a7
......@@ -278,35 +278,56 @@ def waitProcess(config, process, step):
date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
slapgridResultToFile(config, step, process.returncode, date)
def runSoftwareWithLock(config, lock=False):
def runSlapgridWithLock(config, step, process_name, lock=False):
"""
Use Slapgrid to compile current Software Release and wait until
compilation is done
* process_name is the name of the process given to supervisord, which will
run the software or the instance
* step is one of ('software', 'instance')
* lock allows to make this function asynchronous or not
"""
if sup_process.isRunning(config, 'slapgrid-sr'):
if sup_process.isRunning(config, process_name):
return 1
if not os.path.exists(config['software_root']):
os.mkdir(config['software_root'])
root_folder = config["%s_root" % step]
log_file = config["%s_log" % step]
if not os.path.exists(root_folder):
os.mkdir(root_folder)
stopProxy(config)
startProxy(config)
# XXX Hackish and unreliable
if os.path.exists(config['software_log']):
os.remove(config['software_log'])
if os.path.exists(log_file):
os.remove(config[log_file])
if not updateProxy(config):
return 1
try:
sup_process.runProcess(config, "slapgrid-sr")
sup_process.runProcess(config, process_name)
if lock:
sup_process.waitForProcessEnd(config, "slapgrid-sr")
sup_process.waitForProcessEnd(config, process_name)
#Saves the current compile software for re-use
if step == 'software':
config_SR_folder(config)
return sup_process.returnCode(config, "slapgrid-sr")
return sup_process.returnCode(config, process_name)
except xmlrpclib.Fault:
return 1
def runSoftwareWithLock(config, lock=False):
"""
Use Slapgrid to compile current Software Release and wait until
compilation is done
"""
return runSlapgridWithLock(config, 'software', 'slapgrid-sr', lock)
def runInstanceWithLock(config, lock=False):
"""
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
"""
return runSlapgridWithLock(config, 'instance', 'slapgrid-cp', lock)
  • Does slapgrid-cp still exists? it would be better to call "slapos node instance" instead.

Please register or sign in to reply
  • slapgrid-cp and slapgrid-sr are the names under which supervisord knows the "slapos node instance" and "slapos node software" command : https://lab.nexedi.com/nexedi/slapos/blob/f62e7/software/slaprunner/template/supervisord.conf.in#L33 and https://lab.nexedi.com/nexedi/slapos/blob/f62e7/software/slaprunner/instance-runner.cfg#L675 . But the correct "slapos node" command is correctly called.

    It doesn't matter to me to change it, but it's not really important because it's just a title. We could change to slapos-node-instance, but it's too long in my opinion. Maybe slapos-instance ? Better description, but still not 100% accurate.

Please register or sign in to reply
def config_SR_folder(config):
"""Create a symbolik link for each folder in software folder. That allows
the user to customize software release folder"""
......@@ -375,29 +396,6 @@ def isInstanceRunning(config):
return sup_process.isRunning(config, 'slapgrid-cp')
def runInstanceWithLock(config, lock=False):
"""
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
"""
if sup_process.isRunning(config, 'slapgrid-cp'):
return 1
startProxy(config)
# XXX Hackish and unreliable
if os.path.exists(config['instance_log']):
os.remove(config['instance_log'])
if not (updateProxy(config) and requestInstance(config)):
return 1
try:
sup_process.runProcess(config, "slapgrid-cp")
if lock:
sup_process.waitForProcessEnd(config, "slapgrid-cp")
return sup_process.returnCode(config, "slapgrid-cp")
except xmlrpclib.Fault:
return 1
def getProfilePath(projectDir, profile):
"""
Return the path of the current Software Release `profile`
......
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