Skip to content

Commit 51cf988

Browse files
Exclude last hosts with error or degraded state as well, for vm deploy
1 parent 47154ae commit 51cf988

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import javax.inject.Inject;
3737
import javax.naming.ConfigurationException;
3838

39+
import com.cloud.resource.ResourceState;
3940
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
4041
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
4142
import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -464,9 +465,9 @@ private Host checkDeployInVmLastHost(VirtualMachineProfile vmProfile, VirtualMac
464465
return null;
465466
}
466467

467-
logger.debug("VM's last host is {}, trying to choose the same host if it is not in maintenance state", lastHost);
468-
if (lastHost.isInMaintenanceStates()) {
469-
logger.debug("Unable to deploy VM {} in the last host, last host {} is in maintenance state", vm.getName(), lastHost.getName());
468+
logger.debug("VM's last host is {}, trying to choose the same host if it is not in maintenance, error or degraded state", lastHost);
469+
if (lastHost.isInMaintenanceStates() || Arrays.asList(ResourceState.Error, ResourceState.Degraded).contains(lastHost.getResourceState())) {
470+
logger.debug("Unable to deploy VM {} in the last host, last host {} is in {} state", vm.getName(), lastHost.getName(), lastHost.getResourceState());
470471
return null;
471472
}
472473

0 commit comments

Comments
 (0)