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).
(cherry picked from commit 49380b4b49
)
This commit is contained in:
parent
ea5e34e9c6
commit
d50321239c
@ -82,7 +82,11 @@ def get_base_object(conf):
|
|||||||
|
|
||||||
# Update the metadata from the enabled repos to speed up later operations
|
# Update the metadata from the enabled repos to speed up later operations
|
||||||
log.info("Updating repository metadata")
|
log.info("Updating repository metadata")
|
||||||
|
try:
|
||||||
dbo.fill_sack(load_system_repo=False)
|
dbo.fill_sack(load_system_repo=False)
|
||||||
dbo.read_comps()
|
dbo.read_comps()
|
||||||
|
except dnf.exceptions.Error as e:
|
||||||
|
log.error("Failed to update metadata: %s", str(e))
|
||||||
|
raise RuntimeError("Fetching metadata failed: %s" % str(e))
|
||||||
|
|
||||||
return dbo
|
return dbo
|
||||||
|
@ -245,7 +245,11 @@ if __name__ == '__main__':
|
|||||||
make_dnf_dirs(server.config["COMPOSER_CFG"])
|
make_dnf_dirs(server.config["COMPOSER_CFG"])
|
||||||
|
|
||||||
# Get a dnf.Base to share with the requests
|
# Get a dnf.Base to share with the requests
|
||||||
|
try:
|
||||||
dbo = get_base_object(server.config["COMPOSER_CFG"])
|
dbo = get_base_object(server.config["COMPOSER_CFG"])
|
||||||
|
except RuntimeError:
|
||||||
|
# Error has already been logged. Just exit cleanly.
|
||||||
|
sys.exit(1)
|
||||||
server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())
|
server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())
|
||||||
|
|
||||||
# Depsolve the templates and make a note of the failures for /api/status to report
|
# Depsolve the templates and make a note of the failures for /api/status to report
|
||||||
|
Loading…
Reference in New Issue
Block a user