Skip to content

Commit a53365d

Browse files
committed
Merge release branch 4.18 to 4.19
* 4.18: Fix list backups after backup vm is expunged (#9392)
2 parents 21c98af + 8a00e25 commit a53365d

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupsCmd.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.cloudstack.backup.Backup;
3737
import org.apache.cloudstack.backup.BackupManager;
3838
import org.apache.cloudstack.context.CallContext;
39+
import org.apache.log4j.Logger;
3940

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

5355
@Inject
5456
private BackupManager backupManager;
@@ -116,6 +118,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
116118
Pair<List<Backup>, Integer> result = backupManager.listBackups(this);
117119
setupResponseBackupList(result.first(), result.second());
118120
} catch (Exception e) {
121+
s_logger.debug("Exception while listing backups", e);
119122
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
120123
}
121124
}

api/src/main/java/org/apache/cloudstack/backup/Backup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public String toString() {
134134
}
135135

136136
long getVmId();
137+
long getBackupOfferingId();
137138
String getExternalId();
138139
String getType();
139140
Date getDate();

engine/schema/src/main/java/org/apache/cloudstack/backup/BackupVO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public void setStatus(Status status) {
158158
this.status = status;
159159
}
160160

161+
@Override
161162
public long getBackupOfferingId() {
162163
return backupOfferingId;
163164
}

engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupDaoImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public BackupResponse newBackupResponse(Backup backup) {
145145
AccountVO account = accountDao.findByIdIncludingRemoved(vm.getAccountId());
146146
DomainVO domain = domainDao.findByIdIncludingRemoved(vm.getDomainId());
147147
DataCenterVO zone = dataCenterDao.findByIdIncludingRemoved(vm.getDataCenterId());
148-
BackupOffering offering = backupOfferingDao.findByIdIncludingRemoved(vm.getBackupOfferingId());
148+
Long offeringId = vm.getBackupOfferingId();
149+
if (offeringId == null) {
150+
offeringId = backup.getBackupOfferingId();
151+
}
152+
BackupOffering offering = backupOfferingDao.findByIdIncludingRemoved(offeringId);
149153

150154
BackupResponse response = new BackupResponse();
151155
response.setId(backup.getUuid());

0 commit comments

Comments
 (0)