Skip to content

Commit c031eb7

Browse files
Ding YuanDaanHoogland
authored andcommitted
CLOUDSTACK-6242: exception handling improvements
Signed-off-by: Daan Hoogland <daan@onecht.net>
1 parent 498cf61 commit c031eb7

21 files changed

Lines changed: 69 additions & 25 deletions

File tree

engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ protected boolean handleDisconnectWithInvestigation(AgentAttache attache, Status
802802
* Why this can happen? Ask God not me. I hate there was no piece of comment for code handling race condition.
803803
* God knew what race condition the code dealt with!
804804
*/
805+
s_logger.debug("Caught exception while getting agent's next status", ne);
805806
}
806807

807808
if (nextStatus == Status.Alert) {

engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import com.cloud.cluster.dao.ManagementServerHostDao;
8080
import com.cloud.exception.AgentUnavailableException;
8181
import com.cloud.exception.OperationTimedoutException;
82+
import com.cloud.exception.UnsupportedVersionException;
8283
import com.cloud.host.Host;
8384
import com.cloud.host.HostVO;
8485
import com.cloud.host.Status;
@@ -412,7 +413,9 @@ public boolean routeToPeer(String peer, byte[] bytes) {
412413
if (ch == null) {
413414
try {
414415
logD(bytes, "Unable to route to peer: " + Request.parse(bytes).toString());
415-
} catch (Exception e) {
416+
} catch (ClassNotFoundException | UnsupportedVersionException e) {
417+
// Request.parse thrown exception when we try to log it, log as much as we can
418+
logD(bytes, "Unable to route to peer, and Request.parse further caught exception" + e.getMessage());
416419
}
417420
return false;
418421
}
@@ -430,7 +433,10 @@ public boolean routeToPeer(String peer, byte[] bytes) {
430433
} catch (IOException e) {
431434
try {
432435
logI(bytes, "Unable to route to peer: " + Request.parse(bytes).toString() + " due to " + e.getMessage());
433-
} catch (Exception ex) {
436+
} catch (ClassNotFoundException | UnsupportedVersionException ex) {
437+
// Request.parse thrown exception when we try to log it, log as much as we can
438+
logI(bytes, "Unable to route to peer due to" + e.getMessage()
439+
+ ". Also caught exception when parsing request: " + ex.getMessage());
434440
}
435441
}
436442
}

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ protected void migrate(VMInstanceVO vm, long srcHostId, DeployDestination dest)
19301930
throw new CloudRuntimeException("Unable to complete migration for " + vm);
19311931
}
19321932
} catch (OperationTimedoutException e) {
1933+
s_logger.debug("Error while checking the vm " + vm + " on host " + dstHostId, e);
19331934
}
19341935

19351936
migrated = true;
@@ -3898,6 +3899,7 @@ private void orchestrateMigrateForScale(String vmUuid, long srcHostId, DeployDes
38983899
throw new CloudRuntimeException("Unable to complete migration for " + vm);
38993900
}
39003901
} catch (OperationTimedoutException e) {
3902+
s_logger.debug("Error while checking the vm " + vm + " on host " + dstHostId, e);
39013903
}
39023904

39033905
migrated = true;

engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineDataCenterDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public EngineDataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
270270
Long dcId = Long.parseLong(tokenOrIdOrName);
271271
return findById(dcId);
272272
} catch (NumberFormatException nfe) {
273-
273+
s_logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe);
274274
}
275275
}
276276
}

engine/schema/src/com/cloud/dc/dao/DataCenterDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public DataCenterVO findByTokenOrIdOrName(String tokenOrIdOrName) {
411411
Long dcId = Long.parseLong(tokenOrIdOrName);
412412
return findById(dcId);
413413
} catch (NumberFormatException nfe) {
414-
414+
s_logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe);
415415
}
416416
}
417417
}

engine/schema/src/com/cloud/host/dao/HostDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ public List<RunningHostCountInfo> getRunningHostCounts(Date cutTime) {
871871
l.add(info);
872872
}
873873
} catch (SQLException e) {
874-
} catch (Throwable e) {
874+
s_logger.debug("SQLException caught", e);
875875
}
876876
return l;
877877
}

engine/schema/src/com/cloud/storage/dao/StoragePoolHostDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boo
151151
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
152152
}
153153
} catch (SQLException e) {
154-
} catch (Throwable e) {
154+
s_logger.debug("SQLException: ", e);
155155
}
156156
return l;
157157
}

engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public List<Long> listPrivateTemplatesByHost(Long hostId) {
232232
l.add(rs.getLong(1));
233233
}
234234
} catch (SQLException e) {
235-
} catch (Throwable e) {
235+
s_logger.debug("Exception: ", e);
236236
}
237237
return l;
238238
}

engine/schema/src/com/cloud/upgrade/dao/Upgrade2214to30.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,9 @@ protected void switchAccountSpecificNetworksToIsolated(Connection conn) {
986986
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`networks` DROP COLUMN `switch_to_isolated`");
987987
pstmt2Close.add(pstmt);
988988
pstmt.executeUpdate();
989-
} catch (Exception ex) {
989+
} catch (SQLException ex) {
990990
// do nothing here
991+
s_logger.debug("Caught SQLException when trying to drop switch_to_isolated column ", ex);
991992
}
992993

993994
} catch (SQLException e) {

engine/schema/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public List<Pair<Long, Integer>> getProxyLoadMatrix() {
217217
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
218218
}
219219
} catch (SQLException e) {
220-
} catch (Throwable e) {
220+
s_logger.debug("Caught SQLException: ", e);
221221
}
222222
return l;
223223
}
@@ -242,7 +242,7 @@ public List<Pair<Long, Integer>> getDatacenterStoragePoolHostInfo(long dcId, boo
242242
l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2)));
243243
}
244244
} catch (SQLException e) {
245-
} catch (Throwable e) {
245+
s_logger.debug("Caught SQLException: ", e);
246246
}
247247
return l;
248248
}
@@ -261,7 +261,7 @@ public int getProxyStaticLoad(long proxyVmId) {
261261
return rs.getInt(1);
262262
}
263263
} catch (SQLException e) {
264-
} catch (Throwable e) {
264+
s_logger.debug("Caught SQLException: ", e);
265265
}
266266
return 0;
267267
}
@@ -279,7 +279,7 @@ public int getProxyActiveLoad(long proxyVmId) {
279279
return rs.getInt(1);
280280
}
281281
} catch (SQLException e) {
282-
} catch (Throwable e) {
282+
s_logger.debug("Caught SQLException: ", e);
283283
}
284284
return 0;
285285
}
@@ -301,7 +301,7 @@ private List<ConsoleProxyLoadInfo> getDatacenterLoadMatrix(String sql) {
301301
l.add(info);
302302
}
303303
} catch (SQLException e) {
304-
} catch (Throwable e) {
304+
s_logger.debug("Exception: ", e);
305305
}
306306
return l;
307307
}
@@ -323,7 +323,7 @@ public List<Long> getRunningProxyListByMsid(long msid) {
323323
l.add(rs.getLong(1));
324324
}
325325
} catch (SQLException e) {
326-
} catch (Throwable e) {
326+
s_logger.debug("Caught SQLException: ", e);
327327
}
328328
return l;
329329
}

0 commit comments

Comments
 (0)