bitbake: prserv/cooker: Handle PRService errors cleanly
Current if the PR Service fails to start, bitbake carries on regardless or hangs with no error message. This adds an exception and then handles it correctly so the UIs correctly handle the error and exit cleanly. [YOCTO #4010] (Bitbake rev: 949c01228a977c3b92bfc0802f6c71b40d8e05b3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
8779ebcc90
commit
a4cc40c622
|
@ -1486,7 +1486,10 @@ class BBCooker:
|
||||||
# Empty the environment. The environment will be populated as
|
# Empty the environment. The environment will be populated as
|
||||||
# necessary from the data store.
|
# necessary from the data store.
|
||||||
#bb.utils.empty_environment()
|
#bb.utils.empty_environment()
|
||||||
prserv.serv.auto_start(self.configuration.data)
|
try:
|
||||||
|
prserv.serv.auto_start(self.configuration.data)
|
||||||
|
except prserv.serv.PRServiceConfigError:
|
||||||
|
bb.event.fire(CookerExit(), self.configuration.event_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
def post_serve(self):
|
def post_serve(self):
|
||||||
|
|
|
@ -263,6 +263,9 @@ def is_local_special(host, port):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class PRServiceConfigError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def auto_start(d):
|
def auto_start(d):
|
||||||
global singleton
|
global singleton
|
||||||
|
|
||||||
|
@ -273,14 +276,14 @@ def auto_start(d):
|
||||||
if len(host_params) != 2:
|
if len(host_params) != 2:
|
||||||
logger.critical('\n'.join(['PRSERV_HOST: incorrect format',
|
logger.critical('\n'.join(['PRSERV_HOST: incorrect format',
|
||||||
'Usage: PRSERV_HOST = "<hostname>:<port>"']))
|
'Usage: PRSERV_HOST = "<hostname>:<port>"']))
|
||||||
return True
|
raise PRServiceConfigError
|
||||||
|
|
||||||
if is_local_special(host_params[0], int(host_params[1])) and not singleton:
|
if is_local_special(host_params[0], int(host_params[1])) and not singleton:
|
||||||
import bb.utils
|
import bb.utils
|
||||||
cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True))
|
cachedir = (d.getVar("PERSISTENT_DIR", True) or d.getVar("CACHE", True))
|
||||||
if not cachedir:
|
if not cachedir:
|
||||||
logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable")
|
logger.critical("Please set the 'PERSISTENT_DIR' or 'CACHE' variable")
|
||||||
sys.exit(1)
|
raise PRServiceConfigError
|
||||||
bb.utils.mkdirhier(cachedir)
|
bb.utils.mkdirhier(cachedir)
|
||||||
dbfile = os.path.join(cachedir, "prserv.sqlite3")
|
dbfile = os.path.join(cachedir, "prserv.sqlite3")
|
||||||
logfile = os.path.join(cachedir, "prserv.log")
|
logfile = os.path.join(cachedir, "prserv.log")
|
||||||
|
@ -296,7 +299,7 @@ def auto_start(d):
|
||||||
return PRServerConnection(host,port).ping()
|
return PRServerConnection(host,port).ping()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.critical("PRservice %s:%d not available" % (host, port))
|
logger.critical("PRservice %s:%d not available" % (host, port))
|
||||||
return False
|
raise PRServiceConfigError
|
||||||
|
|
||||||
def auto_shutdown(d=None):
|
def auto_shutdown(d=None):
|
||||||
global singleton
|
global singleton
|
||||||
|
|
Loading…
Reference in New Issue