Skip to content

Commit f960725

Browse files
committed
Merge pull request #1457 from nvazquez/excludeclusters
CLOUDSTACK-9333: Exclude clusters from OVF operationsJIRA TICKET: https://issues.apache.org/jira/browse/CLOUDSTACK-9333 ## Introduction In some environments there is a need to exclude certain VMware clusters from performing OVF operations. This operations are part of: * create template * create volume snaphsot * copy template, volume, images from primary storage to secondary storage * migrate volume * participate when a template gets cached over to primary storage. In ESX/ESXi, OVF operations are low priority and bound to a single CPU and most likely get throttled to certain IOPS and network limits. If the hypervisor chosen for OVF operations is weak or overloaded this results in significantly longer execution of such OVF command and therefore degraded performance of underlying CloudStack API call. ### Proposed solution It is proposed to add a way to exclude hosts from selected clusters for OVF operations. To exclude a cluster, would be necessary to insert a record in <code>cluster_details</code> specifying property **vmware.exclude_from_ovf** in this way: (supposing we want to exclude cluster X) | cluster_id | name| value | |:-------------:|:-------------:|:-------------:| |X|vmware.exclude_from_ovf|true| * pr/1457: CLOUDSTACK-9333: Exclude clusters for OVF operations Signed-off-by: Will Stevens <williamstevens@gmail.com>
2 parents e72a69a + 4aae051 commit f960725

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public interface CapacityManager {
5353
"0.85",
5454
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.",
5555
true, ConfigKey.Scope.Zone);
56+
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
57+
new ConfigKey<Boolean>(
58+
Boolean.class,
59+
"cluster.storage.operations.exclude",
60+
"Advanced",
61+
"false",
62+
"Exclude cluster from storage operations",
63+
true,
64+
ConfigKey.Scope.Cluster,
65+
null);
5666

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

engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.cloudstack.storage.LocalHostEndpoint;
4545
import org.apache.cloudstack.storage.RemoteHostEndPoint;
4646

47+
import com.cloud.capacity.CapacityManager;
4748
import com.cloud.host.Host;
4849
import com.cloud.host.HostVO;
4950
import com.cloud.host.Status;
@@ -64,9 +65,13 @@ public class DefaultEndPointSelector implements EndPointSelector {
6465
private static final Logger s_logger = Logger.getLogger(DefaultEndPointSelector.class);
6566
@Inject
6667
HostDao hostDao;
67-
private final String findOneHostOnPrimaryStorage =
68-
"select h.id from host h, storage_pool_host_ref s where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and"
69-
+ " h.id = s.host_id and s.pool_id = ? ";
68+
private final String findOneHostOnPrimaryStorage = "select t.id from "
69+
+ "(select h.id, cd.value "
70+
+ "from host h join storage_pool_host_ref s on h.id = s.host_id "
71+
+ "join cluster c on c.id=h.cluster_id "
72+
+ "left join cluster_details cd on c.id=cd.cluster_id and cd.name='" + CapacityManager.StorageOperationsExcludeCluster.key() + "' "
73+
+ "where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and s.pool_id = ? ";
74+
7075
private String findOneHypervisorHostInScope = "select h.id from host h where h.status = 'Up' and h.hypervisor_type is not null ";
7176

7277
protected boolean moveBetweenPrimaryImage(DataStore srcStore, DataStore destStore) {
@@ -115,6 +120,7 @@ protected EndPoint findEndPointInScope(Scope scope, String sqlBase, Long poolId)
115120
sbuilder.append(scope.getScopeId());
116121
}
117122
// TODO: order by rand() is slow if there are lot of hosts
123+
sbuilder.append(") t where t.value<>'true' or t.value is null"); //Added for exclude cluster's subquery
118124
sbuilder.append(" ORDER by rand() limit 1");
119125
String sql = sbuilder.toString();
120126
HostVO host = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,6 @@ public String getConfigComponentName() {
10821082
@Override
10831083
public ConfigKey<?>[] getConfigKeys() {
10841084
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor,
1085-
StorageAllocatedCapacityDisableThreshold};
1085+
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster};
10861086
}
10871087
}

setup/db/db/schema-481to490.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,6 @@ VIEW `user_vm_view` AS
410410
AND (`custom_speed`.`name` = 'CpuSpeed'))))
411411
LEFT JOIN `user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `vm_instance`.`id`)
412412
AND (`custom_ram_size`.`name` = 'memory'))));
413+
414+
-- Add cluster.storage.operations.exclude property
415+
INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `description`, `default_value`, `updated`, `scope`, `is_dynamic`) VALUES ('Advanced', 'DEFAULT', 'CapacityManager', 'cluster.storage.operations.exclude', 'Exclude cluster from storage operations', 'false', now(), 'Cluster', '1');

0 commit comments

Comments
 (0)