build-pkgs: Fixed the issue that returned chroot is None

If pkgbuilder fails to execute the builder's commands
and fails to assign idle chroot for package build,
not only the 'status' in the returned value should be
set to 'fail', but also the 'chroot' should be used to
set to simple words to show the error type.
And the code is improved to use the 'chroot' safely.

Test Plan:
Only run 'build-pkgs -a' multiple times for this issue
hard to reproduce.

Closes-bug: 1987906
Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
Change-Id: Ia53860a983119ddedac870c39c840e2e1377b46d
This commit is contained in:
Haiqing Bai 2022-08-30 15:25:29 +08:00
parent 0b16615328
commit 50238fcead
1 changed files with 2 additions and 1 deletions

View File

@ -595,6 +595,7 @@ class BuildController():
chroot = resp_json['msg']
else:
status = 'fail'
chroot = 'PkgbuilderFail'
return status, chroot
def req_kill_task(self, owner, dsc=None):
@ -907,7 +908,7 @@ class BuildController():
logger.info("To Require to add build task for %s with snapshot %s", pkg_name, snapshot_idx)
(status, chroot) = self.req_add_task(pkg_dir, dsc_path, build_type, snapshot_idx)
if 'fail' in status:
if 'ServerError' in chroot:
if chroot and 'ServerError' in chroot:
self.req_stop_task()
logger.error("Fatal error from pkgbuilder, exit from %s build with %s", layer, build_type)
return