This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new e0c13cc3ec5 Cleanup userconcentratedpod_random and 
userconcentratedpod_firstfit allocation algorithms (#12233)
e0c13cc3ec5 is described below

commit e0c13cc3ec59d484d6f3e0c8b9d385a68f758804
Author: Manoj Kumar <[email protected]>
AuthorDate: Mon Dec 22 18:55:33 2025 +0530

    Cleanup userconcentratedpod_random and userconcentratedpod_firstfit 
allocation algorithms (#12233)
    
    * Cleanup userconcentratedpod_random and userconcentratedpod_firstfit 
allocation algorithm
    
    * use firstfit instead of random for userconcentratedpod_firstfit
---
 .../java/com/cloud/deploy/DeploymentClusterPlanner.java   |  4 ++--
 api/src/main/java/com/cloud/deploy/DeploymentPlanner.java |  2 +-
 .../orchestration/service/VolumeOrchestrationService.java |  4 ++--
 .../main/java/com/cloud/upgrade/dao/Upgrade410to420.java  |  4 ++--
 .../java/com/cloud/upgrade/dao/Upgrade42210to42300.java   | 15 +++++++++++++++
 .../main/resources/META-INF/db/schema-42210to42300.sql    |  5 +++++
 .../storage/allocator/AbstractStoragePoolAllocator.java   |  2 +-
 .../agent/manager/allocator/impl/FirstFitAllocator.java   |  2 +-
 8 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java 
b/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java
index d127e4bdd66..9471c3d5c84 100644
--- a/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java
+++ b/api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java
@@ -62,11 +62,11 @@ public interface DeploymentClusterPlanner extends 
DeploymentPlanner {
             "vm.allocation.algorithm",
             "Advanced",
             "random",
-            "Order in which hosts within a cluster will be considered for VM 
allocation. The value can be 'random', 'firstfit', 'userdispersing', 
'userconcentratedpod_random', 'userconcentratedpod_firstfit', or 
'firstfitleastconsumed'.",
+            "Order in which hosts within a cluster will be considered for VM 
allocation. The value can be 'random', 'firstfit', 'userdispersing', or 
'firstfitleastconsumed'.",
             true,
             ConfigKey.Scope.Global, null, null, null, null, null,
             ConfigKey.Kind.Select,
-            
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed");
+            "random,firstfit,userdispersing,firstfitleastconsumed");
 
     /**
      * This is called to determine list of possible clusters where a virtual
diff --git a/api/src/main/java/com/cloud/deploy/DeploymentPlanner.java 
b/api/src/main/java/com/cloud/deploy/DeploymentPlanner.java
index 354f9cfaac5..8f7e773070f 100644
--- a/api/src/main/java/com/cloud/deploy/DeploymentPlanner.java
+++ b/api/src/main/java/com/cloud/deploy/DeploymentPlanner.java
@@ -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;
     }
 
     public enum PlannerResourceUsage {
diff --git 
a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
 
b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
index 168822c21eb..6f8c4630456 100644
--- 
a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ 
b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -90,11 +90,11 @@ public interface VolumeOrchestrationService {
             "volume.allocation.algorithm",
             "Advanced",
             "random",
-            "Order in which storage pool within a cluster will be considered 
for volume allocation. The value can be 'random', 'firstfit', 'userdispersing', 
'userconcentratedpod_random', 'userconcentratedpod_firstfit', or 
'firstfitleastconsumed'.",
+            "Order in which storage pool within a cluster will be considered 
for volume allocation. The value can be 'random', 'firstfit', 'userdispersing', 
or 'firstfitleastconsumed'.",
             true,
             ConfigKey.Scope.Global, null, null, null, null, null,
             ConfigKey.Kind.Select,
-            
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed");
+            "random,firstfit,userdispersing,firstfitleastconsumed");
 
     VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long 
destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
         throws ConcurrentOperationException, StorageUnavailableException;
diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade410to420.java 
b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade410to420.java
index 94e6149e73b..a78f93fbdd4 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -1195,9 +1195,9 @@ public class Upgrade410to420 extends 
DbUpgradeAbstractImpl {
                             plannerName = "FirstFitPlanner";
                         } else if 
(globalValue.equals(DeploymentPlanner.AllocationAlgorithm.firstfit.toString())) 
{
                             plannerName = "FirstFitPlanner";
-                        } else if 
(globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_firstfit.toString()))
 {
+                        } else if 
(globalValue.equals("userconcentratedpod_firstfit")) {
                             plannerName = "UserConcentratedPodPlanner";
-                        } else if 
(globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_random.toString()))
 {
+                        } else if 
(globalValue.equals("userconcentratedpod_random")) {
                             plannerName = "UserConcentratedPodPlanner";
                         } else if 
(globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userdispersing.toString()))
 {
                             plannerName = "UserDispersingPlanner";
diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java 
b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
index cb87e730f83..df4743894c9 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
@@ -16,6 +16,10 @@
 // under the License.
 package com.cloud.upgrade.dao;
 
+import java.io.InputStream;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
 public class Upgrade42210to42300 extends DbUpgradeAbstractImpl implements 
DbUpgrade, DbUpgradeSystemVmTemplate {
 
     @Override
@@ -27,4 +31,15 @@ public class Upgrade42210to42300 extends 
DbUpgradeAbstractImpl implements DbUpgr
     public String getUpgradedVersion() {
         return "4.23.0.0";
     }
+
+    @Override
+    public InputStream[] getPrepareScripts() {
+        final String scriptFile = "META-INF/db/schema-42210to42300.sql";
+        final InputStream script = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
+        if (script == null) {
+            throw new CloudRuntimeException("Unable to find " + scriptFile);
+        }
+
+        return new InputStream[] {script};
+    }
 }
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql
index 7024368a1d5..01d528f4a92 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql
@@ -18,3 +18,8 @@
 --;
 -- Schema upgrade from 4.22.1.0 to 4.23.0.0
 --;
+
+-- Update value to random for the config 'vm.allocation.algorithm' or 
'volume.allocation.algorithm' if configured as userconcentratedpod_random
+-- Update value to firstfit for the config 'vm.allocation.algorithm' or 
'volume.allocation.algorithm' if configured as userconcentratedpod_firstfit
+UPDATE `cloud`.`configuration` SET value='random' WHERE name IN 
('vm.allocation.algorithm', 'volume.allocation.algorithm') AND 
value='userconcentratedpod_random';
+UPDATE `cloud`.`configuration` SET value='firstfit' WHERE name IN 
('vm.allocation.algorithm', 'volume.allocation.algorithm') AND 
value='userconcentratedpod_firstfit';
diff --git 
a/engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
 
b/engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
index e0e244d53d3..cd9ab3adb21 100644
--- 
a/engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
+++ 
b/engine/storage/src/main/java/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
@@ -241,7 +241,7 @@ public abstract class AbstractStoragePoolAllocator extends 
AdapterBase implement
     List<StoragePool> reorderStoragePoolsBasedOnAlgorithm(List<StoragePool> 
pools, DeploymentPlan plan, Account account) {
         String volumeAllocationAlgorithm = 
VolumeOrchestrationService.VolumeAllocationAlgorithm.value();
         logger.debug("Using volume allocation algorithm {} to reorder pools.", 
volumeAllocationAlgorithm);
-        if (volumeAllocationAlgorithm.equals("random") || 
volumeAllocationAlgorithm.equals("userconcentratedpod_random") || (account == 
null)) {
+        if (volumeAllocationAlgorithm.equals("random") || (account == null)) {
             reorderRandomPools(pools);
         } else if (StringUtils.equalsAny(volumeAllocationAlgorithm, 
"userdispersing", "firstfitleastconsumed")) {
             if (logger.isTraceEnabled()) {
diff --git 
a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
 
b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index 85baf1b580b..1110804959e 100644
--- 
a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ 
b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -298,7 +298,7 @@ public class FirstFitAllocator extends AdapterBase 
implements HostAllocator {
     protected List<Host> allocateTo(VirtualMachineProfile vmProfile, 
DeploymentPlan plan, ServiceOffering offering, VMTemplateVO template, 
ExcludeList avoid, List<? extends Host> hosts, int returnUpTo,
         boolean considerReservedCapacity, Account account) {
         String vmAllocationAlgorithm = 
DeploymentClusterPlanner.VmAllocationAlgorithm.value();
-        if (vmAllocationAlgorithm.equals("random") || 
vmAllocationAlgorithm.equals("userconcentratedpod_random")) {
+        if (vmAllocationAlgorithm.equals("random")) {
             // Shuffle this so that we don't check the hosts in the same order.
             Collections.shuffle(hosts);
         } else if (vmAllocationAlgorithm.equals("userdispersing")) {

Reply via email to