|
257 | 257 | import com.cloud.utils.db.SearchCriteria.Op;
|
258 | 258 | import com.cloud.utils.db.Transaction;
|
259 | 259 | import com.cloud.utils.db.TransactionCallbackNoReturn;
|
| 260 | +import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn; |
260 | 261 | import com.cloud.utils.db.TransactionLegacy;
|
261 | 262 | import com.cloud.utils.db.TransactionStatus;
|
262 | 263 | import com.cloud.utils.exception.CloudRuntimeException;
|
@@ -1591,22 +1592,27 @@ public void connectHostsToPool(DataStore primaryStore, List<Long> hostIds, Scope
|
1591 | 1592 | if (exceptionOccurred.get()) {
|
1592 | 1593 | return null;
|
1593 | 1594 | }
|
1594 |
| - HostVO host = _hostDao.findById(hostId); |
1595 |
| - try { |
1596 |
| - connectHostToSharedPool(host, primaryStore.getId()); |
1597 |
| - poolHostIds.add(hostId); |
1598 |
| - } catch (Exception e) { |
1599 |
| - if (handleExceptionsPartially && e.getCause() instanceof StorageConflictException) { |
1600 |
| - exceptionOccurred.set(true); |
1601 |
| - throw e; |
1602 |
| - } |
1603 |
| - logger.warn("Unable to establish a connection between {} and {}", host, primaryStore, e); |
1604 |
| - String reason = getStoragePoolMountFailureReason(e.getMessage()); |
1605 |
| - if (handleExceptionsPartially && reason != null) { |
1606 |
| - exceptionOccurred.set(true); |
1607 |
| - throw new CloudRuntimeException(reason); |
| 1595 | + Transaction.execute(new TransactionCallbackWithExceptionNoReturn<Exception>() { |
| 1596 | + @Override |
| 1597 | + public void doInTransactionWithoutResult(TransactionStatus status) throws Exception { |
| 1598 | + HostVO host = _hostDao.findById(hostId); |
| 1599 | + try { |
| 1600 | + connectHostToSharedPool(host, primaryStore.getId()); |
| 1601 | + poolHostIds.add(hostId); |
| 1602 | + } catch (Exception e) { |
| 1603 | + if (handleExceptionsPartially && e.getCause() instanceof StorageConflictException) { |
| 1604 | + exceptionOccurred.set(true); |
| 1605 | + throw e; |
| 1606 | + } |
| 1607 | + logger.warn("Unable to establish a connection between {} and {}", host, primaryStore, e); |
| 1608 | + String reason = getStoragePoolMountFailureReason(e.getMessage()); |
| 1609 | + if (handleExceptionsPartially && reason != null) { |
| 1610 | + exceptionOccurred.set(true); |
| 1611 | + throw new CloudRuntimeException(reason); |
| 1612 | + } |
| 1613 | + } |
1608 | 1614 | }
|
1609 |
| - } |
| 1615 | + }); |
1610 | 1616 | return null;
|
1611 | 1617 | }));
|
1612 | 1618 | }
|
|
0 commit comments