Skip to content

Commit dc0f8eb

Browse files
committed
CLOUDSTACK-4941:
During HA call different planners which skip some heurestics
1 parent ed2125e commit dc0f8eb

23 files changed

Lines changed: 275 additions & 61 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.deploy;
18+
19+
20+
public interface HAPlanner extends DeploymentPlanner {
21+
}

client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@
176176
<artifactId>cloud-plugin-planner-user-dispersing</artifactId>
177177
<version>${project.version}</version>
178178
</dependency>
179+
<dependency>
180+
<groupId>org.apache.cloudstack</groupId>
181+
<artifactId>cloud-plugin-planner-skip-heurestics</artifactId>
182+
<version>${project.version}</version>
183+
</dependency>
179184
<dependency>
180185
<groupId>org.apache.cloudstack</groupId>
181186
<artifactId>cloud-plugin-planner-user-concentrated-pod</artifactId>

core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
<property name="excludeKey" value="deployment.planners.exclude" />
7878
</bean>
7979

80+
<bean id="haPlannersRegistry"
81+
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
82+
<property name="excludeKey" value="ha.planners.exclude" />
83+
</bean>
84+
8085
<bean id="podAllocatorsRegistry"
8186
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
8287
<property name="excludeKey" value="pod.allocators.exclude" />

core/resources/META-INF/cloudstack/planner/spring-core-lifecycle-planner-context-inheritable.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@
3838
value="org.apache.cloudstack.affinity.AffinityGroupProcessor" />
3939
</bean>
4040

41+
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
42+
<property name="registry" ref="haPlannersRegistry" />
43+
<property name="typeClass" value="com.cloud.deploy.HAPlanner" />
44+
</bean>
45+
4146
</beans>

engine/api/src/com/cloud/vm/VirtualMachineManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,22 @@ void allocate(String vmInstanceName,
103103

104104
boolean stateTransitTo(VirtualMachine vm, VirtualMachine.Event e, Long hostId) throws NoTransitionException;
105105

106-
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
106+
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlanner planner) throws InsufficientCapacityException, ResourceUnavailableException,
107107
ConcurrentOperationException, OperationTimedoutException;
108108

109-
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
109+
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner) throws InsufficientCapacityException,
110110
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
111111

112+
void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner) throws InsufficientCapacityException,
113+
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
114+
112115
void advanceStop(String vmUuid, boolean cleanupEvenIfUnableToStop) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
113116

114117
void advanceExpunge(String vmUuid) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
115118

116119
void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException;
117120

118-
void migrateAway(String vmUuid, long hostId) throws InsufficientServerCapacityException;
121+
void migrateAway(String vmUuid, long hostId, DeploymentPlanner planner) throws InsufficientServerCapacityException;
119122

120123
void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException;
121124

engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface DeploymentPlanningManager extends Manager {
4040
*
4141
*/
4242
DeployDestination planDeployment(VirtualMachineProfile vmProfile, DeploymentPlan plan,
43-
ExcludeList avoids) throws InsufficientServerCapacityException, AffinityConflictException;
43+
ExcludeList avoids, DeploymentPlanner planner) throws InsufficientServerCapacityException, AffinityConflictException;
4444

4545
String finalizeReservation(DeployDestination plannedDestination,
4646
VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import org.apache.log4j.Logger;
4444

45+
import com.cloud.deploy.DeploymentPlanner;
4546
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
4647
import org.apache.cloudstack.context.CallContext;
4748
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -555,7 +556,7 @@ public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params
555556
@Override
556557
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) {
557558
try {
558-
advanceStart(vmUuid, params, planToDeploy);
559+
advanceStart(vmUuid, params, planToDeploy, null);
559560
} catch (ConcurrentOperationException e) {
560561
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
561562
} catch (InsufficientCapacityException e) {
@@ -696,20 +697,20 @@ protected boolean areAffinityGroupsAssociated(VirtualMachineProfile vmProfile) {
696697
}
697698

698699
@Override
699-
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params)
700+
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlanner planner)
700701
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
701702

702-
advanceStart(vmUuid, params, null);
703+
advanceStart(vmUuid, params, null, planner);
703704
}
704705

