summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanou Ishii <ishii.vanou@fujitsu.com>2022-09-13 16:53:07 +0900
committerVanou Ishii <ishii.vanou@fujitsu.com>2022-09-22 19:34:12 +0900
commit0bf579c955477da9a43e546703146b8b2b24d05f (patch)
tree6004681c8688d4033875ebdb63340d16b24c99fb
parented6a8d28b7e8f1a6f091023863db26bb2a993a40 (diff)
downloadironic-python-agent-0bf579c955477da9a43e546703146b8b2b24d05f.tar.gz
Fix failure of bind mount in _install_grub2
When IPA runs _install_grub2, IPA tries to bind mount /dev, /proc and /run to <temporal directory path root partition mounted>/{dev,proc,run}. However that bind mount fails because there aren't such mount point path under temporal directory. To fix this failure, this patch add mkdir command before bind mount. Story: 2010292 Task: 46273 Change-Id: I434ce1bf1863ee0f11c4d09918d6d2d8dc065c02
-rw-r--r--ironic_python_agent/extensions/image.py1
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_image.py48
2 files changed, 46 insertions, 3 deletions
diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py
index de880f84..46be48c2 100644
--- a/ironic_python_agent/extensions/image.py
+++ b/ironic_python_agent/extensions/image.py
@@ -425,6 +425,7 @@ def _mount_for_chroot(path):
LOG.debug('Mounting Linux standard partitions for bootloader '
'configuration generation')
for fs in BIND_MOUNTS:
+ utils.execute('mkdir', '-p', path + fs)
utils.execute('mount', '-o', 'bind', fs, path + fs)
utils.execute('mount', '-t', 'sysfs', 'none', path + '/sys')
diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py
index e488b74f..6958036f 100644
--- a/ironic_python_agent/tests/unit/extensions/test_image.py
+++ b/ironic_python_agent/tests/unit/extensions/test_image.py
@@ -538,10 +538,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
image._install_grub2(self.fake_dev, self.fake_root_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -601,10 +604,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
prep_boot_part_uuid=self.fake_prep_boot_part_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -674,10 +680,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
target_boot_mode='uefi')
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -775,10 +784,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_open.assert_has_calls(write_calls)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -883,10 +895,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_open.assert_has_calls(write_calls)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1001,10 +1016,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1087,10 +1105,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1168,10 +1189,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.assertFalse(mock_efi_setup.called)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1289,10 +1313,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.assertFalse(mock_efi_setup.called)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1414,10 +1441,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
self.fake_dir + '/boot/efi/EFI')])
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1494,10 +1524,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
target_boot_mode='uefi')
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1591,10 +1624,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
efi_system_part_uuid=self.fake_efi_system_part_uuid)
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1705,7 +1741,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
mock_execute, mock_dispatch):
# return success for every execute call
- mock_execute.side_effect = [('', '')] * 21
+ mock_execute.side_effect = [('', '')] * 24
# make grub2-install calls fail
grub_failure = processutils.ProcessExecutionError(
@@ -1716,8 +1752,8 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
exit_code=1,
cmd='grub2-install'
)
- mock_execute.side_effect[9] = grub_failure
- mock_execute.side_effect[10] = grub_failure
+ mock_execute.side_effect[12] = grub_failure
+ mock_execute.side_effect[13] = grub_failure
mock_get_part_uuid.side_effect = [self.fake_root_part,
self.fake_efi_system_part]
@@ -1734,10 +1770,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',
@@ -1835,10 +1874,13 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
expected = [
mock.call('mount', '/dev/fake2', self.fake_dir),
+ mock.call('mkdir', '-p', self.fake_dir + '/dev'),
mock.call('mount', '-o', 'bind', '/dev',
self.fake_dir + '/dev'),
+ mock.call('mkdir', '-p', self.fake_dir + '/proc'),
mock.call('mount', '-o', 'bind', '/proc',
self.fake_dir + '/proc'),
+ mock.call('mkdir', '-p', self.fake_dir + '/run'),
mock.call('mount', '-o', 'bind', '/run',
self.fake_dir + '/run'),
mock.call('mount', '-t', 'sysfs', 'none',