marsadm: safeguard {create,join}-resource against old remains

This commit is contained in:
Thomas Schoebel-Theuer 2015-08-03 15:48:31 +02:00
parent 3e92223e47
commit 58294defe5
1 changed files with 14 additions and 0 deletions

View File

@ -1591,6 +1591,20 @@ sub create_res {
}
}
# check for remains from former incidents
foreach my $remain (glob("$resdir/{log,version}-*-$host")) {
if (!$create) {
$remain =~ m/-([0-9]+)-$host/;
my $nr = $1;
next if $nr < $replay_nr;
}
lwarn "Resource directory has some old remains like '$remain'.\n";
lwarn "First cleanup.\n";
my $extra_op = $create ? "delete-resource" : "log-purge-all";
lwarn "If you really want to $cmd, run 'marsadm $extra_op' first.\n";
ldie "REFUSING $cmd\n" unless $force;
}
my $file = "$resdir/data-$host";
if (!$dev) {
lwarn "file '$file' already exists - reusing\n" if -l $file;