Skip to content

Commit 07c3dc8

Browse files
winterhazelDaan Hoogland
authored andcommitted
[22.0] Consider infinite resources when calculating secondary storage limit for upload operations
1 parent d722415 commit 07c3dc8

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

core/src/main/java/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
package org.apache.cloudstack.storage.command;
2121

22+
import com.cloud.configuration.Resource;
23+
import org.apache.cloudstack.utils.bytescale.ByteScaleUtils;
24+
2225
public class TemplateOrVolumePostUploadCommand {
2326

2427
long entityId;
@@ -185,6 +188,11 @@ public void setDescription(String description) {
185188
this.description = description;
186189
}
187190

191+
public void setDefaultMaxSecondaryStorageInBytes(long defaultMaxSecondaryStorageInBytes) {
192+
this.defaultMaxSecondaryStorageInGB = defaultMaxSecondaryStorageInBytes != Resource.RESOURCE_UNLIMITED ?
193+
ByteScaleUtils.bytesToGibibytes(defaultMaxSecondaryStorageInBytes) : Resource.RESOURCE_UNLIMITED;
194+
}
195+
188196
public void setDefaultMaxSecondaryStorageInGB(long defaultMaxSecondaryStorageInGB) {
189197
this.defaultMaxSecondaryStorageInGB = defaultMaxSecondaryStorageInGB;
190198
}

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,9 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
542542
Account account = _accountDao.findById(accountId);
543543
Domain domain = domainDao.findById(account.getDomainId());
544544

545+
// one of the two following might have to be removed
545546
command.setDefaultMaxSecondaryStorageInGB(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null));
547+
command.setDefaultMaxSecondaryStorageInBytes(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null));
546548
command.setAccountId(accountId);
547549
Gson gson = new GsonBuilder().create();
548550
String metadata = EncryptionUtil.encodeData(gson.toJson(command), key);

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,9 @@ public boolean delete(TemplateProfile profile) {
500500
boolean dataDiskDeletetionResult = true;
501501
List<VMTemplateVO> dataDiskTemplates = templateDao.listByParentTemplatetId(template.getId());
502502
if (CollectionUtils.isNotEmpty(dataDiskTemplates)) {
503-
logger.info("Template: {} has Datadisk template(s) associated with it. Delete Datadisk templates before deleting the template", template);
503+
logger.info("Template: {} has Datadisk template(s) associated with it. Delete Datadisk Templates before deleting the Template", template);
504504
for (VMTemplateVO dataDiskTemplate : dataDiskTemplates) {
505-
logger.info("Delete Datadisk template: {} from image store: {}", dataDiskTemplate, imageStore);
505+
logger.info("Delete Datadisk Template: {} from image store: {}", dataDiskTemplate, imageStore);
506506
AsyncCallFuture<TemplateApiResult> future = imageService.deleteTemplateAsync(imageFactory.getTemplate(dataDiskTemplate.getId(), imageStore));
507507
try {
508508
TemplateApiResult result = future.get();

0 commit comments

Comments
 (0)