Bug #17080
closed
Bug #16521: Rudder agent 5.x package not compatible with Centos8
Bug #16751: NCF python script should not be forced to python2
Python 2 vs 3 error on centos8 for package install
Added by François ARMAND over 4 years ago.
Updated over 2 years ago.
Description
On rudder 5.0, when using a package present gm, even with parent ticket corrected, I got:
Traceback (most recent call last):
File "/var/rudder/cfengine-community/modules/packages/yum", line 430, in <module>
sys.exit(main())
File "/var/rudder/cfengine-community/modules/packages/yum", line 412, in main
return list_updates(True)
File "/var/rudder/cfengine-community/modules/packages/yum", line 139, in list_updates
line = lastline + line
TypeError: must be str, not bytes
Traceback (most recent call last):
File "/var/rudder/cfengine-community/modules/packages/yum", line 430, in <module>
sys.exit(main())
File "/var/rudder/cfengine-community/modules/packages/yum", line 415, in main
return list_updates(False)
File "/var/rudder/cfengine-community/modules/packages/yum", line 139, in list_updates
line = lastline + line
TypeError: must be str, not bytes
error: Error installing package 'acpid'
error: Method 'ncf_package' failed in some repairs
error: Method 'package_present' failed in some repairs
error: Method 'test_plop' failed in some repairs
So, it happens that the problem is not in the choice of python 3, that is correctly done, but in the `yum` script itself. We don't have that problem in 6.0, so there is a diff:
diff -u yum-5.0 yum-6.0
--- yum-5.0 2020-04-08 16:08:36.846656642 +0200
+++ yum-6.0 2020-04-08 16:07:36.199261512 +0200
@@ -114,33 +114,44 @@
def list_updates(online):
+ global yum_options
for line in sys.stdin:
line = line.strip()
if line.startswith("options="):
option = line[len("options="):]
- if option.startswith("enablerepo=") or option.startswith("disablerepo="):
- global yum_options
- yum_options += ["--" + option]
+ if option.startswith("-"):
+ yum_options.append(option)
+ elif option.startswith("enablerepo=") or option.startswith("disablerepo="):
+ yum_options.append("--" + option)
online_flag = []
if not online:
online_flag = ["-C"]
process = subprocess_Popen([yum_cmd] + yum_options + online_flag + ["check-update"], stdout=subprocess.PIPE)
+ (stdoutdata, _) = process.communicate()
+ # analyze return code from `yum check-update`:
+ # 0 means no updates
+ # 1 means there was an error
+ # 100 means that there are available updates
+ if process.returncode != 100:
+ # either there were no updates or error happened
+ # Nothing to do for us here anyway
+ return process.returncode
lastline = ""
- for line in process.stdout:
+ for line in stdoutdata.splitlines():
# Combine multiline entries into one line. A line without at least three
# space separated fields gets combined with the next line, if that line
# starts with a space.
- if lastline and not line[0].isspace():
+ if lastline and (len(line) == 0 or not line[0].isspace()):
# Line does not start with a space. No combination.
lastline = ""
line = lastline + line
match = re.match("^\S+\s+\S+\s+\S+", line)
if match is None:
- # Keep line but strip trailing newline.
- lastline = line[:-1]
+ # Keep line
+ lastline = line
continue
lastline = ""
@@ -217,9 +228,10 @@
line = line.strip()
if line.startswith("options="):
option = line[len("options="):]
- if option.startswith("enablerepo=") or option.startswith("disablerepo="):
- global yum_options
- yum_options += ["--" + option]
+ if option.startswith("-"):
+ yum_options.append(option)
+ elif option.startswith("enablerepo=") or option.startswith("disablerepo="):
+ yum_options.append("--" + option)
if line.startswith("Name="):
if name:
# Each new "Name=" triggers a new entry.
- Status changed from New to In progress
- Assignee set to Benoît PECCATTE
- Status changed from In progress to Pending technical review
- Assignee changed from Benoît PECCATTE to Félix DALLIDET
- Pull Request set to https://github.com/Normation/ncf/pull/1168
- Status changed from Pending technical review to Pending release
- Fix check changed from To do to Error - Blocking
- Fix check changed from Error - Blocking to Error - Fixed
- Name check changed from To do to Reviewed
- Status changed from Pending release to Released
This bug has been fixed in Rudder 5.0.17 and 6.0.5 which were released today.
Also available in: Atom
PDF