Bug 2176149 - [leapp] UnicodeDecodeError: 'ascii' codec can't decode byte during the DNF transaction actor
Summary: [leapp] UnicodeDecodeError: 'ascii' codec can't decode byte during the DNF tr...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: leapp-repository
Version: 7.9
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Leapp Notifications Bot
QA Contact: upgrades-and-conversions
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-07 14:15 UTC by Christophe Besson
Modified: 2023-07-31 07:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker OAMG-8645 0 None None None 2023-03-07 14:17:00 UTC
Red Hat Issue Tracker RHELPLAN-150947 0 None None None 2023-03-07 14:16:57 UTC

Description Christophe Besson 2023-03-07 14:15:03 UTC
Description of problem:
An error occurred just after the DNF transaction, leading to the emergency shell.
It seems to fail while trying to remove the target userspace directory in using shutil.rmtree().
Rebooting shows a RHEL 8 OS without post-upgrade actions which was problematic (Satellite server here).

Version-Release number of selected component (if applicable):
leapp-upgrade-el7toel8-0.17.0-1.el7_9

How reproducible:
Always for the customer. Unable to reproduce internally.

Actual results:
[ 1617.173425] localhost upgrade[2241]:   tfm-rubygem-thor-1.0.1-3.el7sat.noarch
[ 1622.741102] localhost upgrade[2241]:   tfm-rubygem-thread_safe-0.3.6-6.el7sat.noarch              Process Process-216:
[ 1622.741102] localhost upgrade[2241]: Traceback (most recent call last):
[ 1622.743537] localhost upgrade[2241]:   File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
[ 1622.743537] localhost upgrade[2241]:     sys.stdin.close()
[ 1622.743537] localhost upgrade[2241]:   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[ 1622.743537] localhost upgrade[2241]:     self._target(*self._args, **self._kwargs)
[ 1622.743537] localhost upgrade[2241]:   File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 72, in _do_run
[ 1622.746925] localhost upgrade[2241]:     actor_instance.run(*args, **kwargs)
[ 1622.746925] localhost upgrade[2241]:   File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 289, in run
[ 1622.746925] localhost upgrade[2241]:     self.process(*args)
[ 1622.746925] localhost upgrade[2241]:   File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/dnfupgradetransaction/actor.py", line 60, in process
[ 1622.749744] localhost upgrade[2241]:     shutil.rmtree(userspace.path)
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 247, in rmtree
[ 1622.749744] localhost upgrade[2241]:     elif onerror is None:
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 247, in rmtree
[ 1622.749744] localhost upgrade[2241]:     elif onerror is None:
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 247, in rmtree
[ 1622.749744] localhost upgrade[2241]:     elif onerror is None:
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 247, in rmtree
[ 1622.749744] localhost upgrade[2241]:     elif onerror is None:
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 247, in rmtree
[ 1622.749744] localhost upgrade[2241]:     elif onerror is None:
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/shutil.py", line 241, in rmtree
[ 1622.749744] localhost upgrade[2241]:     is false and onerror is None, an exception is raised.
[ 1622.749744] localhost upgrade[2241]:   File "/usr/lib64/python2.7/posixpath.py", line 80, in join
[ 1622.749744] localhost upgrade[2241]:     # Trailing '/'es are stripped from head unless it is the root.
[ 1622.749744] localhost upgrade[2241]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128)
[ 1622.749744] localhost upgrade[2241]:                    
[ 1622.749744] localhost upgrade[2241]:   tfm-rubygem-tilt-2.0.8-5.el7sat.noarch
[ 1622.749744] localhost upgrade[2241]:   tfm-rubygem-timeliness-0.3.10-2.el7sat.noarch
[ 1622.749744] localhost upgrade[2241]:   tfm-rubygem-tzinfo-1.2.10-1.el7sat.noarch

Additional info:
As a workaround it has been suggested to catch all errors in the except clause line 61 (remove EnvironmentError).
From `/usr/share/leapp-repository/repositories/system_upgrade/common/actors/dnfupgradetransaction/actor.py`:
 56         self.produce(TransactionCompleted())
 57         userspace = next(self.consume(TargetUserSpaceInfo), None)
 58         if userspace:
 59             try:
 60                 shutil.rmtree(userspace.path)
 61             except EnvironmentError:
 62                 self.log.info("Failed to remove temporary userspace - error ignored", exc_info=True)

Comment 3 Petr Stodulka 2023-03-07 17:15:35 UTC
Hi Chris \o Thanks for the report. I am thinking whether we should not use rather classical `rm -rf PATH` instead of the shutil.rmtree (or put it into the different actor...) to make it more safe - considering the original python2 is removed in that time and the cleaning operation is not fundamental for the upgrade procedure.


Note You need to log in before you can comment on or make changes to this bug.