Package: vmdb2
Version: 0.13.2+git20190215-1

Hi,

I pre-created my LV using the same lvcreate syntax that doesn't work from
within vmdb2 (see previous bug filed), and used with the invocation:

% sudo vmdb2 foo-bar-1.vmdb.yml --image /dev/vg0/foo-bar-1-root --verbose 
--log=foo-bar-1.vmd.log

The boot loader step in foo-bar-1.vmdb.yml was the default one from the
manual:

  - grub: bios
    tag: root
    console: serial

But the log said:

2019-11-27 11:38:31 INFO Installing GRUB for BIOS
2019-11-27 11:38:31 ERROR Do not understand partition device name 
/dev/mapper/vg0-foo--bar--1--root1
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/vmdb/app.py", line 107, in 
run_steps_helper
    method(step, self.settings, state)
  File "/usr/lib/python3/dist-packages/vmdb/plugins/grub_plugin.py", line 98, 
in run
    self.install_bios(step, settings, state)
  File "/usr/lib/python3/dist-packages/vmdb/plugins/grub_plugin.py", line 115, 
in install_bios
    self.install_grub(step, settings, state, grub_package, grub_target)
  File "/usr/lib/python3/dist-packages/vmdb/plugins/grub_plugin.py", line 128, 
in install_grub
    image_dev = self.get_image_loop_device(root_dev)
  File "/usr/lib/python3/dist-packages/vmdb/plugins/grub_plugin.py", line 204, 
in get_image_loop_device
    partition_device))
Exception: Do not understand partition device name 
/dev/mapper/vg0-foo--bar--1--root1
2019-11-27 11:38:31 INFO Something went wrong, cleaning up!

I remembered I used to be able to work around these kinds of problems in
similar situations by doing sudo losetup /dev/loop0 /dev/$vg/$host-root
and then operating on /dev/loop0. (That's what worked with vmdebootstrap.)
However, with vmdb2, that doesn't work either, the log says:

2019-11-27 11:41:09 INFO Running step: {'mklabel': 'gpt', 'device': 
'/dev/loop0'}
2019-11-27 11:41:09 INFO Calling <bound method MklabelStepRunner.run of 
<partition_plugin.MklabelStepRunner object at 0x7f4ba4587828>>
2019-11-27 11:41:09 INFO Exec: ['parted', '-s', '/dev/loop0', 'mklabel', 'gpt']
2019-11-27 11:41:09 DEBUG run external command: [['parted', '-s', '/dev/loop0', 
'mklabel', 'gpt']]
2019-11-27 11:41:09 INFO Calling <bound method 
StepRunnerInterface.run_even_if_skipped of <partition_plugin.MklabelStepRunner 
object at 0x7f4ba4587828>>
2019-11-27 11:41:09 INFO Running step: {'mkpart': 'primary', 'device': 
'/dev/loop0', 'start': '0%', 'end': '100%', 'tag': 'root'}
2019-11-27 11:41:09 INFO Calling <bound method MkpartStepRunner.run of 
<partition_plugin.MkpartStepRunner object at 0x7f4ba4587978>>
2019-11-27 11:41:09 INFO Exec: ['parted', '-m', '/dev/loop0', 'print']
2019-11-27 11:41:09 DEBUG run external command: [['parted', '-m', '/dev/loop0', 
'print']]
2019-11-27 11:41:09 DEBUG STDOUT: 
b'BYT;\n/dev/loop0:4295MB:loopback:512:512:gpt:Loopback device:;\n'
2019-11-27 11:41:09 INFO Exec: ['parted', '-s', '/dev/loop0', 'mkpart', 
'primary', 'ext2', '0%', '100%']
2019-11-27 11:41:09 DEBUG run external command: [['parted', '-s', '/dev/loop0', 
'mkpart', 'primary', 'ext2', '0%', '100%']]
2019-11-27 11:41:10 INFO Exec: ['parted', '-m', '/dev/loop0', 'print']
2019-11-27 11:41:10 DEBUG run external command: [['parted', '-m', '/dev/loop0', 
'print']]
2019-11-27 11:41:10 DEBUG STDOUT: 
b'BYT;\n/dev/loop0:4295MB:loopback:512:512:gpt:Loopback 
device:;\n1:1049kB:4294MB:4293MB:ext4:primary:;\n'
2019-11-27 11:41:10 INFO remembering partition /dev/loop01 as root
2019-11-27 11:41:10 INFO Calling <bound method 
StepRunnerInterface.run_even_if_skipped of <partition_plugin.MkpartStepRunner 
object at 0x7f4ba4587978>>
2019-11-27 11:41:10 INFO Running step: {'kpartx': '/dev/loop0'}
2019-11-27 11:41:10 INFO Calling <bound method KpartxStepRunner.run of 
<partition_plugin.KpartxStepRunner object at 0x7f4ba4587940>>
2019-11-27 11:41:10 INFO Exec: ['kpartx', '-asv', '/dev/loop0']
2019-11-27 11:41:10 DEBUG run external command: [['kpartx', '-asv', 
'/dev/loop0']]
2019-11-27 11:41:10 DEBUG STDOUT: b'add map loop0p1 (253:3): 0 8384512 linear 
7:0 2048\n'
2019-11-27 11:41:10 INFO remembering /dev/mapper/loop0p1 as root
2019-11-27 11:41:10 ERROR Already has device: root
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/vmdb/app.py", line 107, in 
run_steps_helper
    method(step, self.settings, state)
  File "/usr/lib/python3/dist-packages/vmdb/plugins/partition_plugin.py", line 
109, in run
    state.tags.set_dev(tag, dev)
  File "/usr/lib/python3/dist-packages/vmdb/tags.py", line 61, in set_dev
    raise AlreadyHasDev(tag)
vmdb.tags.AlreadyHasDev: Already has device: root
2019-11-27 11:41:10 INFO Something went wrong, cleaning up!

This latter part is clearly a failure to recognize that the partition number
suffixes cannot be concatenated onto a base device name that ends in a
number. Note how kpartx adds the letter 'p' inbetween.

Please fix it. TIA.

-- 
Josip Rodin

Reply via email to