Skip to content

Commit 35e2640

Browse files
committed
bug 10674: For recurring snapshots when there is quota hit log it and send an email alert.
Reviewed by : Kishan.
1 parent b30ae76 commit 35e2640

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

core/src/com/cloud/alert/AlertManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public interface AlertManager extends Manager {
4848
public static final short ALERT_TYPE_USAGE_SANITY_RESULT = 22;
4949
public static final short ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 23;
5050
public static final short ALERT_TYPE_LOCAL_STORAGE = 24;
51+
public static final short ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = 25; // Generated when the resource limit exceeds the limit. Currently used for recurring snapshots only
5152

5253

5354
void clearAlert(short alertType, long dataCenterId, long podId);

server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.cloud.agent.api.ManageSnapshotCommand;
4141
import com.cloud.agent.api.downloadSnapshotFromSwiftCommand;
4242
import com.cloud.agent.api.to.SwiftTO;
43+
import com.cloud.alert.AlertManager;
4344
import com.cloud.api.commands.CreateSnapshotPolicyCmd;
4445
import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
4546
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
@@ -167,6 +168,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
167168
@Inject
168169
protected AccountManager _accountMgr;
169170
@Inject
171+
private AlertManager _alertMgr;
172+
@Inject
170173
protected ClusterDao _clusterDao;
171174
@Inject
172175
private UsageEventDao _usageEventDao;
@@ -1401,9 +1404,19 @@ public SnapshotVO allocSnapshot(Long volumeId, Long policyId) throws ResourceAll
14011404

14021405
// Verify permissions
14031406
_accountMgr.checkAccess(caller, null, volume);
1404-
1407+
Type snapshotType = getSnapshotType(policyId);
14051408
Account owner = _accountMgr.getAccount(volume.getAccountId());
1406-
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.snapshot);
1409+
try{
1410+
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.snapshot);
1411+
} catch (ResourceAllocationException e){
1412+
if (snapshotType == Type.RECURRING){
1413+
String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots";
1414+
s_logger.warn(msg);
1415+
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, msg,
1416+
"Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots; please use updateResourceLimit to increase the limit");
1417+
}
1418+
throw e;
1419+
}
14071420

14081421
// Determine the name for this snapshot
14091422
// Snapshot Name: VMInstancename + volumeName + timeString
@@ -1417,8 +1430,7 @@ public SnapshotVO allocSnapshot(Long volumeId, Long policyId) throws ResourceAll
14171430
String snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString;
14181431

14191432
// Create the Snapshot object and save it so we can return it to the
1420-
// user
1421-
Type snapshotType = getSnapshotType(policyId);
1433+
// user
14221434
HypervisorType hypervisorType = this._volsDao.getHypervisorType(volumeId);
14231435
SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), null, snapshotName,
14241436
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType);

0 commit comments

Comments
 (0)