Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public interface CapacityManager {
ConfigKey.Scope.ImageStore,
null);

static final ConfigKey<Float> SecondaryStorageCapacityThreshold = new ConfigKey<Float>("Advanced", Float.class, "secondary.storage.capacity.threshold", "0.90",
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.", true);

public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);

void allocateVmCapacity(VirtualMachine vm, boolean fromLastHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.cloudstack.engine.orchestration;

import com.cloud.capacity.CapacityManager;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -101,7 +102,6 @@ public class StorageOrchestrator extends ManagerBase implements StorageOrchestra
true, ConfigKey.Scope.Global);

Integer numConcurrentCopyTasksPerSSVM = 2;
private double imageStoreCapacityThreshold = 0.90;

@Override
public String getConfigComponentName() {
Expand Down Expand Up @@ -404,7 +404,7 @@ private boolean shouldMigrate(DataObject chosenFile, Long srcDatastoreId, Long d
private boolean storageCapacityBelowThreshold(Map<Long, Pair<Long, Long>> storageCapacities, Long destStoreId) {
Pair<Long, Long> imageStoreCapacity = storageCapacities.get(destStoreId);
long usedCapacity = imageStoreCapacity.second() - imageStoreCapacity.first();
if (imageStoreCapacity != null && (usedCapacity / (imageStoreCapacity.second() * 1.0)) <= imageStoreCapacityThreshold) {
if (imageStoreCapacity != null && (usedCapacity / (imageStoreCapacity.second() * 1.0)) <= CapacityManager.SecondaryStorageCapacityThreshold.value()) {
s_logger.debug("image store: " + destStoreId + " has sufficient capacity to proceed with migration of file");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,6 @@ public String getConfigComponentName() {
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor,
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, VmwareCreateCloneFull, ImageStoreNFSVersion};
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, VmwareCreateCloneFull, ImageStoreNFSVersion, SecondaryStorageCapacityThreshold};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ private void weightBasedParametersForValidation() {
weightBasedParametersForValidation.add(DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.key());
weightBasedParametersForValidation.add(Config.AgentLoadThreshold.key());
weightBasedParametersForValidation.add(Config.VmUserDispersionWeight.key());
weightBasedParametersForValidation.add(CapacityManager.SecondaryStorageCapacityThreshold.key());

}

Expand Down
28 changes: 23 additions & 5 deletions server/src/main/java/com/cloud/server/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.cloud.agent.api.VmNetworkStatsEntry;
import com.cloud.agent.api.VmStatsEntry;
import com.cloud.agent.api.VolumeStatsEntry;
import com.cloud.capacity.CapacityManager;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.cluster.dao.ManagementServerHostDao;
import com.cloud.dc.Vlan.VlanType;
Expand Down Expand Up @@ -145,6 +146,7 @@
import com.cloud.vm.dao.VMInstanceDao;

import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
import org.apache.commons.io.FileUtils;

/**
* Provides real time stats for various agent resources up to x seconds
Expand Down Expand Up @@ -296,8 +298,6 @@ public String toString() {
private long volumeStatsInterval = -1L;
private long autoScaleStatsInterval = -1L;

private double _imageStoreCapacityThreshold = 0.90;

private String externalStatsPrefix = "";
String externalStatsHost = null;
int externalStatsPort = -1;
Expand Down Expand Up @@ -1367,10 +1367,28 @@ public boolean imageStoreHasEnoughCapacity(DataStore imageStore) {
if (!_storageStats.keySet().contains(imageStore.getId())) { // Stats not available for this store yet, can be a new store. Better to assume it has enough capacity?
return true;
}
StorageStats imageStoreStats = _storageStats.get(imageStore.getId());
if (imageStoreStats != null && (imageStoreStats.getByteUsed() / (imageStoreStats.getCapacityBytes() * 1.0)) <= _imageStoreCapacityThreshold) {

long imageStoreId = imageStore.getId();
StorageStats imageStoreStats = _storageStats.get(imageStoreId);

if (imageStoreStats == null) {
s_logger.debug(String.format("Stats for image store [%s] not found.", imageStoreId));
return false;
}

double totalCapacity = imageStoreStats.getCapacityBytes();
double usedCapacity = imageStoreStats.getByteUsed();
double threshold = getImageStoreCapacityThreshold();
String readableTotalCapacity = FileUtils.byteCountToDisplaySize((long) totalCapacity);
String readableUsedCapacity = FileUtils.byteCountToDisplaySize((long) usedCapacity);

s_logger.debug(String.format("Verifying image storage [%s]. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100));

if (usedCapacity / totalCapacity <= threshold) {
return true;
}

s_logger.warn(String.format("Image storage [%s] has not enough capacity. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100));
return false;
}

Expand Down Expand Up @@ -1603,6 +1621,6 @@ public ConfigKey<?>[] getConfigKeys() {
}

public double getImageStoreCapacityThreshold() {
return _imageStoreCapacityThreshold;
return CapacityManager.SecondaryStorageCapacityThreshold.value();
}
}