Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a779eea
Refactoring Allocator classes
BryanMLima May 10, 2024
1153811
Break into smaller methods random and firfit allocators.
BryanMLima Jun 24, 2024
04b709d
Added unit tests for random and firstfit allocators
BryanMLima Jun 24, 2024
be8bab6
Move random allocator from cloud-plugins to cloud-server
BryanMLima Jun 24, 2024
8058919
Add BaseAllocator abstract class for duplicate code
BryanMLima Jul 11, 2024
05c5662
Add missing license
BryanMLima Jul 11, 2024
7b125d7
Add missing license to unit test file
BryanMLima Jul 11, 2024
1c2d504
Remove host allocator random dependency
BryanMLima Aug 23, 2024
6a4569d
Change exception message on smoke tests
BryanMLima Sep 16, 2024
7520bed
Remove conditional as it was never actually reached in the original flow
BryanMLima Nov 28, 2024
d0e5efd
Fix tests
BryanMLima Jan 27, 2025
84bd297
Fix flipped parameters
Jun 6, 2025
d95c238
Fix NPE while listing hosts for migration when suitableHosts is null
Jun 6, 2025
1eea281
Merge remote-tracking branch 'community/main' into refactor-allocate-…
Jun 6, 2025
94ee342
Remove unnecessary stubbings
Jun 6, 2025
a98abd2
Fix checkstyle
Jun 6, 2025
7496ae4
Remove unnecessary file
BryanMLima Jul 9, 2025
e9ea442
Rename exception error messages
BryanMLima Jul 9, 2025
6a72d99
Merge remote-tracking branch 'origin/main' into refactor-allocate-to-…
BryanMLima Jul 16, 2025
821992e
Apply suggestions from code review
BryanMLima Jul 17, 2025
2b4ce57
Merge remote-tracking branch 'origin/main' into refactor-allocate-to-…
BryanMLima Jul 24, 2025
6b24b2e
Rename UserVmDetailVO references to VMInstanceDetailVO
BryanMLima Jul 24, 2025
6c65b5c
Merge remote-tracking branch 'origin/main' into refactor-allocate-to-…
BryanMLima Aug 1, 2025
85c694f
Remove unused imports
BryanMLima Aug 1, 2025
e153515
Add new line at EOF
BryanMLima Aug 1, 2025
1d8e0e6
Merge remote-tracking branch 'origin/main' into refactor-allocate-to-…
BryanMLima Sep 25, 2025
39a6031
Remove unnecessary random allocator pom
BryanMLima Sep 25, 2025
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 @@ -22,19 +22,11 @@
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
import com.cloud.offering.ServiceOffering;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;

public interface HostAllocator extends Adapter {

/**
* @param UserVm vm
* @param ServiceOffering offering
**/
boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);

/**
* Determines which physical hosts are suitable to
* allocate the guest virtual machines on
Expand All @@ -49,31 +41,6 @@ public interface HostAllocator extends Adapter {

public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo);

/**
* Determines which physical hosts are suitable to allocate the guest
* virtual machines on
*
* Allocators must set any other hosts not considered for allocation in the
* ExcludeList avoid. Thus the avoid set and the list of hosts suitable,
* together must cover the entire host set in the cluster.
*
* @param VirtualMachineProfile
* vmProfile
* @param DeploymentPlan
* plan
* @param GuestType
* type
* @param ExcludeList
* avoid
* @param int returnUpTo (use -1 to return all possible hosts)
* @param boolean considerReservedCapacity (default should be true, set to
* false if host capacity calculation should not look at reserved
* capacity)
* @return List<Host> List of hosts that are suitable for VM allocation
**/

public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity);

