Skip to content

Commit

Permalink
Fix list backups after backup vm is expunged (apache#9392)
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshanaparti authored Jul 15, 2024
1 parent 877c4d9 commit 8a00e25
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.cloudstack.backup.Backup;
import org.apache.cloudstack.backup.BackupManager;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
Expand All @@ -49,6 +50,7 @@
responseObject = BackupResponse.class, since = "4.14.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ListBackupsCmd extends BaseListProjectAndAccountResourcesCmd {
private static final Logger s_logger = Logger.getLogger(ListBackupsCmd.class);

@Inject
private BackupManager backupManager;
Expand Down Expand Up @@ -116,6 +118,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
Pair<List<Backup>, Integer> result = backupManager.listBackups(this);
setupResponseBackupList(result.first(), result.second());
} catch (Exception e) {
s_logger.debug("Exception while listing backups", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/org/apache/cloudstack/backup/Backup.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public String toString() {
}

long getVmId();
long getBackupOfferingId();
String getExternalId();
String getType();
String getDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void setStatus(Status status) {
this.status = status;
}

@Override
public long getBackupOfferingId() {
return backupOfferingId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ public BackupResponse newBackupResponse(Backup backup) {
AccountVO account = accountDao.findByIdIncludingRemoved(vm.getAccountId());
DomainVO domain = domainDao.findByIdIncludingRemoved(vm.getDomainId());
DataCenterVO zone = dataCenterDao.findByIdIncludingRemoved(vm.getDataCenterId());
BackupOffering offering = backupOfferingDao.findByIdIncludingRemoved(vm.getBackupOfferingId());
Long offeringId = vm.getBackupOfferingId();
if (offeringId == null) {
offeringId = backup.getBackupOfferingId();
}
BackupOffering offering = backupOfferingDao.findByIdIncludingRemoved(offeringId);

BackupResponse response = new BackupResponse();
response.setId(backup.getUuid());
Expand Down

0 comments on commit 8a00e25

Please sign in to comment.