marsadm: guard create-resource against distributed races

This commit is contained in:
Thomas Schoebel-Theuer 2022-04-02 19:26:14 +02:00
parent 88d7456c79
commit c52ad3ceb7
1 changed files with 8 additions and 0 deletions

View File

@ -5258,6 +5258,14 @@ sub create_res {
$appear = $res if !$appear;
check_id($appear, 0, 1) if $appear;
# guard against distributed races and/or uninitialized communication
my $nr_replicas = get_nr_replicas(@_);
if (!$create) {
update_cluster($cmd, "all", "*");
} elsif ($nr_replicas > 0) {
lwarn "are you sure to run '$cmd'? There are $nr_replicas known replicas at '$res'\n";
}
my $resdir = "$mars/resource-$res";
if ($create) {
if (-d $resdir) {