705706
@Override
706-
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
707+
public void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner) throws InsufficientCapacityException,
707708
ConcurrentOperationException, ResourceUnavailableException {
708709

709710
AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
710711
if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
711712
// avoid re-entrance
712-
orchestrateStart(vmUuid, params, planToDeploy);
713+
orchestrateStart(vmUuid, params, planToDeploy, planner);
713714
} else {
714715
Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy);
715716

@@ -731,9 +732,11 @@ else if(jobException instanceof ResourceUnavailableException)
731732
}
732733
}
733734

734-
private void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
735-
ConcurrentOperationException, ResourceUnavailableException {
736735

736+
@Override
737+
public void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner)
738+
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
739+
737740
CallContext cctxt = CallContext.current();
738741
Account account = cctxt.getCallingAccount();
739742
User caller = cctxt.getCallingUser();
@@ -848,7 +851,7 @@ private void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Ob
848851
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, owner, params);
849852
DeployDestination dest = null;
850853
try {
851-
dest = _dpMgr.planDeployment(vmProfile, plan, avoids);
854+
dest = _dpMgr.planDeployment(vmProfile, plan, avoids, planner);
852855
} catch (AffinityConflictException e2) {
853856
s_logger.warn("Unable to create deployment, affinity rules associted to the VM conflict", e2);
854857
throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
@@ -2035,7 +2038,7 @@ protected void cancelWorkItems(long nodeId) {
20352038
}
20362039

20372040
@Override
2038-
public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServerCapacityException {
2041+
public void migrateAway(String vmUuid, long srcHostId, DeploymentPlanner planner) throws InsufficientServerCapacityException {
20392042
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
20402043
if (vm == null) {
20412044
s_logger.debug("Unable to find a VM for " + vmUuid);
@@ -2068,7 +2071,7 @@ public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServer
20682071
while (true) {
20692072

20702073
try {
2071-
dest = _dpMgr.planDeployment(profile, plan, excludes);
2074+
dest = _dpMgr.planDeployment(profile, plan, excludes, planner);
20722075
} catch (AffinityConflictException e2) {
20732076
s_logger.warn("Unable to create deployment, affinity rules associted to the VM conflict", e2);
20742077
throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
@@ -3390,7 +3393,7 @@ public void findHostAndMigrate(String vmUuid, Long newSvcOfferingId, ExcludeList
33903393
DeployDestination dest = null;
33913394

33923395
try {
3393-
dest = _dpMgr.planDeployment(profile, plan, excludes);
3396+
dest = _dpMgr.planDeployment(profile, plan, excludes, null);
33943397
} catch (AffinityConflictException e2) {
33953398
s_logger.warn("Unable to create deployment, affinity rules associted to the VM conflict", e2);
33963399
throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
@@ -4714,7 +4717,7 @@ public Pair<JobInfo.Status, String> handleVmWorkJob(AsyncJob job, VmWork work) t
47144717
assert (vm != null);
47154718
if (work instanceof VmWorkStart) {
47164719
VmWorkStart workStart = (VmWorkStart)work;
4717-
orchestrateStart(vm.getUuid(), workStart.getParams(), workStart.getPlan());
4720+
orchestrateStart(vm.getUuid(), workStart.getParams(), workStart.getPlan(), null);
47184721
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null);
47194722
} else if (work instanceof VmWorkStop) {
47204723
VmWorkStop workStop = (VmWorkStop)work;

engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse,
185185
while (true) {
186186
DeployDestination dest = null;
187187
try {
188-
dest = _dpMgr.planDeployment(vmProfile, plan, exclude);
188+
dest = _dpMgr.planDeployment(vmProfile, plan, exclude, null);
189189
} catch (AffinityConflictException e) {
190190
throw new CloudRuntimeException(
191191
"Unable to create deployment, affinity rules associted to the VM conflict");
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<artifactId>cloud-plugin-planner-skip-heurestics</artifactId>
22+
<name>Apache CloudStack Plugin - Skip Heurestics Planner</name>
23+
<parent>
24+
<groupId>org.apache.cloudstack</groupId>
25+
<artifactId>cloudstack-plugins</artifactId>
26+
<version>4.3.0-SNAPSHOT</version>
27+
<relativePath>../../pom.xml</relativePath>
28+
</parent>
29+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
name=skip-heurestics
18+
parent=planner

0 commit comments

Comments
 (0)