Skip to content

Commit 360b64c

Browse files
winterhazelDaan Hoogland
authored andcommitted
Consider infinite resources when calculating secondary storage limit for upload operations
1 parent 81a8ac8 commit 360b64c

3 files changed

Lines changed: 10 additions & 4 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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
108108
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
109109
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
110-
import org.apache.cloudstack.utils.bytescale.ByteScaleUtils;
111110
import org.apache.cloudstack.utils.identity.ManagementServerNode;
112111
import org.apache.cloudstack.utils.imagestore.ImageStoreUtil;
113112
import org.apache.cloudstack.utils.jsinterpreter.TagAsRuleHelper;
@@ -523,7 +522,7 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
523522
Account account = _accountDao.findById(accountId);
524523
Domain domain = domainDao.findById(account.getDomainId());
525524

526-
command.setDefaultMaxSecondaryStorageInGB(ByteScaleUtils.bytesToGibibytes(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null)));
525+
command.setDefaultMaxSecondaryStorageInBytes(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null));
527526
command.setAccountId(accountId);
528527
Gson gson = new GsonBuilder().create();
529528
String metadata = EncryptionUtil.encodeData(gson.toJson(command), key);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
6565
import org.apache.cloudstack.storage.heuristics.HeuristicRuleHelper;
6666
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
67-
import org.apache.cloudstack.utils.bytescale.ByteScaleUtils;
6867
import org.apache.cloudstack.utils.security.DigestHelper;
6968
import org.apache.commons.collections.CollectionUtils;
7069

@@ -450,7 +449,7 @@ private void postUploadAllocation(List<DataStore> imageStores, VMTemplateVO temp
450449
Account account = _accountDao.findById(accountId);
451450
Domain domain = _domainDao.findById(account.getDomainId());
452451

453-
payload.setDefaultMaxSecondaryStorageInGB(ByteScaleUtils.bytesToGibibytes(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null)));
452+
payload.setDefaultMaxSecondaryStorageInBytes(_resourceLimitMgr.findCorrectResourceLimitForAccountAndDomain(account, domain, ResourceType.secondary_storage, null));
454453
payload.setAccountId(accountId);
455454
payload.setRemoteEndPoint(ep.getPublicAddr());
456455
payload.setRequiresHvm(template.requiresHvm());

0 commit comments

Comments
 (0)