Skip to content

Commit e942df9

Browse files
Deepti Doharechipchilders
authored andcommitted
CLOUDSTACK-1541 NPE while deleting snapshots
1 parent 06e7fc1 commit e942df9

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.cloud.agent.api.LogLevel.Log4jLevel;
2020
import com.cloud.agent.api.to.S3TO;
2121
import com.cloud.agent.api.to.SwiftTO;
22+
import com.cloud.storage.StoragePool;
2223

2324
/**
2425
* This command encapsulates a primitive operation which enables coalescing the backed up VHD snapshots on the secondary server
@@ -78,15 +79,16 @@ protected DeleteSnapshotBackupCommand() {
7879
* @param backupUUID The VHD which has to be deleted
7980
* @param childUUID The child VHD file of the backup whose parent is reset to its grandparent.
8081
*/
81-
public DeleteSnapshotBackupCommand(SwiftTO swift,
82+
public DeleteSnapshotBackupCommand(StoragePool pool,
83+
SwiftTO swift,
8284
S3TO s3,
8385
String secondaryStoragePoolURL,
8486
Long dcId,
8587
Long accountId,
8688
Long volumeId,
8789
String backupUUID, Boolean all)
8890
{
89-
super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
91+
super(pool, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
9092
setSwift(swift);
9193
this.s3 = s3;
9294
setAll(all);

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,13 @@ private static void checkObjectStorageConfiguration(SwiftTO swift, S3TO s3) {
482482
public void deleteSnapshotsForVolume (String secondaryStoragePoolUrl, Long dcId, Long accountId, Long volumeId ){
483483
SwiftTO swift = _swiftMgr.getSwiftTO();
484484
S3TO s3 = _s3Mgr.getS3TO();
485+
VolumeVO volume = _volumeDao.findById(volumeId);
486+
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
485487

486488
checkObjectStorageConfiguration(swift, s3);
487489

488490
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
489-
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
491+
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
490492
null, true);
491493
try {
492494
Answer ans = _agentMgr.sendToSSVM(dcId, cmd);
@@ -909,8 +911,11 @@ public boolean destroySnapshotBackUp(long snapshotId) {
909911

910912
checkObjectStorageConfiguration(swift, s3);
911913

914+
VolumeVO volume = _volumeDao.findById(volumeId);
915+
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
916+
912917
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
913-
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
918+
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
914919
backupOfSnapshot, false);
915920
Answer answer = _agentMgr.sendToSSVM(dcId, cmd);
916921

@@ -1062,10 +1067,12 @@ public boolean deleteSnapshotDirsForAccount(long accountId) {
10621067

10631068
checkObjectStorageConfiguration(swift, s3);
10641069

1070+
StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId());
1071+
10651072
if (swift == null && s3 == null) {
10661073
for (HostVO ssHost : ssHosts) {
10671074
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
1068-
null, null, ssHost.getStorageUrl(), dcId,
1075+
pool, null, null, ssHost.getStorageUrl(), dcId,
10691076
accountId, volumeId, "", true);
10701077
Answer answer = null;
10711078
try {
@@ -1084,7 +1091,7 @@ public boolean deleteSnapshotDirsForAccount(long accountId) {
10841091
}
10851092
} else {
10861093
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
1087-
swift, s3, "", dcId, accountId, volumeId, "", true);
1094+
pool, swift, s3, "", dcId, accountId, volumeId, "", true);
10881095
Answer answer = null;
10891096
try {
10901097
answer = _agentMgr.sendToSSVM(dcId, cmd);

0 commit comments

Comments
 (0)