Commit 5591f894 authored by Xavier Thompson's avatar Xavier Thompson

slapgrid: Adapt launching promise with SlapPopen

parent 0fe309cd
...@@ -59,7 +59,11 @@ from slapos import manager as slapmanager ...@@ -59,7 +59,11 @@ from slapos import manager as slapmanager
from slapos.slap.slap import NotFoundError from slapos.slap.slap import NotFoundError
from slapos.slap.slap import ServerError from slapos.slap.slap import ServerError
from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME
from slapos.util import mkdir_p, chownDirectory, string_to_boolean, listifdir from slapos.util import (mkdir_p,
chownDirectory,
string_to_boolean,
listifdir,
unicode2str)
from slapos.grid.exception import BuildoutFailedError from slapos.grid.exception import BuildoutFailedError
from slapos.grid.SlapObject import Software, Partition from slapos.grid.SlapObject import Software, Partition
from slapos.grid.svcbackend import (launchSupervisord, from slapos.grid.svcbackend import (launchSupervisord,
...@@ -68,7 +72,6 @@ from slapos.grid.svcbackend import (launchSupervisord, ...@@ -68,7 +72,6 @@ from slapos.grid.svcbackend import (launchSupervisord,
_getSupervisordSocketPath) _getSupervisordSocketPath)
from slapos.grid.utils import (md5digest, from slapos.grid.utils import (md5digest,
dropPrivileges, dropPrivileges,
killProcessTree,
SlapPopen, SlapPopen,
updateFile) updateFile)
from slapos.grid.promise import PromiseLauncher, PromiseError from slapos.grid.promise import PromiseLauncher, PromiseError
...@@ -738,7 +741,6 @@ stderr_logfile_backups=1 ...@@ -738,7 +741,6 @@ stderr_logfile_backups=1
os.dup2(1, 2) os.dup2(1, 2)
dropPrivileges(uid, gid, logger=self.logger) dropPrivileges(uid, gid, logger=self.logger)
os.dup2(err, 2) os.dup2(err, 2)
try:
process = SlapPopen( process = SlapPopen(
command, command,
preexec_fn=preexec_fn, preexec_fn=preexec_fn,
...@@ -749,17 +751,12 @@ stderr_logfile_backups=1 ...@@ -749,17 +751,12 @@ stderr_logfile_backups=1
logger=self.logger, logger=self.logger,
timeout=timeout, timeout=timeout,
) )
stderr = process.stderr.read()
if process.returncode == 2: if process.returncode == 2:
raise PromiseError(stderr) raise PromiseError(unicode2str(process.error))
elif process.returncode: elif process.returncode:
raise Exception(stderr) raise Exception(unicode2str(process.error))
elif stderr: elif process.error:
self.logger.warn('Unexpected promise runner output:\n%s', stderr) self.logger.warn('Unexpected promise runner output:\n%s', process.error)
except subprocess.TimeoutExpired:
killProcessTree(process.pid, self.logger)
# If this happens, it might be that the timeout margin is too small.
raise Exception('Promise runner timed out')
else: else:
return PromiseLauncher(config=promise_config, logger=self.logger).run() return PromiseLauncher(config=promise_config, logger=self.logger).run()
......
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