Closed sbernhard closed 4 years ago
Honestly, I hate adding more options. Especially as it's not obvious to the user why they should use it from the help text.
Do I assume correctly that this is required because a basic OL8 install has OL repos in /etc/yum.repos.d
which are unavailable and a dnf install <something>
fails due to that?
I'd rather prefer us either instructing dnf not to fail in this case (I think it has a CLI switch for that, so there also should be an API call), or a try/except
around dnf_base.fill_sack()
(if that's the failing line?)
Alternatively, drop the option and make it if options.deps_repository_url
?
Do I assume correctly that this is required because a basic OL8 install has OL repos in
/etc/yum.repos.d
which are unavailable and adnf install <something>
fails due to that?
Yes. This is exactly what happens. If dnf fails, it does not find the sub-man and therefore its not possible to install sub-man.
I guess, "if options....url?" (your alternative solution) would harm some other scenarios in which deps-repo + default repos are necessary.
Well, there is another solution which doesn't affect the code: dear oracle users, remove / rename the original yum repos before you want to bootstrap them.... :-)
So I thought about that a bit more and either I'm not understanding the issue correctly, or the change shouldn't fix it...
Let me reiterate:
Now, your change modifies the code that does "search for sub man", but not the code that does "install subman", so even after the change you should not end up with a working system, as the install step should fail?
Another question that comes to mind: why are those repos unavailable? Bootstrap is supposed to migrate brown field environments, so I'd expect working systems with working repos, not something broken ;)
(Doesn't mean it shouldn't work, just that the use of bootstrap is questionable)
=> therefore, the approach is to use the deps-repository (2.) without running into (1.)
Right, I got that. But:
/etc/yum.repos.d
)1) good question. Maybe its "dnf vs yum"? While installing sub-man it works without an error. The error happend before while verifying if sub-man is already installed or not. 2) maybe again "dnf vs. yum" - maybe the yum doesn't complains not usable repos when verifying if sub-man is already installed 3) well, we have tested that with a "base oracle8" installation as a reference. Of course, we are using Foreman to provision new systems :)
[root@a1245aa8ea8f /]# cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)
[root@a1245aa8ea8f /]# cat /etc/yum.repos.d/fail.repo
[fail]
name=fail
baseurl=http://192.168.43.1:8000/not/existing
gpgcheck=0
[root@a1245aa8ea8f /]# yum install vim
Failed to set locale, defaulting to C.UTF-8
fail 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'fail':
- Curl error (7): Couldn't connect to server for http://192.168.43.1:8000/not/existing/repodata/repomd.xml [Failed to connect to 192.168.43.1 port 8000: Connection refused]
Error: Failed to download metadata for repo 'fail': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
[root@a1245aa8ea8f /]# echo $?
1
[root@a1245aa8ea8f /]# dnf install vim
Failed to set locale, defaulting to C.UTF-8
fail 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'fail':
- Curl error (7): Couldn't connect to server for http://192.168.43.1:8000/not/existing/repodata/repomd.xml [Failed to connect to 192.168.43.1 port 8000: Connection refused]
Error: Failed to download metadata for repo 'fail': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
[root@a1245aa8ea8f /]# echo $?
1
So the real issue is the ociregion
variable in Oracle's repo files.
Simple test script:
import dnf
def run_dnf():
dnf_base = dnf.Base()
dnf_base.conf.read()
dnf_base.read_all_repos()
dnf_base.fill_sack()
pkg_list = dnf_base.sack.query().filter(name='subscription-manager')
print(pkg_list.installed().run())
print(pkg_list.available().run())
run_dnf()
This errors out on OL8 with:
Errors during downloading metadata for repository 'ol8_baseos_latest':
- Curl error (6): Couldn't resolve host name for https://yum$ociregion.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/repodata/repomd.xml [Could not resolve host: yum$ociregion.oracle.com]
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load
ret = self._repo.load()
File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 394, in load
return _repo.Repo_load(self)
RuntimeError: Failed to download metadata for repo 'ol8_baseos_latest': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./test.py", line 13, in <module>
run_dnf()
File "./test.py", line 8, in run_dnf
dnf_base.fill_sack()
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 392, in fill_sack
self._add_repo_to_sack(r)
File "/usr/lib/python3.6/site-packages/dnf/base.py", line 137, in _add_repo_to_sack
repo.load()
File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 580, in load
raise dnf.exceptions.RepoError(str(e))
dnf.exceptions.RepoError: Failed to download metadata for repo 'ol8_baseos_latest': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Adding a dnf_base.conf.substitutions['ociregion'] = ''
to the script above (after dnf_base.conf.read()
) makes it work like a charm. (see docs for the config)
Why this variable is not set when you use the python library directly, I don't know. But adding this conditionally on Oracle systems sounds like the correct fix here.
That variable is loaded from /etc/dnf/vars/ociregion
, added in Oracle BZ 30121584 (but I can't find a working link to it)
So you think, there no change necessary in bootstrap script because the ociregion variable will be available soon and then the issue is fixed?
No, dnf seems not to read that variable properly when called from Python, so we need to workaround it (or tell dnf to read, I have no idea how)
This change is necessary to bootstrap oracle8. On oracle8, there is no subscription-manager by default in the repositories. Therefore you need to use a self-build sub-man which is part of a repository. The target of this PR is, to use ONLY this deps repositories which stores the sub-man because the Oracle8 base repositories can not be used as they require to login to the "orcale network" first.