Skip to content

Commit 731a83b

Browse files
authored
add global setting to allow parallel execution on vmware (apache#6413)
* add global setting to allow parallel execution on vmware * cleanup setting distribution for vmware.create.full.clone * query setting in vmware guru * don´t touch other hypervisor's commands * guru hierarchy cleanup
1 parent 12ecfa8 commit 731a83b

File tree

23 files changed

+223
-149
lines changed

23 files changed

+223
-149
lines changed

api/src/main/java/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Map;
2121

2222
import org.apache.cloudstack.backup.Backup;
23-
import org.apache.cloudstack.framework.config.ConfigKey;
2423

2524
import com.cloud.agent.api.Command;
2625
import com.cloud.agent.api.to.NicTO;
@@ -35,8 +34,7 @@
3534
import com.cloud.vm.VirtualMachineProfile;
3635

3736
public interface HypervisorGuru extends Adapter {
38-
ConfigKey<Boolean> VmwareFullClone = new ConfigKey<Boolean>("Advanced", Boolean.class, "vmware.create.full.clone", "true",
39-
"If set to true, creates guest VMs as full clones on ESX", false);
37+
4038
HypervisorType getHypervisorType();
4139

4240
/**

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

Lines changed: 62 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,57 +40,86 @@ 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 VmwareCreateCloneFullCK = "vmware.create.full.clone";
44-
45-
static final ConfigKey<Float> CpuOverprovisioningFactor = new ConfigKey<Float>(Float.class, CpuOverprovisioningFactorCK, "Advanced", "1.0",
46-
"Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", true, ConfigKey.Scope.Cluster, null);
47-
static final ConfigKey<Float> MemOverprovisioningFactor = new ConfigKey<Float>(Float.class, MemOverprovisioningFactorCK, "Advanced", "1.0",
48-
"Used for memory overprovisioning calculation", true, ConfigKey.Scope.Cluster, null);
49-
static final ConfigKey<Double> StorageCapacityDisableThreshold = new ConfigKey<Double>("Alert", Double.class, StorageCapacityDisableThresholdCK, "0.85",
50-
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true,
51-
ConfigKey.Scope.Zone);
52-
static final ConfigKey<Double> StorageOverprovisioningFactor = new ConfigKey<Double>("Storage", Double.class, StorageOverprovisioningFactorCK, "2",
53-
"Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.StoragePool);
43+
44+
static final String CATEGORY_ADVANCED = "Advanced";
45+
static final String CATEGORY_ALERT = "Alert";
46+
47+
static final ConfigKey<Float> CpuOverprovisioningFactor =
48+
new ConfigKey<>(
49+
Float.class,
50+
CpuOverprovisioningFactorCK,
51+
CATEGORY_ADVANCED,
52+
"1.0",
53+
"Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)",
54+
true,
55+
ConfigKey.Scope.Cluster,
56+
null);
57+
static final ConfigKey<Float> MemOverprovisioningFactor =
58+
new ConfigKey<>(
59+
Float.class,
60+
MemOverprovisioningFactorCK,
61+
CATEGORY_ADVANCED,
62+
"1.0",
63+
"Used for memory overprovisioning calculation",
64+
true,
65+
ConfigKey.Scope.Cluster,
66+
null);
67+
static final ConfigKey<Double> StorageCapacityDisableThreshold =
68+
new ConfigKey<>(
69+
CATEGORY_ALERT,
70+
Double.class,
71+
StorageCapacityDisableThresholdCK,
72+
"0.85",
73+
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.",
74+
true,
75+
ConfigKey.Scope.Zone);
76+
static final ConfigKey<Double> StorageOverprovisioningFactor =
77+
new ConfigKey<>(
78+
"Storage",
79+
Double.class,
80+
StorageOverprovisioningFactorCK,
81+
"2",
82+
"Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)",
83+
true,
84+
ConfigKey.Scope.StoragePool);
5485
static final ConfigKey<Double> StorageAllocatedCapacityDisableThreshold =
55-
new ConfigKey<Double>(
56-
"Alert",
57-
Double.class,
58-
StorageAllocatedCapacityDisableThresholdCK,
59-
"0.85",
60-
"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.",
61-
true, ConfigKey.Scope.Zone);
86+
new ConfigKey<>(
87+
CATEGORY_ALERT,
88+
Double.class,
89+
StorageAllocatedCapacityDisableThresholdCK,
90+
"0.85",
91+
"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.",
92+
true,
93+
ConfigKey.Scope.Zone);
6294
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
63-
new ConfigKey<Boolean>(
95+
new ConfigKey<>(
6496
Boolean.class,
6597
"cluster.storage.operations.exclude",
66-
"Advanced",
98+
CATEGORY_ADVANCED,
6799
"false",
68100
"Exclude cluster from storage operations",
69101
true,
70102
ConfigKey.Scope.Cluster,
71103
null);
72-
static final ConfigKey<Boolean> VmwareCreateCloneFull =
73-
new ConfigKey<Boolean>(
74-
"Storage",
75-
Boolean.class,
76-
VmwareCreateCloneFullCK,
77-
"false",
78-
"If set to true, creates VMs as full clones on ESX hypervisor",
79-
true,
80-
ConfigKey.Scope.StoragePool);
81104
static final ConfigKey<String> ImageStoreNFSVersion =
82-
new ConfigKey<String>(
105+
new ConfigKey<>(
83106
String.class,
84107
"secstorage.nfs.version",
85-
"Advanced",
108+
CATEGORY_ADVANCED,
86109
null,
87110
"Enforces specific NFS version when mounting Secondary Storage. If NULL default selection is performed",
88111
true,
89112
ConfigKey.Scope.ImageStore,
90113
null);
91114

92-
static final ConfigKey<Float> SecondaryStorageCapacityThreshold = new ConfigKey<Float>("Advanced", Float.class, "secondary.storage.capacity.threshold", "0.90",
93-
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.", true);
115+
static final ConfigKey<Float> SecondaryStorageCapacityThreshold =
116+
new ConfigKey<>(
117+
CATEGORY_ADVANCED,
118+
Float.class,
119+
"secondary.storage.capacity.threshold",
120+
"0.90",
121+
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.",
122+
true);
94123

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

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,44 @@ public interface StorageManager extends StorageService {
163163
true,
164164
ConfigKey.Scope.Cluster,
165165
null);
166+
ConfigKey<Boolean> VmwareCreateCloneFull = new ConfigKey<>(Boolean.class,
167+
"vmware.create.full.clone",
168+
"Storage",
169+
"false",
170+
"If set to true, creates VMs as full clones on ESX hypervisor",
171+
true,
172+
ConfigKey.Scope.StoragePool,
173+
null);
174+
ConfigKey<Boolean> VmwareAllowParallelExecution = new ConfigKey<>(Boolean.class,
175+
"vmware.allow.parallel.command.execution",
176+
"Advanced",
177+
"false",
178+
"allow commands to be executed in parallel in spite of 'vmware.create.full.clone' being set to true.",
179+
true,
180+
ConfigKey.Scope.Global,
181+
null);
182+
183+
/**
184+
* should we execute in sequence not involving any storages?
185+
* @return tru if commands should execute in sequence
186+
*/
187+
static boolean shouldExecuteInSequenceOnVmware() {
188+
return shouldExecuteInSequenceOnVmware(null, null);
189+
}
190+
191+
static boolean shouldExecuteInSequenceOnVmware(Long srcStoreId, Long dstStoreId) {
192+
final Boolean fullClone = getFullCloneConfiguration(srcStoreId) || getFullCloneConfiguration(dstStoreId);
193+
final Boolean allowParallel = getAllowParallelExecutionConfiguration();
194+
return fullClone && !allowParallel;
195+
}
196+
197+
static Boolean getAllowParallelExecutionConfiguration() {
198+
return VmwareAllowParallelExecution.value();
199+
}
200+
201+
static Boolean getFullCloneConfiguration(Long storeId) {
202+
return VmwareCreateCloneFull.valueIn(storeId);
203+
}
166204

167205
/**
168206
* Returns a comma separated list of tags for the specified storage pool

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,7 @@ public boolean getExecuteInSequence(final HypervisorType hypervisorType) {
15571557
case LXC:
15581558
return false;
15591559
case VMware:
1560-
final Boolean fullClone = HypervisorGuru.VmwareFullClone.value();
1561-
return fullClone;
1560+
return StorageManager.shouldExecuteInSequenceOnVmware();
15621561
default:
15631562
return ExecuteInSequence.value();
15641563
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
import com.cloud.agent.api.to.DiskTO;
8686
import com.cloud.agent.api.to.VirtualMachineTO;
8787
import com.cloud.agent.manager.allocator.PodAllocator;
88-
import com.cloud.capacity.CapacityManager;
8988
import com.cloud.cluster.ClusterManager;
9089
import com.cloud.configuration.Resource.ResourceType;
9190
import com.cloud.dc.DataCenter;
@@ -1704,7 +1703,7 @@ public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws Sto
17041703
if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
17051704
// retrieve clone flag.
17061705
UserVmCloneType cloneType = UserVmCloneType.linked;
1707-
Boolean value = CapacityManager.VmwareCreateCloneFull.valueIn(vol.getPoolId());
1706+
Boolean value = StorageManager.VmwareCreateCloneFull.valueIn(vol.getPoolId());
17081707
if (value != null && value) {
17091708
cloneType = UserVmCloneType.full;
17101709
}

engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Map;
3333

3434
import com.cloud.exception.InvalidParameterValueException;
35+
import com.cloud.storage.StorageManager;
3536
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
3637
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3738
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -56,7 +57,6 @@
5657
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
5758
import com.cloud.host.HostVO;
5859
import com.cloud.hypervisor.Hypervisor.HypervisorType;
59-
import com.cloud.hypervisor.HypervisorGuru;
6060
import com.cloud.service.ServiceOfferingVO;
6161
import com.cloud.service.dao.ServiceOfferingDao;
6262
import com.cloud.storage.DiskOfferingVO;
@@ -209,9 +209,23 @@ public void testSendStopWithNullAnswer() throws Exception {
209209
public void testExeceuteInSequence() {
210210
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.XenServer) == false);
211211
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.KVM) == false);
212-
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware) == HypervisorGuru.VmwareFullClone.value());
213212
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.Ovm3) == VirtualMachineManager.ExecuteInSequence.value());
214213
}
214+
@Test
215+
public void testExeceuteInSequenceVmware() {
216+
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
217+
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
218+
assertFalse("no full clones so no need to execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
219+
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
220+
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
221+
assertTrue("full clones and no explicit parallel execution allowed, should execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
222+
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
223+
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
224+
assertFalse("execute in sequence should not be needed as parallel is allowed", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
225+
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
226+
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
227+
assertFalse("double reasons to allow parallel execution", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
228+
}
215229

216230
@Test
217231
public void testCheckIfCanUpgrade() throws Exception {

engine/schema/src/main/java/com/cloud/network/dao/NetworkDao.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long>, StateDao<State,
4747

4848
int getOtherPersistentNetworksCount(long id, String broadcastURI, boolean isPersistent);
4949

50-
@Override
51-
@Deprecated
52-
NetworkVO persist(NetworkVO vo);
53-
5450
/**
5551
* Retrieves the next available mac address in this network configuration.
5652
*

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import com.cloud.agent.api.to.DataTO;
6363
import com.cloud.agent.api.to.NfsTO;
6464
import com.cloud.agent.api.to.VirtualMachineTO;
65-
import com.cloud.capacity.CapacityManager;
6665
import com.cloud.configuration.Config;
6766
import com.cloud.host.Host;
6867
import com.cloud.hypervisor.Hypervisor;
@@ -226,7 +225,7 @@ protected DataTO addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(DataTO
226225
DataStoreTO dataStoreTO = dataTO.getDataStore();
227226
if (dataStoreTO != null && dataStoreTO instanceof PrimaryDataStoreTO){
228227
PrimaryDataStoreTO primaryDataStoreTO = (PrimaryDataStoreTO) dataStoreTO;
229-
primaryDataStoreTO.setFullCloneFlag(CapacityManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId()));
228+
primaryDataStoreTO.setFullCloneFlag(StorageManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId()));
230229
StoragePool pool = storageManager.getStoragePool(primaryDataStoreTO.getId());
231230
primaryDataStoreTO.setDiskProvisioningStrictnessFlag(storageManager.DiskProvisioningStrictness.valueIn(pool.getDataCenterId()));
232231
}

engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void setup() throws Exception {
8282
}
8383

8484
private void replaceVmwareCreateCloneFullField() throws Exception {
85-
Field field = CapacityManager.class.getDeclaredField("VmwareCreateCloneFull");
85+
Field field = StorageManager.class.getDeclaredField("VmwareCreateCloneFull");
8686
field.setAccessible(true);
8787
// remove final modifier from field
8888
Field modifiersField = Field.class.getDeclaredField("modifiers");

plugins/hypervisors/baremetal/src/main/java/com/cloud/baremetal/manager/BareMetalGuru.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@
3030
import org.apache.log4j.Logger;
3131

3232
import com.cloud.agent.api.to.VirtualMachineTO;
33-
import com.cloud.host.dao.HostDao;
3433
import com.cloud.hypervisor.Hypervisor.HypervisorType;
3534
import com.cloud.hypervisor.HypervisorGuru;
3635
import com.cloud.hypervisor.HypervisorGuruBase;
3736
import com.cloud.storage.GuestOSVO;
3837
import com.cloud.storage.dao.GuestOSDao;
3938
import com.cloud.vm.VMInstanceVO;
4039
import com.cloud.vm.VirtualMachineProfile;
41-
import com.cloud.vm.dao.VMInstanceDao;
4240

4341
public class BareMetalGuru extends HypervisorGuruBase implements HypervisorGuru {
4442
private static final Logger s_logger = Logger.getLogger(BareMetalGuru.class);
4543
@Inject
4644
GuestOSDao _guestOsDao;
47-
@Inject
48-
HostDao _hostDao;
49-
@Inject
50-
VMInstanceDao _vmDao;
5145

5246
protected BareMetalGuru() {
5347
super();
@@ -62,7 +56,7 @@ public HypervisorType getHypervisorType() {
6256
public VirtualMachineTO implement(VirtualMachineProfile vm) {
6357
VirtualMachineTO to = toVirtualMachineTO(vm);
6458

65-
VMInstanceVO vo = _vmDao.findById(vm.getId());
59+
VMInstanceVO vo = virtualMachineDao.findById(vm.getId());
6660
if (vo.getLastHostId() == null) {
6761
to.setBootArgs(BaremetalManager.DO_PXE);
6862
}

0 commit comments

Comments
 (0)