cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [2/3] git commit: updated refs/heads/4.1.1-sbp to 45b691a
Date Mon, 01 Jul 2013 11:49:04 GMT
Improve tracelogging and exception handling in CitrixResourceBase.

Custom fix for SBP

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

Branch: refs/heads/4.1.1-sbp
Commit: 5702b9b6fd85c43d148e57a2a0fcbc552728d93a
Parents: 8f70981
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Mon Jul 1 13:47:38 2013 +0200
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Mon Jul 1 13:47:38 2013 +0200

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java        | 162 +++++++++++++------
 1 file changed, 110 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5702b9b6/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 2a0b6d2..f0ca691 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -680,8 +680,12 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 _host.vswitchNetwork = vswitchNw;
             }
             return _host.vswitchNetwork;
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (BadServerResponse e) {
+            s_logger.error("Failure in setupvSwitchNetwork", e);
+        } catch (XenAPIException e) {
+            s_logger.error("Failure in setupvSwitchNetwork", e);
+        } catch (XmlRpcException e) {
+            s_logger.error("Failure in setupvSwitchNetwork", e);
         }
 
         return null;
@@ -2493,14 +2497,11 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
                 try {
                     host_uuid = host.getUuid(conn);
                 } catch (BadServerResponse e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
+                    s_logger.error("Failure when calling getUuid on host", e);
                 } catch (XenAPIException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
+                    s_logger.error("Failure when calling getUuid on host", e);
                 } catch (XmlRpcException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
+                    s_logger.error("Failure when calling getUuid on host", e);
                 }
                 vmStates.put(record.nameLabel, new Pair<String, State>(host_uuid, state));
             }
@@ -2585,7 +2586,13 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             s_logger.debug("4. The VM " +  vm.getName() + " is in Migrating state");
 
             return new PrepareForMigrationAnswer(cmd);
-        } catch (Exception e) {
+        } catch (BadServerResponse e) {
+            s_logger.warn("Catch Exception " + e.getClass().getName() + " prepare for migration
failed due to " + e.toString(), e);
+            return new PrepareForMigrationAnswer(cmd, e);
+        } catch (XenAPIException e) {
+            s_logger.warn("Catch Exception " + e.getClass().getName() + " prepare for migration
failed due to " + e.toString(), e);
+            return new PrepareForMigrationAnswer(cmd, e);
+        } catch (XmlRpcException e) {
             s_logger.warn("Catch Exception " + e.getClass().getName() + " prepare for migration
failed due to " + e.toString(), e);
             return new PrepareForMigrationAnswer(cmd, e);
         }
@@ -2677,9 +2684,11 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
                 try {
                     vdi.destroy(conn);
                 } catch (Exception e) {
+                    s_logger.warn("Ignoring exception in vdi.detroy", e);
                 }
             }
         } catch (Exception e){
+            s_logger.warn("Ignoring exception in vdi.detroy", e);
         }
     }
 
@@ -2738,14 +2747,27 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             poolsr.scan(conn);
             try{
                 Thread.sleep(5000);
-            } catch (Exception e) {
+            } catch (InterruptedException e) {
             }
             return new PrimaryStorageDownloadAnswer(snapshotvdi.getUuid(conn), phySize);
-        } catch (Exception e) {
+        } catch (BadServerResponse e) {
             String msg = "Catch Exception " + e.getClass().getName() + " on host:" + _host.uuid
+ " for template: "
-                    + tmplturl + " due to " + e.toString();
+                    + tmplturl;
             s_logger.warn(msg, e);
             return new PrimaryStorageDownloadAnswer(msg);
+        } catch (XenAPIException e) {
+            String msg = "Catch Exception " + e.getClass().getName() + " on host:" + _host.uuid
+ " for template: "
+                    + tmplturl;
+            s_logger.warn(msg, e);
+            return new PrimaryStorageDownloadAnswer(msg);
+        } catch (XmlRpcException e) {
+            String msg = "Catch Exception " + e.getClass().getName() + " on host:" + _host.uuid
+ " for template: "
+                    + tmplturl;
+            s_logger.warn(msg, e);
+            return new PrimaryStorageDownloadAnswer(msg);
+        } catch (URISyntaxException e1) {
+            s_logger.error("Failed to parse template uri: " + tmplturl, e1);
+            return new PrimaryStorageDownloadAnswer("Failed to parse template uri : " + e1.getMessage());
         }
     }
 
