Skip to content

Commit a84e65e

Browse files
committed
server: add global settings for volume resize
1 parent 046870e commit a84e65e

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public interface CapacityManager {
4040
static final String StorageCapacityDisableThresholdCK = "pool.storage.capacity.disablethreshold";
4141
static final String StorageOverprovisioningFactorCK = "storage.overprovisioning.factor";
4242
static final String StorageAllocatedCapacityDisableThresholdCK = "pool.storage.allocated.capacity.disablethreshold";
43+
static final String StorageAllocatedCapacityDisableThresholdForVolumeResizeCK = "pool.storage.allocated.resize.capacity.disablethreshold";
4344

4445
static final ConfigKey<Float> CpuOverprovisioningFactor =
4546
new ConfigKey<>(
@@ -118,6 +119,17 @@ public interface CapacityManager {
118119
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.",
119120
true);
120121

122+
static final ConfigKey<Double> StorageAllocatedCapacityDisableThresholdForVolumeSize =
123+
new ConfigKey<>(
124+
ConfigKey.CATEGORY_ALERT,
125+
Double.class,
126+
StorageAllocatedCapacityDisableThresholdForVolumeResizeCK,
127+
"0.85",
128+
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for volume resize. " +
129+
"This is applicable only when volume.resize.allowed.beyond.allocation is set to true.",
130+
true,
131+
ConfigKey.Scope.Zone);
132+
121133
public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);
122134

123135
void allocateVmCapacity(VirtualMachine vm, boolean fromLastHost);

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ public interface StorageManager extends StorageService {
209209
ConfigKey<Long> HEURISTICS_SCRIPT_TIMEOUT = new ConfigKey<>("Advanced", Long.class, "heuristics.script.timeout", "3000",
210210
"The maximum runtime, in milliseconds, to execute the heuristic rule; if it is reached, a timeout will happen.", true);
211211

212+
ConfigKey<Boolean> AllowVolumeReSizeBeyongAllocation = new ConfigKey<Boolean>("Advanced", Boolean.class, "volume.resize.allowed.beyond.allocation", "false",
213+
"Determines whether volume size can exceed the pool capacity allocation disable threshold (pool.storage.allocated.capacity.disablethreshold) when resize a volume",
214+
true, ConfigKey.Scope.StoragePool);
215+
212216
/**
213217
* should we execute in sequence not involving any storages?
214218
* @return tru if commands should execute in sequence

server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ public String getConfigComponentName() {
12541254
@Override
12551255
public ConfigKey<?>[] getConfigKeys() {
12561256
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor,
1257-
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, ImageStoreNFSVersion, SecondaryStorageCapacityThreshold};
1257+
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, ImageStoreNFSVersion, SecondaryStorageCapacityThreshold,
1258+
StorageAllocatedCapacityDisableThresholdForVolumeSize };
12581259
}
12591260
}

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ protected void weightBasedParametersForValidation() {
590590
weightBasedParametersForValidation.add(Config.LocalStorageCapacityThreshold.key());
591591
weightBasedParametersForValidation.add(CapacityManager.StorageAllocatedCapacityDisableThreshold.key());
592592
weightBasedParametersForValidation.add(CapacityManager.StorageCapacityDisableThreshold.key());
593+
weightBasedParametersForValidation.add(CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.key());
593594
weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.key());
594595
weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.key());
595596
weightBasedParametersForValidation.add(Config.AgentLoadThreshold.key());

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,21 +3185,32 @@ protected boolean checkPoolforSpace(StoragePool pool, long allocatedSizeWithTemp
31853185
logger.debug("Total capacity of the pool " + poolVO.getName() + " with ID " + pool.getId() + " is " + toHumanReadableSize(totalOverProvCapacity));
31863186

31873187
double storageAllocatedThreshold = CapacityManager.StorageAllocatedCapacityDisableThreshold.valueIn(pool.getDataCenterId());
3188+
System.out.println("Wei storageAllocatedThreshold = " + storageAllocatedThreshold);
31883189

31893190
if (logger.isDebugEnabled()) {
31903191
logger.debug("Checking pool: " + pool.getId() + " for storage allocation , maxSize : " + toHumanReadableSize(totalOverProvCapacity) + ", totalAllocatedSize : " + toHumanReadableSize(allocatedSizeWithTemplate)
31913192
+ ", askingSize : " + toHumanReadableSize(totalAskingSize) + ", allocated disable threshold: " + storageAllocatedThreshold);
31923193
}
31933194

31943195
double usedPercentage = (allocatedSizeWithTemplate + totalAskingSize) / (double)(totalOverProvCapacity);
3196+
System.out.println("Wei usedPercentage = " + usedPercentage);
31953197

31963198
if (usedPercentage > storageAllocatedThreshold) {
31973199
if (logger.isDebugEnabled()) {
31983200
logger.debug("Insufficient un-allocated capacity on: " + pool.getId() + " for storage allocation since its allocated percentage: " + usedPercentage
3199-
+ " has crossed the allocated pool.storage.allocated.capacity.disablethreshold: " + storageAllocatedThreshold + ", skipping this pool");
3201+
+ " has crossed the allocated pool.storage.allocated.capacity.disablethreshold: " + storageAllocatedThreshold);
3202+
}
3203+
if (!AllowVolumeReSizeBeyongAllocation.valueIn(pool.getId())) {
3204+
logger.debug(String.format("Skipping the pool %s as %s is false", pool, AllowVolumeReSizeBeyongAllocation.key()));
3205+
return false;
32003206
}
32013207

3202-
return false;
3208+
double storageAllocatedThresholdForResize = CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.valueIn(pool.getDataCenterId());
3209+
if (usedPercentage > storageAllocatedThresholdForResize) {
3210+
logger.debug(String.format("Skipping the pool %s since its allocated percentage: %s has crossed the allocated %s: %s",
3211+
pool, usedPercentage, CapacityManager.StorageAllocatedCapacityDisableThresholdForVolumeSize.key(), storageAllocatedThresholdForResize));
3212+
return false;
3213+
}
32033214
}
32043215

32053216
if (totalOverProvCapacity < (allocatedSizeWithTemplate + totalAskingSize)) {
@@ -4050,7 +4061,8 @@ public ConfigKey<?>[] getConfigKeys() {
40504061
MountDisabledStoragePool,
40514062
VmwareCreateCloneFull,
40524063
VmwareAllowParallelExecution,
4053-
DataStoreDownloadFollowRedirects
4064+
DataStoreDownloadFollowRedirects,
4065+
AllowVolumeReSizeBeyongAllocation
40544066
};
40554067
}
40564068

0 commit comments

Comments
 (0)