Package: fai-client
Version: 3.2.17~lenny1, 3.2.20
So the basic problem is that the setup-storage script doesn't properly
find the logical volumes it's supposed to preserve when they exist.
Here's a full example:
- First, a disk_config
# TEST
# 2009-06-01
# bpkroth
#
# This file is a disk_config file uses the setup-storage syntax to create an
# LVM'd vm server disk layout that preserves partitions. It is expected to
# be at least 12G.
#
# Setup the first disk to use an msdos partition table and two partitions, one
# for /boot and the rest for LVM.
disk_config disk1 bootable:1 fstabkey:label
# preserve_reinstall:2
primary /boot 256M ext3 defaults,rw
createopts="-L boot"
primary - 10G- - -
# Setup LVM to contain all the system partitions.
# Make sure that /local.hd is preserved unless it doesn't exist and gets
# to claim almost all of whatever's left. It leaves a little bit in
# case we need to resize later.
vg vg disk1.2
disk_config lvm fstabkey:label preserve_reinstall:vg-localhd
vg-swap swap 512M-1G swap sw
createopts="-L swap"
vg-root / 4G-8G ext3
defaults,rw,errors=remount-ro createopts="-L root"
vg-var /var 1G-2G ext3 defaults,rw
createopts="-L var"
vg-localhd /local.hd 1-90% ext3
defaults,rw,nosuid,nodev createopts="-L local.hd -m 1"
- Next, run the config:
# parted /dev/sda mklabel msdos # necessary for fresh VMDKs.
# flag_initial=1 disklist=sda setup-storage -X -f /tmp/TEST
- Next, remove a logical volume:
# lvremove -f vg/root
- Run setup storage again (without flag_initial) to reinstall the
partition. Dies with this message:
Preserved volume vg/localhd does not exist.
Now, the problem happens to be that in Commands.pm two hashes are used,
FAI::config{volumes}{lv} and FAI::current_lvm_config{vg}{volumes}{lv},
except their keys are lv and /dev/vg/lv respectively.
Also, while testing that one I discovered that in Volumes.pm a bad
concatenation error occurs if the volume group exists but is empty.
Here's the error message for that one:
Use of uninitialized value in concatenation (.) or string at
/usr/share/fai/setup-storage//Volumes.pm line 313.
Use of uninitialized value in concatenation (.) or string at
/usr/share/fai/setup-storage//Volumes.pm line 313.
INTERNAL ERROR in setup-storage:
convert_unit
Please report this error to the Debian Bug Tracking System.
Attached is a patch to deal with both of these problems.
Brian
diff -rubB lib/setup-storage/Commands.pm
/pong/usr5/b/bpkroth/tmp/setup-storage/Commands.pm
--- lib/setup-storage/Commands.pm 2009-06-08 08:00:59.000000000 -0500
+++ /pong/usr5/b/bpkroth/tmp/setup-storage/Commands.pm 2009-06-08
08:19:42.000000000 -0500
@@ -374,7 +374,21 @@
my $lv_resize_pre = "";
# remove, resize, create the logical volumes
# remove all volumes that do not exist anymore or need not be preserved
- foreach my $lv (keys %{ $FAI::current_lvm_config{$vg}{volumes} }) {
+
+ # FIXME:
+ # There's a problem with this code since the
+ # FAI::current_lvm_config{vg}{volumes} hash has keys of the form /dev/vg/lv,
+ # but the FAI::configs{config}{volumes} hash has keys of the form lv. I've
+ # tried to fix this in the few places I caught it so far as preserving
+ # partitions was concerned, but that's all. I imagine this causes problems
+ # elsewhere as well.
+ # 2009-06-07
+ # bpkroth
+
+ foreach my $lv_path (keys %{ $FAI::current_lvm_config{$vg}{volumes} }) {
+ my $lv = $lv_path;
+ $lv =~ s#/dev/$vg/##;
+ print STDERR "lv: $lv\n";
# skip preserved/resized volumes
if (defined ( $FAI::configs{$config}{volumes}{$lv})
&& ($FAI::configs{$config}{volumes}{$lv}{size}{preserve} == 1)) {
@@ -391,24 +405,25 @@
# now create or resize the configured logical volumes
foreach my $lv (keys %{ $FAI::configs{$config}{volumes} }) {
+ my $lv_path = "/dev/$vg/$lv";
# reference to the size of the current logical volume
my $lv_size = (\%FAI::configs)->{$config}->{volumes}->{$lv}->{size};
# skip preserved partitions, but ensure that they exist
if ($lv_size->{preserve}) {
- defined ($FAI::current_lvm_config{$vg}{volumes}{$lv})
- or die "Preserved volume $vg/$lv does not exist\n";
+ defined ($FAI::current_lvm_config{$vg}{volumes}{$lv_path}) or
+ die "Preserved volume $vg/$lv does not exist\n";
warn "$vg/$lv will be preserved\n";
next;
}
# resize the volume
if ($lv_size->{resize}) {
- defined ($FAI::current_lvm_config{$vg}{volumes}{$lv})
+ defined ($FAI::current_lvm_config{$vg}{volumes}{$lv_path})
or die "Resized volume $vg/$lv does not exist\n";
warn "$vg/$lv will be resized\n";
if ($lv_size->{eff_size} <
- $FAI::current_lvm_config{$vg}{volumes}{$lv}{size})
+ $FAI::current_lvm_config{$vg}{volumes}{$lv_path}{size})
{
&FAI::push_command( "parted -s /dev/$vg/$lv resize 1 0 " .
$lv_size->{eff_size} . "B",
"vg_enabled_$vg,$lv_rm_pre", "lv_shrink_$vg/$lv" );
Only in lib/setup-storage: .svn
diff -rubB lib/setup-storage/Volumes.pm
/pong/usr5/b/bpkroth/tmp/setup-storage/Volumes.pm
--- lib/setup-storage/Volumes.pm 2009-06-08 08:00:59.000000000 -0500
+++ /pong/usr5/b/bpkroth/tmp/setup-storage/Volumes.pm 2009-06-08
08:19:53.000000000 -0500
@@ -308,9 +308,29 @@
# store the vg size in MB
my %vg_info = get_volume_group_information($vg);
+
+ # FIXME:
+ # If the volume group exists but is empty, this results in the following
error:
+ # Use of uninitialized value in concatenation (.) or string at
/usr/share/fai/setup-storage//Volumes.pm line 313.
+ # Use of uninitialized value in concatenation (.) or string at
/usr/share/fai/setup-storage//Volumes.pm line 313.
+ # INTERNAL ERROR in setup-storage:
+ # convert_unit
+ # Please report this error to the Debian Bug Tracking System.
+ # 2009-06-07
+ # bpkroth
+ #
+ #$FAI::current_lvm_config{$vg}{size} =
+ # &FAI::convert_unit( $vg_info{alloc_pe_size} .
+ # $vg_info{alloc_pe_size_unit} );
+ my $unit_to_convert;
+ if ($vg_info{alloc_pe_size} && $vg_info{alloc_pe_size_unit}) {
+ $unit_to_convert = $vg_info{alloc_pe_size} .
$vg_info{alloc_pe_size_unit};
+ }
+ else {
+ $unit_to_convert = '0M';
+ }
$FAI::current_lvm_config{$vg}{size} =
- &FAI::convert_unit( $vg_info{alloc_pe_size} .
- $vg_info{alloc_pe_size_unit} );
+ &FAI::convert_unit( $unit_to_convert );
# store the logical volumes and their sizes
my %lv_info = get_logical_volume_information($vg);