You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/04/16 20:07:21 UTC

git commit: updated refs/heads/master to 202930f

Updated Branches:
  refs/heads/master 90e8158db -> 202930fd5


 CLOUDSTACK-2051 Allow KVM HA Monitor to verify that a NfsStoragePool is
valid before running the script that mounts it and touches the HA files.

Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1366135635 -0600


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/202930fd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/202930fd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/202930fd

Branch: refs/heads/master
Commit: 202930fd554ddc9a8e78cf39ae54a4e3a56d3904
Parents: 90e8158
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Tue Apr 16 12:07:15 2013 -0600
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Tue Apr 16 12:07:15 2013 -0600

----------------------------------------------------------------------
 .../hypervisor/kvm/resource/KVMHAMonitor.java      |   51 ++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/202930fd/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
index c4e121b..d1470d6 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
@@ -23,6 +23,15 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.log4j.Logger;
 import com.cloud.utils.script.Script;
 
+import org.libvirt.Connect;
+import org.libvirt.LibvirtException;
+import org.libvirt.Secret;
+import org.libvirt.StoragePool;
+import org.libvirt.StoragePoolInfo;
+import org.libvirt.StoragePoolInfo.StoragePoolState;
+
+import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
+
 public class KVMHAMonitor extends KVMHABase implements Runnable {
     private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
     private Map<String, NfsStoragePool> _storagePool = new ConcurrentHashMap<String, NfsStoragePool>();
@@ -45,6 +54,9 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
 
     public void removeStoragePool(String uuid) {
         synchronized (_storagePool) {
+            NfsStoragePool pool = this._storagePool.get(uuid);
+            Script.runSimpleBashScript("umount " + pool._mountDestPath);
+            s_logger.debug("attempted to umount '" + pool._mountDestPath + "'");
             this._storagePool.remove(uuid);
         }
     }
@@ -60,7 +72,44 @@ public class KVMHAMonitor extends KVMHABase implements Runnable {
         @Override
         public void run() {
             synchronized (_storagePool) {
-                for (NfsStoragePool primaryStoragePool : _storagePool.values()) {
+                for (String uuid : _storagePool.keySet()) {
+                    NfsStoragePool primaryStoragePool = _storagePool.get(uuid);
+
+                    // check for any that have been deregistered with libvirt and
+                    // skip,remove them
+
+                    StoragePool storage = null;
+                    try {
+                        Connect conn = LibvirtConnection.getConnection();
+                        storage = conn.storagePoolLookupByUUIDString(uuid);
+                        if (storage == null) {
+                            s_logger.debug("Libvirt storage pool " + uuid
+                                           +" not found, removing from HA list");
+                            removeStoragePool(uuid);
+                            continue;
+
+                        } else if (storage.getInfo().state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
+                            s_logger.debug("Libvirt storage pool " + uuid
+                                           +" found, but not running, removing from HA list");
+                            
+                            removeStoragePool(uuid);
+                            continue;
+                        }
+                        s_logger.debug("Found NFS storage pool " + uuid + " in libvirt, continuing");
+
+                    } catch (LibvirtException e) {
+                        s_logger.debug("Failed to lookup libvirt storage pool " + uuid
+                                       + " due to: " + e );
+
+                        // we only want to remove pool if it's not found, not if libvirt
+                        // connection fails
+                        if (e.toString().contains("pool not found")) {
+                            s_logger.debug("removing pool from HA monitor since it was deleted");
+                            removeStoragePool(uuid);
+                            continue;
+                        }
+                    }
+
                     String result = null;
                     for (int i = 0; i < 5; i++) {
                         Script cmd = new Script(_heartBeatPath,