Skip to content

Commit 090c1e3

Browse files
hsato03Henrique Sato
andauthored
Improve vm.allocation.algorithm global setting description (#8823)
Co-authored-by: Henrique Sato <[email protected]>
1 parent 31f28f6 commit 090c1e3

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
5757
false,
5858
ConfigKey.Scope.Global);
5959

60+
static final ConfigKey<String> VmAllocationAlgorithm = new ConfigKey<>(
61+
String.class,
62+
"vm.allocation.algorithm",
63+
"Advanced",
64+
"random",
65+
"Order in which hosts within a cluster will be considered for VM/volume allocation. The value can be 'random', 'firstfit', 'userdispersing', 'userconcentratedpod_random', 'userconcentratedpod_firstfit', or 'firstfitleastconsumed'.",
66+
true,
67+
ConfigKey.Scope.Global, null, null, null, null, null,
68+
ConfigKey.Kind.Select,
69+
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed");
70+
6071
/**
6172
* This is called to determine list of possible clusters where a virtual
6273
* machine can be deployed.

server/src/main/java/com/cloud/configuration/Config.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -918,16 +918,6 @@ public enum Config {
918918
"1",
919919
"Weight for user dispersion heuristic (as a value between 0 and 1) applied to resource allocation during vm deployment. Weight for capacity heuristic will be (1 - weight of user dispersion)",
920920
null),
921-
VmAllocationAlgorithm(
922-
"Advanced",
923-
ManagementServer.class,
924-
String.class,
925-
"vm.allocation.algorithm",
926-
"random",
927-
"'random', 'firstfit', 'userdispersing', 'userconcentratedpod_random', 'userconcentratedpod_firstfit', 'firstfitleastconsumed' : Order in which hosts within a cluster will be considered for VM/volume allocation.",
928-
null,
929-
ConfigKey.Kind.Select,
930-
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed"),
931921
VmDeploymentPlanner(
932922
"Advanced",
933923
ManagementServer.class,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeL
567567
@Override
568568
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
569569
super.configure(name, params);
570-
allocationAlgorithm = configDao.getValue(Config.VmAllocationAlgorithm.key());
570+
allocationAlgorithm = VmAllocationAlgorithm.value();
571571
globalDeploymentPlanner = configDao.getValue(Config.VmDeploymentPlanner.key());
572572
String configValue;
573573
if ((configValue = configDao.getValue(Config.ImplicitHostTags.key())) != null) {
@@ -594,6 +594,6 @@ public String getConfigComponentName() {
594594

595595
@Override
596596
public ConfigKey<?>[] getConfigKeys() {
597-
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled};
597+
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm};
598598
}
599599
}

server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public class FirstFitPlannerTest {
151151
public void setUp() {
152152
ConfigKey.init(configDepot);
153153

154+
when(configDepot.global()).thenReturn(configDao);
154155
when(configDao.getValue(Mockito.anyString())).thenReturn(null);
155156
when(configDao.getValue(Config.ImplicitHostTags.key())).thenReturn("GPU");
156157

@@ -242,8 +243,6 @@ public void checkClusterReorderingForStartVMWithThresholdCheckDisabled() throws
242243
}
243244

244245
private List<Long> initializeForClusterThresholdDisabled() {
245-
when(configDepot.global()).thenReturn(configDao);
246-
247246
ConfigurationVO config = mock(ConfigurationVO.class);
248247
when(config.getValue()).thenReturn(String.valueOf(false));
249248
when(configDao.findById(DeploymentClusterPlanner.ClusterThresholdEnabled.key())).thenReturn(config);

0 commit comments

Comments
 (0)