Commit aa0a0d37 authored by Jérome Perrin's avatar Jérome Perrin

svcbackend: properly log error when supervisord can not be started

Output is already captured on SlapPopen instances and the output
is available with output attribute.
parent cdbdd701
Pipeline #11478 failed with stage
in 0 seconds
......@@ -190,10 +190,10 @@ def launchSupervisord(instance_root, logger,
stderr=subprocess.STDOUT,
logger=logger)
result = supervisord_popen.communicate()[0]
result = supervisord_popen.output
if supervisord_popen.returncode:
logger.warning('Supervisord unknown problem: %s' % result)
raise RuntimeError('Failed to launch supervisord : %s' % result)
logger.warning('Supervisord unknown problem: %s', result)
raise RuntimeError('Failed to launch supervisord:\n%s' % result)
try:
default_timeout = socketlib.getdefaulttimeout()
......
......@@ -44,6 +44,7 @@ import json
import re
import grp
import mock
from mock import patch
from zope.interface import implementer
......@@ -3749,3 +3750,20 @@ class TestSlapgridPromiseWithMaster(MasterMixin, unittest.TestCase):
self.assertFalse(os.path.isfile(os.path.join(instance.partition_path,
".slapgrid/promise/result/fail.status.json")))
class TestSVCBackend(unittest.TestCase):
"""Tests for supervisor backend.
"""
def test_launchSupervisord_fail(self):
"""Proper message is displayed when supervisor can not be started.
"""
logger = mock.create_autospec(logging.Logger)
from slapos.grid.svcbackend import launchSupervisord
with self.assertRaisesRegexp(
RuntimeError,
"""Failed to launch supervisord:
Error: could not find config file /not/exist/etc/supervisord.conf
For help, use -c -h"""):
launchSupervisord('/not/exist', logger)
logger.warning.assert_called()
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