marsadm: fix leave-resource cleanup

Now the sequence leave-resource ; join-resource should work.

When the last member of the resource has gone and create-resource is
tried anew, there is a new saftey measure: the old resource directory
is left over deliberately, thus the new create-resource will deny creation
because some unreachable cluster node may have existed, such that we
didn't even know of its resource membership. This very special
case requires --force and some handwork cleanup.
This commit is contained in:
Thomas Schoebel-Theuer 2013-06-27 12:05:25 +02:00 committed by Thomas Schoebel-Theuer
parent 62b016d4cc
commit 45f462026f
1 changed files with 10 additions and 2 deletions

View File

@ -799,7 +799,8 @@ sub create_res {
my $resdir = "$mars/resource-$res";
if ($create) {
ldie "resource '$res' already exists\n" if -d $resdir;
ldie "resource directory '$res' already exists; you may override this via --force\n" if (!$force && -d $resdir);
ldie "resource directory '$res' has some contents -- remove by hand if you are sure that you really know what you are doing.\n" if glob("$resdir/*.status");
lprint "creating new resource '$res'\n";
} else {
if ( -e "$resdir/connect-$host" || -e "$resdir/data-$host") {
@ -949,7 +950,7 @@ sub leave_res_phase0 {
my ($cmd, $res) = @_;
check_not_primary(@_);
foreach my $tmp (glob("$mars/resource-$res/todo-$host/*")) {
my $status = get_link($tmp);
my $status = get_link($tmp, 2);
ldie "switch '$tmp' is not off\n" if $status;
}
check_status($cmd, $res, "is-attached", 0, 0, 1);
@ -978,6 +979,13 @@ sub leave_res_phase1 {
_create_delete("$mars/resource-$res/data-$host");
_create_delete("$mars/resource-$res/syncstatus-$host");
_create_delete("$mars/resource-$res/device-$host");
_create_delete("$mars/resource-$res/actsize-$host");
foreach my $dir (glob("$mars/resource-$res/*-$host/")) {
foreach my $tmp (glob("${dir}*")) {
_create_delete($tmp);
}
_create_delete($dir);
}
cleanup_res($cmd, $res, 9999999999);
}