kvm: Add better logging when fetching a volume from libvirt

Clearly show if a volume is found and if not, that the pool is being refreshed
and the fetch is tried again.

Due to my commit b53a9dcc9f3ee95d40761b9c2c860f821595a661 the chance of a volume
not being found is slightly bigger, but the performance gain is enormous on 
larger
deployments.

This is why we clearly have to log that we are refreshing the pool information
when a volume is not found.

It could be that a volume is created on host A and a few seconds later host B 
tries
to access the volume. In that case host B's libvirt doesn't know about the 
volume
yet and has to refresh the pool before it does.

(cherry picked from commit 4ee82f1f40f6a384619323698d3f59e3cdda3c9c)


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

Branch: refs/heads/4.5
Commit: 3b65a5928b7c50ab5eef5789371df0acdb7a3463
Parents: da73d73
Author: Wido den Hollander <[email protected]>
Authored: Fri Oct 10 00:57:21 2014 +0200
Committer: David Nalley <[email protected]>
Committed: Mon Oct 13 00:37:54 2014 -0400

----------------------------------------------------------------------
 .../kvm/storage/LibvirtStorageAdaptor.java           | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3b65a592/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 26237ba..ea3e1d6 100644
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -94,21 +94,30 @@ public class LibvirtStorageAdaptor implements 
StorageAdaptor {
         try {
             vol = pool.storageVolLookupByName(volName);
         } catch (LibvirtException e) {
-            s_logger.debug("Can't find volume: " + e.toString());
+            s_logger.debug("Could not find volume " + volName + ": " + 
e.getMessage());
         }
+
+        /**
+         * The volume was not found in the storage pool
+         * This can happen when a volume has just been created on a different 
host and
+         * since then the libvirt storage pool has not been refreshed.
+         */
         if (vol == null) {
             try {
+                s_logger.debug("Refreshing storage pool " + pool.getName());
                 refreshPool(pool);
             } catch (LibvirtException e) {
-                s_logger.debug("failed to refresh pool: " + e.toString());
+                s_logger.debug("Failed to refresh storage pool: " + 
e.getMessage());
             }
 
             try {
                 vol = pool.storageVolLookupByName(volName);
+                s_logger.debug("Found volume " + volName + " in storage pool " 
+ pool.getName() + " after refreshing the pool");
             } catch (LibvirtException e) {
-                throw new CloudRuntimeException(e.toString());
+                throw new CloudRuntimeException("Could not find volume " + 
volName + ": " + e.getMessage());
             }
         }
+
         return vol;
     }
 

Reply via email to