Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete destructor from BootImageDracut #2451

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 27 additions & 34 deletions kiwi/boot/image/dracut.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#
import os
import logging
from contextlib import ExitStack
from typing import (
List, Optional, Dict
)
Expand Down Expand Up @@ -51,9 +52,6 @@ def post_init(self) -> None:

Initialize empty list of dracut caller options
"""
self.device_mount: Optional[MountManager] = None
self.proc_mount: Optional[MountManager] = None

# signing keys are only taken into account on install of
# packages. As dracut runs from a pre defined root directory,
# no signing keys will be used in the process of creating
Expand Down Expand Up @@ -198,30 +196,32 @@ def create_initrd(
] if self.omit_modules else []
options = self.dracut_options + modules_args + included_files
if kernel_details:
self.device_mount = MountManager(
device='/dev',
mountpoint=self.boot_root_directory + '/dev'
)
self.device_mount.bind_mount()
self.proc_mount = MountManager(
device='/proc',
mountpoint=self.boot_root_directory + '/proc'
)
self.proc_mount.bind_mount()
dracut_call = Command.run(
[
'chroot', self.boot_root_directory,
'dracut', '--verbose',
'--no-hostonly',
'--no-hostonly-cmdline'
] + options + [
dracut_initrd_basename,
kernel_details.version
],
stderr_to_stdout=True
)
self.device_mount.umount()
self.proc_mount.umount()
with ExitStack() as stack:
device_mount = MountManager(
device='/dev',
mountpoint=self.boot_root_directory + '/dev'
)
stack.push(device_mount)
device_mount.bind_mount()
proc_mount = MountManager(
device='/proc',
mountpoint=self.boot_root_directory + '/proc'
)
stack.push(proc_mount)
proc_mount.bind_mount()
dracut_call = Command.run(
[
'chroot', self.boot_root_directory,
'dracut', '--verbose',
'--no-hostonly',
'--no-hostonly-cmdline'
] + options + [
dracut_initrd_basename,
kernel_details.version
],
stderr_to_stdout=True
)

log.debug(dracut_call.output)
Command.run(
[
Expand Down Expand Up @@ -259,10 +259,3 @@ def _create_profile_environment(self) -> None:
profile.create(
Defaults.get_profile_file(self.boot_root_directory)
)

def __del__(self):
log.info('Cleaning up %s instance', type(self).__name__)
if self.device_mount:
self.device_mount.umount()
if self.proc_mount:
self.proc_mount.umount()
7 changes: 0 additions & 7 deletions test/unit/boot/image/dracut_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,3 @@ def test_create_initrd(

def test_has_initrd_support(self):
assert self.boot_image.has_initrd_support() is True

def test_destructor(self):
self.boot_image.device_mount = Mock()
self.boot_image.proc_mount = Mock()
self.boot_image.__del__()
self.boot_image.device_mount.umount.assert_called_once_with()
self.boot_image.proc_mount.umount.assert_called_once_with()
Loading