]> git.proxmox.com Git - pve-manager.git/commitdiff
ocf agent: retry get_vmlist if we get an empty list
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 7 Jan 2014 09:41:04 +0000 (10:41 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 7 Jan 2014 09:41:04 +0000 (10:41 +0100)
Make HA more stable if pmxcfs is not reachable for a short period (for example
if you restart the service). Some users reported they get empty VM list
when there is very high load on a server.

bin/ocf/pvevm

index 79b8eb437a75f2096ad38fdae1678fe12c08419c..ab108caef5fda9e498eefccad96533c45f3f88f0 100755 (executable)
@@ -115,8 +115,20 @@ sub validate_all {
        die "no VMID specified\n" if !defined($vmid);
        die "got invalid VMID '$vmid'\n" if $vmid !~ m/^[1-9]\d*$/;
 
-       my $vmlist = PVE::Cluster::get_vmlist();
+       my $vmlist;
+        for (my $i = 0; $i < 10; $i++) {
+           $vmlist = PVE::Cluster::get_vmlist();
+           if (!$vmlist || !$vmlist->{ids}) {
+               warn "got empty cluster VM list - try again in 2 seconds\n";
+               sleep(2);
+               PVE::Cluster::cfs_update();
+           } else {
+               last;
+           }
+       }
+
        die "got empty cluster VM list\n" if !$vmlist || !$vmlist->{ids};
        my $data = $vmlist->{ids}->{$vmid};
        die "VM $vmid does not exist\n" if !$data;