yum repos has a delete() function. But it doesn't clear the cache.
yum also has a cache it uses for listEnabled(), but the cache isn't invalidated when a repo is deleted it any following metadata update will fail because it is still using the deleted repo. We are forced to use the heavy hammer on a yum private variable yet again to force the cache to be cleared so that it won't crash.
This commit is contained in:
parent
2e95b56508
commit
a5eaebeefc
@ -1478,10 +1478,13 @@ def v0_api(api):
|
|||||||
|
|
||||||
# Cleanup the mess, if loading it failed we don't want to leave it in memory
|
# Cleanup the mess, if loading it failed we don't want to leave it in memory
|
||||||
with api.config["YUMLOCK"].lock:
|
with api.config["YUMLOCK"].lock:
|
||||||
|
yb = api.config["YUMLOCK"].yb
|
||||||
repos = list(r.id for r in yb.repos.listEnabled())
|
repos = list(r.id for r in yb.repos.listEnabled())
|
||||||
|
log.info("BCL: repos = %s", repos)
|
||||||
if source["name"] in repos:
|
if source["name"] in repos:
|
||||||
yb = api.config["YUMLOCK"].yb
|
|
||||||
yb.repos.delete(source["name"])
|
yb.repos.delete(source["name"])
|
||||||
|
# delete doesn't remove it from the cache used by listEnabled so we have to force it
|
||||||
|
yb.repos._cache_enabled_repos = None
|
||||||
|
|
||||||
log.info("Updating repository metadata after adding %s failed", source["name"])
|
log.info("Updating repository metadata after adding %s failed", source["name"])
|
||||||
update_metadata(yb)
|
update_metadata(yb)
|
||||||
@ -1508,6 +1511,9 @@ def v0_api(api):
|
|||||||
repos = list(r.id for r in yb.repos.listEnabled())
|
repos = list(r.id for r in yb.repos.listEnabled())
|
||||||
if source_name in repos:
|
if source_name in repos:
|
||||||
yb.repos.delete(source_name)
|
yb.repos.delete(source_name)
|
||||||
|
# delete doesn't remove it from the cache used by listEnabled so we have to force it
|
||||||
|
yb.repos._cache_enabled_repos = None
|
||||||
|
|
||||||
log.info("Updating repository metadata after removing %s", source_name)
|
log.info("Updating repository metadata after removing %s", source_name)
|
||||||
update_metadata(yb)
|
update_metadata(yb)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user