Description
Actual behavior
When leapp upgrade
is run with various locale-related environment variables set to C
, even though the sub-command overrides them with en_US.UTF-8
, Python internals are still configured to use the ascii
encoding, and certain external commands emit UTF-8, which causes the logging subsystem to emit several UnicodeEncodeError
exceptions.
To Reproduce
- On a fresh AlmaLInux 8.10 installation, the appropriate ELevate repository RPM is installed, and packages to perform an AL8-to-AL9 upgrade are installed.
# rpm -ivh https://repo.almalinux.org/elevate/elevate-release-latest-el8.noarch.rpm
# dnf install leapp leapp-data-almalinux leapp-upgrade-el8toel9
- The environment of the shell session is modified to force the use of the standard C locale:
# export LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=C LC_CTYPE=C
leapp preupgrade
is run and comes back with no inhibitors.leapp upgrade
is run. The following stack trace is the first of many which occur during initramfs generation, usually due tosystemctl
emitting fancy Unicode symbols when running in the context of DNF plugin handling:
==> Processing phase `InterimPreparation`
====> * common_leapp_dracut_modules
Influences the generation of the initram disk
====> * efi_interim_fix
Adjust EFI boot entry for first reboot
====> * add_arm_bootloader_workaround
Workaround for ARM Upgrades from RHEL8 to RHEL9.5 onwards
====> * remove_upgrade_artifacts
Removes artifacts left over by previous leapp runs
====> * upgrade_initramfs_generator
Creates the upgrade initramfs
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib64/python3.6/logging/__init__.py", line 996, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2192' in position 183: ordinal not in range(128)
Call stack:
File "/bin/leapp", line 11, in <module>
load_entry_point('leapp==0.18.0', 'console_scripts', 'leapp')()
File "/usr/lib/python3.6/site-packages/leapp/cli/__init__.py", line 51, in main
cli.command.execute('leapp version {}'.format(VERSION))
File "/usr/lib/python3.6/site-packages/leapp/utils/clicmd.py", line 111, in execute
args.func(args)
File "/usr/lib/python3.6/site-packages/leapp/utils/clicmd.py", line 133, in called
self.target(args)
File "/usr/lib/python3.6/site-packages/leapp/cli/commands/upgrade/breadcrumbs.py", line 166, in wrapper
return f(*args, breadcrumbs=breadcrumbs, **kwargs)
File "/usr/lib/python3.6/site-packages/leapp/cli/commands/upgrade/__init__.py", line 110, in upgrade
only_with_tags=only_with_tags)
File "/usr/lib/python3.6/site-packages/leapp/workflows/__init__.py", line 351, in run
instance.run()
File "/usr/lib/python3.6/site-packages/leapp/repository/actor_definition.py", line 112, in run
p.start()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 105, in start
self._popen = self._Popen(self)
File "/usr/lib64/python3.6/multiprocessing/context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/usr/lib64/python3.6/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/usr/lib64/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/usr/lib64/python3.6/multiprocessing/popen_fork.py", line 73, in _launch
code = process_obj._bootstrap()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.6/site-packages/leapp/repository/actor_definition.py", line 75, in _do_run
actor_instance.run(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/leapp/actors/__init__.py", line 316, in run
self.process(*args)
File "/etc/leapp/repos.d/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/actor.py", line 46, in process
upgradeinitramfsgenerator.process()
File "/etc/leapp/repos.d/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py", line 539, in process
prepare_userspace_for_initram(context)
File "/usr/lib/python3.6/site-packages/leapp/utils/deprecation.py", line 42, in process_wrapper
return target_item(*args, **kwargs)
File "/etc/leapp/repos.d/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py", line 245, in prepare_userspace_for_initram
_install_initram_deps(packages)
File "/etc/leapp/repos.d/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py", line 176, in _install_initram_deps
used_repos=used_repos)
File "/etc/leapp/repos.d/system_upgrade/common/libraries/dnfplugin.py", line 386, in install_initramdisk_requirements
context.call(cmd, env=env)
File "/etc/leapp/repos.d/system_upgrade/common/libraries/mounting.py", line 169, in call
return run(self.type.make_command(cmd), *args, **kwargs)
File "/usr/lib/python3.6/site-packages/leapp/libraries/stdlib/__init__.py", line 185, in run
stdin=stdin, env=env, encoding=encoding)
File "/usr/lib/python3.6/site-packages/leapp/libraries/stdlib/call.py", line 199, in _call
**extra
File "/usr/lib/python3.6/site-packages/leapp/libraries/stdlib/call.py", line 73, in _multiplex
callback_linebuffered((fd, fd_type), pre)
File "/usr/lib/python3.6/site-packages/leapp/libraries/stdlib/__init__.py", line 146, in _logfile_logging_handler
api.current_logger().debug(line)
Message: 'Created symlink /etc/systemd/system/sysinit.target.wants/multipathd.service \u2192 /usr/lib/systemd/system/multipathd.service.'
Arguments: ()
Expected behavior
If Leapp is to override the locale passed at start to the Python interpreter and it, it should perform this task completely. Evidently, overriding the environment variables alone is not enough for Python.
System information (please complete the following information):
- OS and version: AlmaLinux 8.10
# uname -a
:Linux aaaaaa.openstack.build 4.18.0-553.16.1.el8_10.x86_64 #1 SMP Thu Aug 8 07:11:46 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
# rpm -qa "*leapp*"
(or shorthashes of commits in case of manual installation):
# rpm -qa leapp*
leapp-data-almalinux-0.5-1.el8.20241127.noarch
leapp-deps-0.18.0-2.el8.noarch
leapp-0.18.0-2.el8.noarch
leapp-upgrade-el8toel9-0.21.0-4.el8.elevate.4.noarch
leapp-upgrade-el8toel9-deps-0.21.0-4.el8.elevate.4.noarch
Additional context
I'm reasonably sure that you inherited this bug from upstream, but I though that I should file here first.