Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Repository listed more than once" when also using Spacewalk (RHN) #50

Closed
wschaft opened this issue Sep 4, 2017 · 1 comment
Closed

Comments

@wschaft
Copy link

wschaft commented Sep 4, 2017

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

@dmnks
Copy link
Contributor

dmnks commented Nov 2, 2017

Hi,

This turned out pretty confusing, but here's the culprit: yb.getReposFromConfig() is invoked twice in your script. What happens is, when

  1. yb.repos is touched, it calls
  2. yb._getRepos() which touches
  3. yb.conf which goes to the init hook of yum-rhn-plugin which touches
  4. yb.repos itself which calls
  5. yb._getRepos() again which touches
  6. yb.conf again (this time it only returns the already initialized yb._conf) which calls
  7. yb.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.

@megaumi megaumi closed this as completed Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants