"Repository listed more than once" when also using Spacewalk (RHN)
wschaft opened this issue · 1 comments
When the yum library is called on a server with both RHN (Spacewalk in my case) and local repository files configured, it outputs that some repositories more than once:
python -c 'import yum ; yb = yum.YumBase() ; print [(r.id + "=" + str(r.gpgcheck)) for r in yb.repos.listEnabled()]' | grep "^\[" | tr -d '[] ' | tr -d "'" | sed 's/,/ /g'
Repository dell-system-update_independent is listed more than once in the configuration
Repository dell-system-update_dependent is listed more than once in the configuration
Repository dell-omsa-indep is listed more than once in the configuration
Repository dell-omsa-specific is listed more than once in the configuration
centos7=False centos_7-repos=False dell-system-update_dependent=False dell-system-update_independent=False epel_7=False spacewalk_client-el7=False zabbix-el7=False
This isn't the case when the yum command itself is executed. Maybe the output is filtered out?
The Dell repositories are locally configured, the rest if coming from Spacewalk.
This happens on both CentOS 6 and 7.
Version of the yum-rhn-plugin: yum-rhn-plugin-2.5.5-1
Hi,
This turned out pretty confusing, but here's the culprit: yb.getReposFromConfig()
is invoked twice in your script. What happens is, when
yb.repos
is touched, it callsyb._getRepos()
which touchesyb.conf
which goes to the init hook ofyum-rhn-plugin
which touchesyb.repos
itself which callsyb._getRepos()
again which touchesyb.conf
again (this time it only returns the already initializedyb._conf
) which callsyb.getReposFromConfig()
, reading in all the repo config files.
Later, when execution returns to the topmost stack frame, the _getRepos()
function continues past the just returned yb.conf
to getReposFromConfig()
again, which causes the error messages.
Luckily, this is trivial to resolve: you have to touch yb.conf
first, before yb.repos
, so that the latter yb.repos
doesn't get into the same recursion that caused the double repo configuration. So the fixed script looks like this:
python -c 'import yum ; yb = yum.YumBase() ; yb.conf ; print [(r.id + "=" + str(r.gpgcheck)) for r in yb.repos.listEnabled()]' | grep "^\[" | tr -d '[] ' | tr -d "'" | sed 's/,/ /g'
BTW, this is also why this doesn't happen if you run the yum
binary; the code path is different, with the conf
object being touched first.