@@ -2882,7 +2904,15 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
                 state = State.Stopping;
             }
             return new MigrateAnswer(cmd, true, "migration succeeded", null);
-        } catch (Exception e) {
+        } catch (BadServerResponse e) {
+            String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed
due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new MigrateAnswer(cmd, false, msg, null);
+        } catch (XenAPIException e) {
+            String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed
due to " + e.toString();
+            s_logger.warn(msg, e);
+            return new MigrateAnswer(cmd, false, msg, null);
+        } catch (XmlRpcException e) {
             String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed
due to " + e.toString();
             s_logger.warn(msg, e);
             return new MigrateAnswer(cmd, false, msg, null);
@@ -2957,7 +2987,12 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             for ( VM vm : vms ) {
                 destroyPatchVbd(conn, vm.getNameLabel(conn));
             }
-        } catch (Exception e) {
+        } catch (BadServerResponse e) {
+            s_logger.warn("Ignoring exception during execution of ReadyCommand", e);
+        } catch (XenAPIException e) {
+            s_logger.warn("Ignoring exception during execution of ReadyCommand", e);
+        } catch (XmlRpcException e) {
+            s_logger.warn("Ignoring exception during execution of ReadyCommand", e);
         }
         try {
             boolean result = cleanupHaltedVms(conn);
@@ -3057,11 +3092,11 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             try {
                 vms = VM.getByNameLabel(conn, cmd.getVmName());
             } catch (XenAPIException e0) {
-                s_logger.debug("getByNameLabel failed " + e0.toString());
+                s_logger.error("getByNameLabel failed " + e0.toString(), e0);
                 return new RebootAnswer(cmd, "getByNameLabel failed " + e0.toString(), false);
-            } catch (Exception e0) {
-                s_logger.debug("getByNameLabel failed " + e0.getMessage());
-                return new RebootAnswer(cmd, "getByNameLabel failed", false);
+            } catch (XmlRpcException e) {
+                s_logger.error("getByNameLabel failed " + e.toString(), e);
+                return new RebootAnswer(cmd, "getByNameLabel failed " + e.toString(), false);
             }
             for (VM vm : vms) {
                 try {
@@ -3153,8 +3188,16 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
     private void waitForTask(Connection c, Task task, long pollInterval, long timeout) throws
XenAPIException, XmlRpcException {
         long beginTime = System.currentTimeMillis();
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("Task " + task.getNameLabel(c) + " (" + task.getUuid(c) + ") sent
to " + c.getSessionReference()
+                    + " is pending completion with a " + timeout + "ms timeout");
+        }
         while (task.getStatus(c) == Types.TaskStatusType.PENDING) {
             try {
+                if (s_logger.isTraceEnabled()) {
+                    s_logger.trace("Task " + task.getNameLabel(c) + " (" + task.getUuid(c)
+ ") is pending, sleeping for "
+                            + pollInterval + "ms");
+                }
                 Thread.sleep(pollInterval);
             } catch (InterruptedException e) {
             }
@@ -3169,6 +3212,9 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
     private void checkForSuccess(Connection c, Task task) throws XenAPIException, XmlRpcException
{
         if (task.getStatus(c) == Types.TaskStatusType.SUCCESS) {
+            if (s_logger.isTraceEnabled()) {
+                s_logger.trace("Task " + task.getNameLabel(c) + " (" + task.getUuid(c) +
") completed");
+            }
             return;
         } else {
             String msg = "Task failed! Task record: " + task.getRecord(c);
@@ -3178,6 +3224,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         }
     }
 
+
     void rebootVM(Connection conn, VM vm, String vmName) throws XmlRpcException {
         Task task = null;
         try {
@@ -5214,39 +5261,37 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             } else {
                 return new Answer(cmd, false, result);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (BadServerResponse e) {
+            s_logger.error("Failure during execution of OvsDeleteFlowCommand", e);
+        } catch (XenAPIException e) {
+            s_logger.error("Failure during execution of OvsDeleteFlowCommand", e);
+        } catch (XmlRpcException e) {
+            s_logger.error("Failure during execution of OvsDeleteFlowCommand", e);
         }
         return new Answer(cmd, false, "failed to delete flow for " + cmd.getVmName());
     }
 
     private List<Pair<String, Long>> ovsFullSyncStates() {
         Connection conn = getConnection();
-        try {
-            String result = callHostPlugin(conn, "ovsgre", "ovs_get_vm_log", "host_uuid",
_host.uuid);
-            String [] logs = result != null ?result.split(";"): new String [0];
-            List<Pair<String, Long>> states = new ArrayList<Pair<String,
Long>>();
-            for (String log: logs){
-                String [] info = log.split(",");
-                if (info.length != 5) {
-                    s_logger.warn("Wrong element number in ovs log(" + log +")");
-                    continue;
-                }
-
-                //','.join([bridge, vmName, vmId, seqno, tag])
-                try {
-                    states.add(new Pair<String,Long>(info[0], Long.parseLong(info[3])));
-                } catch (NumberFormatException nfe) {
-                    states.add(new Pair<String,Long>(info[0], -1L));
-                }
+        String result = callHostPlugin(conn, "ovsgre", "ovs_get_vm_log", "host_uuid", _host.uuid);
+        String [] logs = result != null ?result.split(";"): new String [0];
+        List<Pair<String, Long>> states = new ArrayList<Pair<String, Long>>();
+        for (String log: logs){
+            String [] info = log.split(",");
+            if (info.length != 5) {
+                s_logger.warn("Wrong element number in ovs log(" + log +")");
+                continue;
             }
 
-            return states;
-        } catch (Exception e) {
-            e.printStackTrace();
+            //','.join([bridge, vmName, vmId, seqno, tag])
+            try {
+                states.add(new Pair<String,Long>(info[0], Long.parseLong(info[3])));
+            } catch (NumberFormatException nfe) {
+                states.add(new Pair<String,Long>(info[0], -1L));
+            }
         }
 
-        return null;
+        return states;
     }
 
     private OvsSetTagAndFlowAnswer execute(OvsSetTagAndFlowCommand cmd) {
@@ -5271,8 +5316,12 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             } else {
                 return new OvsSetTagAndFlowAnswer(cmd, false, result);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (BadServerResponse e) {
+            s_logger.error("Failure during execution of OvsSetTagAndFlowCommand", e);
+        } catch (XenAPIException e) {
+            s_logger.error("Failure during execution of OvsSetTagAndFlowCommand", e);
+        } catch (XmlRpcException e) {
+            s_logger.error("Failure during execution of OvsSetTagAndFlowCommand", e);
         }
 
         return new OvsSetTagAndFlowAnswer(cmd, false, "EXCEPTION");
@@ -5292,11 +5341,17 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             s_logger.debug("PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
             return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + pifRec.device +
" retrieved successfully", 
                     pifRec.IP, pifRec.netmask, pifRec.MAC);
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (BadServerResponse e) {
+            s_logger.error("An error occurred while fetching the interface for " +
+                    label + " on host " + _host.ip, e);
+            return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage());
+        } catch (XenAPIException e) {
             s_logger.error("An error occurred while fetching the interface for " +
-                    label + " on host " + _host.ip + ":" + e.toString() + 
-                    "(" + e.getClass() + ")");
+                    label + " on host " + _host.ip, e);
+            return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage());
+        } catch (XmlRpcException e) {
+            s_logger.error("An error occurred while fetching the interface for " +
+                    label + " on host " + _host.ip, e);
             return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage());
         }
     }
@@ -5321,12 +5376,15 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
             } else {
                 return new OvsCreateGreTunnelAnswer(cmd, true, result, _host.ip, bridge,
Integer.parseInt(res[1]));
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (BadServerResponse e) {
             s_logger.error("An error occurred while creating a GRE tunnel to " +
-                    cmd.getRemoteIp() + " on host " + _host.ip + ":" + e.getMessage() + 
-                    "(" + e.getClass() + ")");
-
+                    cmd.getRemoteIp() + " on host " + _host.ip, e);
+        } catch (XenAPIException e) {
+            s_logger.error("An error occurred while creating a GRE tunnel to " +
+                    cmd.getRemoteIp() + " on host " + _host.ip, e);
+        } catch (XmlRpcException e) {
+            s_logger.error("An error occurred while creating a GRE tunnel to " +
+                    cmd.getRemoteIp() + " on host " + _host.ip, e);
         }
 
         return new OvsCreateGreTunnelAnswer(cmd, false, "EXCEPTION", _host.ip, bridge);


Mime
View raw message