mirror of https://github.com/schoebel/mars
marsadm: activate resource when device_exists fails
This commit is contained in:
parent
6b37c1300d
commit
87f9972d60
|
@ -287,7 +287,7 @@ sub device_name {
|
|||
}
|
||||
|
||||
sub device_exists {
|
||||
my ($res, $peer) = @_;
|
||||
my ($cmd, $res, $peer) = @_;
|
||||
$peer = $host unless defined($peer);
|
||||
return 0 if $peer eq "(none)";
|
||||
if ($peer eq $real_host) {
|
||||
|
@ -323,6 +323,9 @@ sub device_exists {
|
|||
$val = (-b $name) ? 1 : 0;
|
||||
} else {
|
||||
lwarn "Cannot determine device presence for $peer\n";
|
||||
if ($peer ne $real_host) {
|
||||
_activate_resource($cmd, $res, $peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $val;
|
||||
|
@ -1514,7 +1517,7 @@ sub set_systemd_want_phase2 {
|
|||
return $fail;
|
||||
}
|
||||
my $name = _device_name($res, $new);
|
||||
my $dev_present = device_exists($res, $new);
|
||||
my $dev_present = device_exists($cmd, $res, $new);
|
||||
if (!$dev_present) {
|
||||
lwarn "device '$name' is not present at '$new'\n";
|
||||
return 0;
|
||||
|
@ -1751,7 +1754,7 @@ sub __systemd_activate_want {
|
|||
}
|
||||
if ($do_activate) {
|
||||
# Check for device existence
|
||||
if (!device_exists($res, $want)) {
|
||||
if (!device_exists($cmd, $res, $want)) {
|
||||
my $name = device_name($res, $want);
|
||||
lprint "==== device '$name' is not preset at '$want'\n" if $verbose;
|
||||
$do_activate = 0;
|
||||
|
@ -3125,7 +3128,7 @@ sub check_primary {
|
|||
my $lnk = "$mars/resource-$res/actual-$host/is-primary";
|
||||
my $is_primary = get_link($lnk, 1);
|
||||
if (!$is_primary && todo_local($cmd, $res)) { # give it a second chance
|
||||
$is_primary = device_exists($res);
|
||||
$is_primary = device_exists($cmd, $res);
|
||||
}
|
||||
unless ($is_primary) {
|
||||
lwarn "For operation '$cmd' I need to be primary\n";
|
||||
|
@ -3324,7 +3327,7 @@ sub check_mars_device {
|
|||
my $backoff = 1;
|
||||
my $round = 0;
|
||||
if ($inv) {
|
||||
while (device_exists($res)) {
|
||||
while (device_exists($cmd, $res)) {
|
||||
ldie "cannot execute $cmd: device '$dev' has not yet disappeared\n" if !$wait;
|
||||
lwarn "device '$dev' has not yet disappeared\n";
|
||||
sleep_timeout($backoff);
|
||||
|
@ -3335,13 +3338,13 @@ sub check_mars_device {
|
|||
}
|
||||
systemd_any_trigger($cmd, $res);
|
||||
}
|
||||
lprint "device '$dev' is no longer present\n" unless device_exists($res);
|
||||
lprint "device '$dev' is no longer present\n" unless device_exists($cmd, $res);
|
||||
return;
|
||||
}
|
||||
# !$inv
|
||||
my $primary = _get_designated_primary($cmd, $res);
|
||||
ldie "for operation '$cmd', I should be the designated primary\n" unless $primary eq $host;
|
||||
while (!device_exists($res)) {
|
||||
while (!device_exists($cmd, $res)) {
|
||||
my $text = get_error_text($cmd, $res);
|
||||
lprint $text if $text;
|
||||
ldie "aborting due to errors\n" if $text =~ m/error/mi;
|
||||
|
@ -3354,7 +3357,7 @@ sub check_mars_device {
|
|||
$backoff++;
|
||||
}
|
||||
}
|
||||
lprint "device '$dev' is present\n" if device_exists($res);
|
||||
lprint "device '$dev' is present\n" if device_exists($cmd, $res);
|
||||
}
|
||||
|
||||
sub check_userspace {
|
||||
|
@ -4035,12 +4038,12 @@ sub get_size {
|
|||
# Get actual primary node from links below actual-*/ subdirs
|
||||
#
|
||||
sub _get_actual_primary {
|
||||
my ($res) = @_;
|
||||
my ($cmd, $res) = @_;
|
||||
# TST: Presence of local device takes precedence over anything else.
|
||||
# This tries to workaround the most important special case of
|
||||
# split-brain situations, but cannot fix the problem exhaustively.
|
||||
llog "DEPRECATED: you are trying to uniquely identify an actual primary hostname (as seen from host $host resource $res), but this is conceptually wrong because in split-brain situations there may exist multiple ones. Use view-is-primary instead. That would be safe.\n";
|
||||
return $host if device_exists($res);
|
||||
return $host if device_exists($cmd, $res);
|
||||
# The following old code is CONCEPTUALLY WRONG for split-brain situations (see NOTE above)
|
||||
my @primary_links = lamport_glob("$mars/resource-$res/actual-*/is-primary");
|
||||
my $primary;
|
||||
|
@ -4115,7 +4118,7 @@ sub get_actual_prosumers {
|
|||
my @peers = get_any_peers($res);
|
||||
my @result = ();
|
||||
foreach my $peer (@peers) {
|
||||
if (device_exists($res, $peer)) {
|
||||
if (device_exists($cmd, $res, $peer)) {
|
||||
push @result, $peer;
|
||||
}
|
||||
}
|
||||
|
@ -6760,7 +6763,7 @@ sub primary_phase0b {
|
|||
my $lnk = "$mars/resource-$res/new-primary";
|
||||
# at handover: check that any LocalProsumer is converted to a true Prosumer
|
||||
if (!$force && !$ignore_umount &&
|
||||
$old && $old ne "(none)" && device_exists($res, $old)) {
|
||||
$old && $old ne "(none)" && device_exists($cmd, $res, $old)) {
|
||||
my $val = get_link($lnk, 1);
|
||||
if ($val && $val ne "(none)" && $val eq $old) {
|
||||
my $lnk_on = "$mars/resource-$res/actual-$old/prosumer-on";
|
||||
|
@ -7544,7 +7547,7 @@ sub _check_prosumers_vanished {
|
|||
my ($cmd, $res, $minus_prosumers) = @_;
|
||||
my $errors = 0;
|
||||
foreach my $peer (split("\\+", $minus_prosumers)) {
|
||||
my $val = device_exists($res, $peer);
|
||||
my $val = device_exists($cmd, $res, $peer);
|
||||
if ($val) {
|
||||
lprint "Device at '$peer' has not vanished.\n";
|
||||
$errors++ unless $ignore_umount;
|
||||
|
@ -7648,7 +7651,7 @@ sub prosumer_phase6 {
|
|||
my $new_prosumers = $pros_new{$res};
|
||||
my $fail = 0;
|
||||
foreach my $peer (split("\\+", $new_prosumers)) {
|
||||
if (device_exists($res, $peer)) {
|
||||
if (device_exists($cmd, $res, $peer)) {
|
||||
lprint "Device '$dev' is present at '$peer'\n";
|
||||
next;
|
||||
}
|
||||
|
@ -8529,7 +8532,7 @@ sub eval_fn {
|
|||
my $primary;
|
||||
if ($op eq "actual") {
|
||||
lwarn "DEPRECATED: you are trying to uniquely identify an actual primary hostname, but this is conceptually wrong because in split-brain situations there may exist multiple ones. Use view-is-primary instead. That would be safe.\n" unless $$env{cmd} =~ m/-1and1$/;
|
||||
$primary = _get_actual_primary($$env{"res"});
|
||||
$primary = _get_actual_primary($$env{"cmd"}, $$env{"res"});
|
||||
} else {
|
||||
$primary = _get_designated_primary($$env{"cmd"}, $$env{"res"});
|
||||
}
|
||||
|
@ -8772,7 +8775,7 @@ sub eval_fn {
|
|||
return $result;
|
||||
}
|
||||
if (/^device[-_]?present$/) {
|
||||
my $result = device_exists($$env{"res"}, $$env{"host"});
|
||||
my $result = device_exists($$env{"cmd"}, $$env{"res"}, $$env{"host"});
|
||||
return $result;
|
||||
}
|
||||
if (/^device[-_]?detach$/) {
|
||||
|
|
Loading…
Reference in New Issue