Bug 1858204

Summary: reposync doesn't work in Fedora 32
Product: [Fedora] Fedora Reporter: Yuriy <smoker.tabac>
Component: cobblerAssignee: Orion Poplawski <orion>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 32CC: jimi, kwizart, ngompa13, orion, scott, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-17 08:23:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yuriy 2020-07-17 08:18:56 UTC
Description of problem:
Several problems in the code reposync.py

Version-Release number of selected component (if applicable):
cobbler-3.1.2-1.fc32.noarch

How reproducible:
cobbler reposync

Actual results:
cobbler reposync fail

Additional info:

Problem 1:

received on stderr: 
Exception occured: <class 'UnboundLocalError'>
Exception value: local variable 'cert' referenced before assignment
Exception Info:
  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 163, in run
    self.sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 206, in sync
    self.yum_sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 524, in yum_sync
    (cert, verify) = self.gen_urlgrab_ssl_opts(repo.yumopts)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 434, in gen_urlgrab_ssl_opts
    return (cert, verify)

Workaround 1:

Assign a value to variables prior to use.
--- reposync.py.orig	2020-07-06 20:58:12.496673490 +0300
+++ reposync.py.my	2020-07-17 09:52:50.525167207 +0300
@@ -421,6 +421,8 @@
         :rtype: (str, bool)
         """
         # use SSL options if specified in yum opts
+        cert = None
+        verify = False
         if 'sslclientkey' and 'sslclientcert' in yumopts:
             cert = (yumopts['sslclientcert'], yumopts['sslclientkey'])
         # Note that the default of requests is to verify the peer and host but the default here is NOT to verify them

Problem 2 (after workaround 1):

The download_file definition does not contain the "verify" parameter.
download_manager.py:    def download_file(self, url, dst, proxies=None, cert=None)

received on stderr: 
Exception occured: <class 'TypeError'>
Exception value: can only concatenate str (not "tuple") to str
Exception Info:
  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 163, in run
    self.sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 206, in sync
    self.yum_sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 530, in yum_sync
    utils.die(self.logger, "failed to fetch " + src + " " + e.args)

Workaround 2:

--- reposync.py.orig	2020-07-06 20:58:12.496673490 +0300
+++ reposync.py	2020-07-17 10:22:14.495238163 +0300
@@ -523,7 +525,7 @@
         dst = temp_path + "/repomd.xml"
         (cert, verify) = self.gen_urlgrab_ssl_opts(repo.yumopts)
         try:
-            self.dlmgr.download_file(src, dst, proxies, cert, verify)
+            self.dlmgr.download_file(src, dst, proxies, cert)
         except Exception as e:
             utils.die(self.logger, "failed to fetch " + src + " " + e.args)


Problem 3 (after workaround 3):

YUM API has been removed in Fedora 32.

# dnf install yum-utils
Package dnf-utils-4.0.16-1.fc32.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

# cobbler reposync
< .. >
received on stderr: 
Exception occured: <class 'NameError'>
Exception value: name 'yum' is not defined
Exception Info:
  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 163, in run
    self.sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 206, in sync
    self.yum_sync(repo)

  File "/usr/lib/python3.8/site-packages/cobbler/actions/reposync.py", line 535, in yum_sync
    rmd = yum.repoMDObject.RepoMD('', "%s/repomd.xml" % (temp_path))

Comment 1 Nicolas Chauvet (kwizart) 2020-07-17 08:23:05 UTC
duplicate of 1858177 cobbler needs to be ported to dnf reposync over (yum) reposync

Please forward patches upstrem.

*** This bug has been marked as a duplicate of bug 1858177 ***