/**
* Determines which physical hosts are suitable to allocate the guest
* virtual machines on
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/deploy/DeploymentPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface DeploymentPlanner extends Adapter {
boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeList avoid);

public enum AllocationAlgorithm {
random, firstfit, userdispersing, userconcentratedpod_random, userconcentratedpod_firstfit;
random, firstfit, userdispersing, userconcentratedpod_random, userconcentratedpod_firstfit, firstfitleastconsumed
}

public enum PlannerResourceUsage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void execute() {
for (Host host : result.first()) {
HostForMigrationResponse hostResponse = _responseGenerator.createHostForMigrationResponse(host);
Boolean suitableForMigration = false;
if (hostsWithCapacity.contains(host)) {
if (hostsWithCapacity != null && hostsWithCapacity.contains(host)) {
suitableForMigration = true;
}
hostResponse.setSuitableForMigration(suitableForMigration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected ListResponse<HostResponse> getHostResponses() {
for (Host host : result.first()) {
HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
Boolean suitableForMigration = false;
if (hostsWithCapacity.contains(host)) {
if (hostsWithCapacity != null && hostsWithCapacity.contains(host)) {
suitableForMigration = true;
}
hostResponse.setSuitableForMigration(suitableForMigration);
Expand Down
5 changes: 0 additions & 5 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,6 @@
<artifactId>cloud-plugin-explicit-dedication</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-host-allocator-random</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-outofbandmanagement-driver-ipmitool</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,6 @@ void orchestrateStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> pa
void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
ConcurrentOperationException, OperationTimedoutException;

/**
* Check to see if a virtual machine can be upgraded to the given service offering
*
* @param vm
* @param offering
* @return true if the host can handle the upgrade, false otherwise
*/
boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);

VirtualMachine findById(long vmId);

void storageMigration(String vmUuid, Map<Long, Long> volumeToPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3658,19 +3658,6 @@ protected void runInContext() {
}
}

@Override
public boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering) {
boolean isMachineUpgradable = true;
for (final HostAllocator allocator : hostAllocators) {
isMachineUpgradable = allocator.isVirtualMachineUpgradable(vm, offering);
if (!isMachineUpgradable) {
break;
}
}

return isMachineUpgradable;
}

@Override
public void reboot(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException {
try {
Expand Down Expand Up @@ -4050,11 +4037,6 @@ public void checkIfCanUpgrade(final VirtualMachine vmInstance, final ServiceOffe
throw new InvalidParameterValueException("isSystem property is different for current service offering and new service offering");
}

if (!isVirtualMachineUpgradable(vmInstance, newServiceOffering)) {
throw new InvalidParameterValueException("Unable to upgrade virtual machine, not enough resources available " + "for an offering of " +
newServiceOffering.getCpu() + " cpu(s) at " + newServiceOffering.getSpeed() + " Mhz, and " + newServiceOffering.getRamSize() + " MB of memory");
}

final List<String> currentTags = StringUtils.csvTagsToList(currentDiskOffering.getTags());
final List<String> newTags = StringUtils.csvTagsToList(newDiskOffering.getTags());
if (VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.valueIn(vmInstance.getDataCenterId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int countHostsByMsResourceStateTypeAndHypervisorType(long msId, List<ResourceSta
*/
List<String> listOrderedHostsHypervisorVersionsInDatacenter(long datacenterId, HypervisorType hypervisorType);

List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String computeOfferingTags);
List<HostVO> findHostsWithTagRuleThatMatchComputeOfferingTags(String computeOfferingTags);

List<Long> findClustersThatMatchHostTagRule(String computeOfferingTags);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ private List<Long> findHostIdsByHostTags(String hostTags){
}
}

public List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String computeOfferingTags) {
public List<HostVO> findHostsWithTagRuleThatMatchComputeOfferingTags(String computeOfferingTags) {
List<HostTagVO> hostTagVOList = _hostTagsDao.findHostRuleTags();
List<HostVO> result = new ArrayList<>();
for (HostTagVO rule: hostTagVOList) {
Expand All @@ -1534,7 +1534,7 @@ public List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String comp

public List<Long> findClustersThatMatchHostTagRule(String computeOfferingTags) {
Set<Long> result = new HashSet<>();
List<HostVO> hosts = findHostsWithTagRuleThatMatchComputeOferringTags(computeOfferingTags);
List<HostVO> hosts = findHostsWithTagRuleThatMatchComputeOfferingTags(computeOfferingTags);
for (HostVO host: hosts) {
result.add(host.getClusterId());
}
Expand Down
30 changes: 0 additions & 30 deletions plugins/host-allocators/random/pom.xml

This file was deleted.

This file was deleted.

Loading
Loading