From a6445b391a01bf17d3ad8229ca1185b10479f467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20M=C3=A9trich?= Date: Mon, 7 Nov 2022 09:33:32 +0100 Subject: [PATCH 24/32] ziplconverttoblscfg: bind mount /dev & /boot into the userspace container (s390x) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The conversion of ZIPL to BLS on IBM Z machines failed when a) the machine was configured using ZFCP instead of DASD b) /boot was not on a separate partition In case a), the zipl-switch-to-blscfg script failed as the /dev has not been propagated to into the el8userspace container. Regarding that, the /dev did not contain all required devices needed for the correct conversion. With this fix, the /dev is bindmounted into the el8userspace container using the (systemd-nspawn) `--bind` option. The direct bind mounting via `leapp.libraries.common.mounting.BindMount` cannot be used in this case as it blocks the correct start of the container. In case b), the content of /boot has been removed during the upgrade due to problems when using BindMount on normal directory (that is not mountpoint). This has been possibly resolved by this commit also, as the /boot has been propagated using the --bind (sysmd-nspawn) option as well. (Untested) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2140563 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1901440 Signed-off-by: Renaud Métrich --- .../actors/ziplconverttoblscfg/actor.py | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/repos/system_upgrade/el7toel8/actors/ziplconverttoblscfg/actor.py b/repos/system_upgrade/el7toel8/actors/ziplconverttoblscfg/actor.py index e80c335d..441c538b 100644 --- a/repos/system_upgrade/el7toel8/actors/ziplconverttoblscfg/actor.py +++ b/repos/system_upgrade/el7toel8/actors/ziplconverttoblscfg/actor.py @@ -38,40 +38,40 @@ class ZiplConvertToBLSCFG(Actor): # replace the original boot directory inside the container by the host one # - as we cannot use zipl* pointing anywhere else than default directory # - no, --bls-directory is not solution - with mounting.BindMount(source='/boot', target=os.path.join(userspace.path, 'boot')): + # also make sure device nodes are available (requirement for zipl-switch-to-blscfg) + binds = ['/boot', '/dev'] + with mounting.NspawnActions(base_dir=userspace.path, binds=binds) as context: userspace_zipl_conf = os.path.join(userspace.path, 'etc', 'zipl.conf') if os.path.exists(userspace_zipl_conf): os.remove(userspace_zipl_conf) - with mounting.NullMount(target=userspace.path) as userspace: - with userspace.nspawn() as context: - context.copy_to('/etc/zipl.conf', '/etc/zipl.conf') - # zipl needs this one as well - context.copy_to('/etc/machine-id', '/etc/machine-id') - try: - context.call(['/usr/sbin/zipl-switch-to-blscfg']) - if filecmp.cmp('/etc/zipl.conf', userspace_zipl_conf): - # When the files are same, zipl failed - see the switch script - raise OSError('Failed to convert the ZIPL configuration to BLS.') - context.copy_from('/etc/zipl.conf', '/etc/zipl.conf') - except OSError as e: - self.log.error('Could not call zipl-switch-to-blscfg command.', - exc_info=True) - raise StopActorExecutionError( - message='Failed to execute zipl-switch-to-blscfg.', - details={'details': str(e)} - ) - except CalledProcessError as e: - self.log.error('zipl-switch-to-blscfg execution failed,', - exc_info=True) - raise StopActorExecutionError( - message='zipl-switch-to-blscfg execution failed with non zero exit code.', - details={'details': str(e), 'stdout': e.stdout, 'stderr': e.stderr} - ) + context.copy_to('/etc/zipl.conf', '/etc/zipl.conf') + # zipl needs this one as well + context.copy_to('/etc/machine-id', '/etc/machine-id') + try: + context.call(['/usr/sbin/zipl-switch-to-blscfg']) + if filecmp.cmp('/etc/zipl.conf', userspace_zipl_conf): + # When the files are same, zipl failed - see the switch script + raise OSError('Failed to convert the ZIPL configuration to BLS.') + context.copy_from('/etc/zipl.conf', '/etc/zipl.conf') + except OSError as e: + self.log.error('Could not call zipl-switch-to-blscfg command.', + exc_info=True) + raise StopActorExecutionError( + message='Failed to execute zipl-switch-to-blscfg.', + details={'details': str(e)} + ) + except CalledProcessError as e: + self.log.error('zipl-switch-to-blscfg execution failed,', + exc_info=True) + raise StopActorExecutionError( + message='zipl-switch-to-blscfg execution failed with non zero exit code.', + details={'details': str(e), 'stdout': e.stdout, 'stderr': e.stderr} + ) - # FIXME: we do not want to continue anymore, but we should clean - # better. - # NOTE: Basically, just removal of the /boot/loader dir content inside - # could be enough, but we cannot remove /boot/loader because of boom - # - - if we remove it, we will remove the snapshot as well - # - - on the other hand, we shouldn't keep it there if zipl - # - - has not been converted to BLS + # FIXME: we do not want to continue anymore, but we should clean + # better. + # NOTE: Basically, just removal of the /boot/loader dir content inside + # could be enough, but we cannot remove /boot/loader because of boom + # - - if we remove it, we will remove the snapshot as well + # - - on the other hand, we shouldn't keep it there if zipl + # - - has not been converted to BLS -- 2.38.1