diff --git a/userspace/marsadm b/userspace/marsadm index 6d2ced42..6eb449c8 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -159,6 +159,9 @@ sub check_primary { 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; + $lnk = "$mars/resource-$res/primary"; + my $primary = readlink($lnk) or ldie "cannot determine primary\n"; + ldie "for operation '$cmd', I also must be the designated primary\n" unless $primary eq $host; } sub check_not_primary { @@ -168,11 +171,10 @@ sub check_not_primary { 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"; - } + # 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" if $primary eq $host; } sub check_primary_gone {