diff --git a/src/pylorax/api/yumbase.py b/src/pylorax/api/yumbase.py index 704ce159..11b38d40 100644 --- a/src/pylorax/api/yumbase.py +++ b/src/pylorax/api/yumbase.py @@ -24,6 +24,8 @@ from fnmatch import fnmatchcase from glob import glob import os import yum +from yum.Errors import YumBaseError + # This is a hack to short circuit yum's internal logging yum.logginglevels._added_handlers = True @@ -118,6 +120,10 @@ def update_metadata(yb): for r in yb.repos.sort(): r.metadata_expire = 0 r.mdpolicy = "group:all" - yb.doRepoSetup() - yb.repos.doSetup() - yb.repos.populateSack(mdtype='all', cacheonly=0) + try: + yb.doRepoSetup() + yb.repos.doSetup() + yb.repos.populateSack(mdtype='all', cacheonly=0) + except YumBaseError as e: + log.error("Failed to update metadata: %s", str(e)) + raise RuntimeError("Fetching metadata failed: %s" % str(e)) diff --git a/src/sbin/lorax-composer b/src/sbin/lorax-composer index 234b161a..b5de76a5 100755 --- a/src/sbin/lorax-composer +++ b/src/sbin/lorax-composer @@ -278,7 +278,11 @@ if __name__ == '__main__': make_yum_dirs(server.config["COMPOSER_CFG"]) # Get a YumBase to share with the requests - yb = get_base_object(server.config["COMPOSER_CFG"]) + try: + yb = get_base_object(server.config["COMPOSER_CFG"]) + except RuntimeError: + # Error has already been logged. Just exit cleanly. + sys.exit(1) server.config["YUMLOCK"] = YumLock(yb=yb, lock=Lock()) # Depsolve the templates and make a note of the failures for /api/status to report