[Fai-commit] r5820 - branches/experimental/patches
Michael Tautschnig
mt at alioth.debian.org
Mon Jun 28 09:29:24 UTC 2010
Author: mt
Date: 2010-06-28 09:29:24 +0000 (Mon, 28 Jun 2010)
New Revision: 5820
Modified:
branches/experimental/patches/setup-storage_always-format
branches/experimental/patches/setup-storage_exit-codes
branches/experimental/patches/setup-storage_external-journal
branches/experimental/patches/setup-storage_lvm-preserve2
branches/experimental/patches/setup-storage_resize2fs
branches/experimental/patches/setup-storage_tmpfs
Log:
- improved handling of existing LVM volumes
- make setup-storage fail if some subcommand fails
Modified: branches/experimental/patches/setup-storage_always-format
===================================================================
--- branches/experimental/patches/setup-storage_always-format 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_always-format 2010-06-28 09:29:24 UTC (rev 5820)
@@ -22,7 +22,7 @@
# the desired RAID level
my $level = $vol->{mode};
-@@ -487,6 +493,10 @@
+@@ -489,6 +495,10 @@
defined ($FAI::current_lvm_config{$vg}{volumes}{$lv})
or die "Preserved volume $vg/$lv does not exist\n";
warn "$vg/$lv will be preserved\n";
@@ -33,7 +33,7 @@
next;
}
-@@ -530,6 +540,10 @@
+@@ -532,6 +542,10 @@
}
}
@@ -44,7 +44,7 @@
next;
}
-@@ -1010,8 +1024,9 @@
+@@ -1019,8 +1033,9 @@
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
# skip preserved/resized/extended partitions
Modified: branches/experimental/patches/setup-storage_exit-codes
===================================================================
--- branches/experimental/patches/setup-storage_exit-codes 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_exit-codes 2010-06-28 09:29:24 UTC (rev 5820)
@@ -1,7 +1,7 @@
-2010-06-20 Michael Tautschnig <mt at debian.org>
+2010-06-28 Michael Tautschnig <mt at debian.org>
- * setup-storage/Exec.pm: Improved handling of non-zero exit codes; later this
- will be changed to die on almost all non-zero exits of subcommands.
+ * setup-storage/Exec.pm: All unexpected non-zero exit codes of subcommands
+ lead to immediate failure of setup-storage.
Index: trunk/lib/setup-storage/Exec.pm
===================================================================
--- trunk.orig/lib/setup-storage/Exec.pm
@@ -118,24 +118,51 @@
},
{
error => "ntfsresize_1",
-@@ -161,6 +174,16 @@
+@@ -161,6 +174,43 @@
stdout_regex => "",
program => "ntfsresize",
response => "die",
+ exit_codes => [0..255],
+ },
+ {
++ error => "pvremove_pv_in_vg",
++ message => "Removing physical volume that is still part of volume group\n",
++ stderr_regex => "WARNING: Wiping physical volume label from \\S+ of volume group \".*\"",
++ stdout_regex => "",
++ program => "pvremove -ff -y \\S+",
++ response => "warn",
++ exit_codes => [5],
++ },
++ {
++ error => "pvcreate_pv_in_vg",
++ message => "Recreating physical volume that is already part of volume group\n",
++ stderr_regex => "Can't initialize physical volume \"\\S+\" of volume group \".*\" without -ff",
++ stdout_regex => "",
++ program => "pvcreate \\S+",
++ response => "warn",
++ exit_codes => [5],
++ },
++ {
++ error => "vgcreate_vg_exists",
++ message => "Volume group already/still exists\n",
++ stderr_regex => "/dev/.*: already exists in filesystem",
++ stdout_regex => "",
++ program => "vgcreate .* \\S+",
++ response => "warn",
++ exit_codes => [5],
++ },
++ {
+ error => "catch_all_nonzero_exit_code",
+ message => "Command had non-zero exit code\n",
+ stderr_regex => "",
+ stdout_regex => "",
+ program => ".*",
-+ response => "warn",
++ response => "die",
+ exit_codes => [1..255],
},
];
-@@ -300,6 +323,7 @@
+@@ -300,6 +350,7 @@
my @stdout = ();
my $stderr_line = "";
my $stdout_line = "";
@@ -143,7 +170,7 @@
#make tempfile, get perl filehandle and filename of the file
my ($stderr_fh, $stderr_filename) = File::Temp::tempfile(UNLINK => 1);
-@@ -314,9 +338,10 @@
+@@ -314,9 +365,10 @@
# execute the bash command, write stderr and stdout into the testfiles
print "Executing: $command\n";
`$command 1> $stdout_filename 2> $stderr_filename`;
@@ -156,7 +183,7 @@
}
# read the tempfile into lists, each element of the list one line
-@@ -344,11 +369,11 @@
+@@ -344,11 +396,11 @@
#get the error, if there was any
foreach my $err (@$FAI::error_codes) {
Modified: branches/experimental/patches/setup-storage_external-journal
===================================================================
--- branches/experimental/patches/setup-storage_external-journal 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_external-journal 2010-06-28 09:29:24 UTC (rev 5820)
@@ -70,7 +70,7 @@
# possibly tune the file system - this depends on whether the file system
# supports tuning at all
-@@ -956,10 +989,12 @@
+@@ -965,10 +998,12 @@
my $fs = $part->{filesystem};
$fs = "" unless defined($fs);
Modified: branches/experimental/patches/setup-storage_lvm-preserve2
===================================================================
--- branches/experimental/patches/setup-storage_lvm-preserve2 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_lvm-preserve2 2010-06-28 09:29:24 UTC (rev 5820)
@@ -1,8 +1,8 @@
-2010-03-19 Michael Tautschnig <mt at debian.org>
+2010-06-28 Michael Tautschnig <mt at debian.org>
* setup-storage/{Commands.pm,Volumes.pm}: Completed support for preserve in
LVM/RAID contexts; extended checking for volume groups that remain alive,
- fixed bug in LV resize code.
+ fixed bug in LV resize code, disable existing volume groups.
Index: trunk/lib/setup-storage/Commands.pm
===================================================================
--- trunk.orig/lib/setup-storage/Commands.pm
@@ -115,24 +115,72 @@
$pre_dev .= ",pv_done_$_" foreach (keys %rm_devs);
&FAI::push_command( "vgreduce $vg " . join (" ", keys %rm_devs),
"vg_extended_$vg$pre_dev", "vg_created_$vg" );
-@@ -447,11 +464,12 @@
+@@ -445,20 +462,23 @@
+ 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} }) {
- # skip preserved/resized volumes
+- foreach my $lv (keys %{ $FAI::current_lvm_config{$vg}{volumes} }) {
+- # skip preserved/resized volumes
- if (defined ( $FAI::configs{$config}{volumes}{$lv})
- && ($FAI::configs{$config}{volumes}{$lv}{size}{preserve} == 1)) {
- $lv_resize_pre .= ",lv_resize_$vg/$lv" if
- $FAI::configs{$config}{volumes}{$lv}{size}{resize};
- next;
-+ if (defined ( $FAI::configs{$config}{volumes}{$lv})) {
-+ next if ($FAI::configs{$config}{volumes}{$lv}{size}{preserve} == 1);
-+ if (1 == $FAI::configs{$config}{volumes}{$lv}{size}{resize}) {
-+ $lv_resize_pre .= ",lv_resize_$vg/$lv";
-+ next;
+- }
++ if (defined($FAI::current_lvm_config{$vg})) {
++ foreach my $lv (keys %{ $FAI::current_lvm_config{$vg}{volumes} }) {
++ # skip preserved/resized volumes
++ if (defined ( $FAI::configs{$config}{volumes}{$lv})) {
++ next if ($FAI::configs{$config}{volumes}{$lv}{size}{preserve} == 1);
++ if (1 == $FAI::configs{$config}{volumes}{$lv}{size}{resize}) {
++ $lv_resize_pre .= ",lv_resize_$vg/$lv";
++ next;
++ }
+ }
+
+- &FAI::push_command( "lvremove -f $vg/$lv", "vg_enabled_$vg", "lv_rm_$vg/$lv");
+- $lv_rm_pre .= ",lv_rm_$vg/$lv";
++ &FAI::push_command( "lvremove -f $vg/$lv", "vg_enabled_$vg", "lv_rm_$vg/$lv");
++ $lv_rm_pre .= ",lv_rm_$vg/$lv";
++ }
++ $lv_rm_pre =~ s/^,//;
++ $lv_resize_pre =~ s/^,//;
+ }
+- $lv_rm_pre =~ s/^,//;
+- $lv_resize_pre =~ s/^,//;
+
+ # now create or resize the configured logical volumes
+ foreach my $lv (keys %{ $FAI::configs{$config}{volumes} }) {
+@@ -519,6 +539,10 @@
+ ################################################################################
+ sub build_lvm_commands {
+
++ # disable volumes if there are pre-existing ones
++ &FAI::push_command("vgchange -a n", "", "vgchange_a_n")
++ if (scalar(keys %FAI::current_lvm_config));
++
+ # loop through all configs
+ foreach my $config (keys %FAI::configs) {
+
+@@ -540,6 +564,7 @@
+ $type_pre .= ",exist_$d"
+ }
}
++ $type_pre .= ",vgchange_a_n" if (scalar(keys %FAI::current_lvm_config));
- &FAI::push_command( "lvremove -f $vg/$lv", "vg_enabled_$vg", "lv_rm_$vg/$lv");
+ # create the volume group or add/remove devices
+ &FAI::create_volume_group($config);
+@@ -754,7 +779,9 @@
+ or die "Can't change disklabel, partitions are to be preserved\n";
+
+ # write the disklabel to drop the previous partition table
+- &FAI::push_command( "parted -s $disk mklabel $label", "exist_$disk",
++ my $pre = "exist_$disk";
++ $pre .= ",vgchange_a_n" if (scalar(keys %FAI::current_lvm_config));
++ &FAI::push_command( "parted -s $disk mklabel $label", $pre,
+ "cleared1_$disk" );
+
+ &FAI::rebuild_preserved_partitions($config, \@to_preserve);
Index: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk.orig/lib/setup-storage/Volumes.pm
Modified: branches/experimental/patches/setup-storage_resize2fs
===================================================================
--- branches/experimental/patches/setup-storage_resize2fs 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_resize2fs 2010-06-28 09:29:24 UTC (rev 5820)
@@ -8,7 +8,7 @@
===================================================================
--- trunk.orig/lib/setup-storage/Commands.pm
+++ trunk/lib/setup-storage/Commands.pm
-@@ -496,18 +496,38 @@
+@@ -498,18 +498,38 @@
or die "Resized volume $vg/$lv does not exist\n";
warn "$vg/$lv will be resized\n";
@@ -55,7 +55,7 @@
}
next;
-@@ -516,10 +536,10 @@
+@@ -518,10 +538,10 @@
my ($create_options) = $FAI::configs{$config}{volumes}{$lv}{lvcreateopts};
# prevent warnings of uninitialized variables
$create_options = '' unless $create_options;
@@ -68,7 +68,7 @@
"exist_/dev/$vg/$lv" );
# create the filesystem on the volume
-@@ -847,25 +867,42 @@
+@@ -856,25 +876,42 @@
my $start = $part->{start_byte};
my $end = $part->{end_byte};
Modified: branches/experimental/patches/setup-storage_tmpfs
===================================================================
--- branches/experimental/patches/setup-storage_tmpfs 2010-06-26 07:14:58 UTC (rev 5819)
+++ branches/experimental/patches/setup-storage_tmpfs 2010-06-28 09:29:24 UTC (rev 5820)
@@ -21,7 +21,7 @@
($config eq "RAID") or &FAI::internal_error("Invalid config $config");
# create all raid devices
-@@ -574,8 +574,8 @@
+@@ -580,8 +580,8 @@
# loop through all configs
foreach my $config (keys %FAI::configs) {
@@ -32,7 +32,7 @@
($config =~ /^VG_(.+)$/) or &FAI::internal_error("Invalid config $config");
next if ($1 eq "--ANY--");
my $vg = $1; # the volume group
-@@ -1000,8 +1000,8 @@
+@@ -1009,8 +1009,8 @@
# loop through all configs
foreach my $config ( keys %FAI::configs ) {
More information about the Fai-commit
mailing list