Log and exit on metadata update errors at startup
A bad system repo can cause lorax-composer to fail to start. Instead of a traceback log the error and exit. (note that the exit still results in an OSError traceback due to part of it running as root, this needs to be addressed in another commit).
This commit is contained in:
parent
f916e41d00
commit
8080abda67
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user