marsadm: fix check_primary/check_not_primary to use actual state ('is-primary')

The actual state is decoded in 'actual-*/is-primary' links, while the target
state is decoded in the 'primary' link.
- check_primary() now uses actual state
- check_not_primary() now uses both actual state and target state

Commits c38a822 94ac15a rebased on eaba743

Signed-off-by: Thomas Schoebel-Theuer <tst@1und1.de>
This commit is contained in:
Daniel Hermann 2013-04-03 16:00:50 +02:00 committed by Thomas Schoebel-Theuer
parent 24ad742db4
commit 5d3d777b86
1 changed files with 13 additions and 6 deletions

View File

@ -130,16 +130,23 @@ sub check_sync_finished {
sub check_primary {
my ($cmd, $res) = @_;
my $pri = "$mars/resource-$res/primary";
my $old = readlink($pri) or ldie "cannot determine primary\n";
ldie "for operation '$cmd' I need to be primary\n" unless $old eq $host;
my $lnk = "$mars/resource-$res/actual-$host/is-primary";
my $is_primary = readlink($lnk);
ldie "for operation '$cmd' I need to be primary\n" unless $is_primary;
}
sub check_not_primary {
my ($cmd, $res) = @_;
my $pri = "$mars/resource-$res/primary";
my $old = readlink($pri) or ldie "cannot determine primary\n";
ldie "operation '$cmd' cannot be executed on primary\n" if $old eq $host;
my $lnk = "$mars/resource-$res/actual-$host/is-primary";
my $is_primary = readlink($lnk);
if ($is_primary) {
ldie "operation '$cmd' cannot be executed on primary\n";
}
else { # also check whether we intend to become primary
$lnk = "$mars/resource-$res/primary";
my $primary = readlink($lnk) or ldie "cannot determine primary\n";
ldie "operation '$cmd' cannot be executed on designated primary\n";
}
}
sub check_primary_gone {