Skip to content

Commit 7877b43

Browse files
committed
Fix validation for drs.imbalance.condensed.skip.threshold
1 parent c108659 commit 7877b43

4 files changed

Lines changed: 16 additions & 25 deletions

File tree

api/src/main/java/org/apache/cloudstack/cluster/ClusterDrsService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public interface ClusterDrsService extends Manager, Configurable, Scheduler {
7878
true, ConfigKey.Scope.Cluster, null, "DRS metric use ratio", null, null, null, ConfigKey.Kind.Select,
7979
"true,false");
8080

81+
ConfigKey<Float> ClusterDrsImbalanceSkipThreshold = new ConfigKey<>(Float.class,
82+
"drs.imbalance.condensed.skip.threshold", ConfigKey.CATEGORY_ADVANCED, "0.95",
83+
"Threshold to ignore the metric for a host while calculating the imbalance to decide " +
84+
"whether DRS is required for a cluster.This is to avoid cases when the calculated imbalance" +
85+
" gets skewed due to a single host having a very high/low metric value resulting in imbalance" +
86+
" being higher than 1. If " + ClusterDrsMetricType.key() + " is 'free', set a lower value and if it is 'used' " +
87+
"set a higher value. The value should be between 0.0 and 1.0",
88+
true, ConfigKey.Scope.Cluster, null, "DRS imbalance skip threshold for Condensed algorithm",
89+
null, null, null);
90+
8191

8292
/**
8393
* Generate a DRS plan for a cluster and save it as per the parameters

plugins/drs/cluster/condensed/src/main/java/org/apache/cloudstack/cluster/Condensed.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,23 @@
2424
import com.cloud.utils.Ternary;
2525
import com.cloud.utils.component.AdapterBase;
2626
import com.cloud.vm.VirtualMachine;
27-
import org.apache.cloudstack.framework.config.ConfigKey;
28-
import org.apache.cloudstack.framework.config.Configurable;
27+
2928

3029
import javax.naming.ConfigurationException;
3130
import java.util.ArrayList;
3231
import java.util.List;
3332
import java.util.Map;
3433

34+
import static org.apache.cloudstack.cluster.ClusterDrsService.ClusterDrsImbalanceSkipThreshold;
3535
import static org.apache.cloudstack.cluster.ClusterDrsService.ClusterDrsImbalanceThreshold;
36-
import static org.apache.cloudstack.cluster.ClusterDrsService.ClusterDrsMetricType;
37-
38-
public class Condensed extends AdapterBase implements ClusterDrsAlgorithm, Configurable {
3936

40-
ConfigKey<Float> ClusterDrsImbalanceSkipThreshold = new ConfigKey<>(Float.class,
41-
"drs.imbalance.condensed.skip.threshold", ConfigKey.CATEGORY_ADVANCED, "0.95",
42-
"Threshold to ignore the metric for a host while calculating the imbalance to decide " +
43-
"whether DRS is required for a cluster.This is to avoid cases when the calculated imbalance" +
44-
" gets skewed due to a single host having a very high/low metric value resulting in imbalance" +
45-
" being higher than 1. If " + ClusterDrsMetricType.key() + " is 'free', set a lower value and if it is 'used' " +
46-
"set a higher value. The value should be between 0.0 and 1.0",
47-
true, ConfigKey.Scope.Cluster, null, "DRS imbalance skip threshold for Condensed algorithm",
48-
null, null, null);
37+
public class Condensed extends AdapterBase implements ClusterDrsAlgorithm {
4938

5039
@Override
5140
public String getName() {
5241
return "condensed";
5342
}
5443

55-
@Override
56-
public String getConfigComponentName() {
57-
return Condensed.class.getSimpleName();
58-
}
59-
60-
@Override
61-
public ConfigKey<?>[] getConfigKeys() {
62-
return new ConfigKey<?>[]{ClusterDrsImbalanceSkipThreshold};
63-
}
64-
6544
@Override
6645
public boolean needsDrs(long clusterId, List<Ternary<Long, Long, Long>> cpuList,
6746
List<Ternary<Long, Long, Long>> memoryList) throws ConfigurationException {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ private void weightBasedParametersForValidation() {
577577
weightBasedParametersForValidation.add(Config.VmUserDispersionWeight.key());
578578
weightBasedParametersForValidation.add(CapacityManager.SecondaryStorageCapacityThreshold.key());
579579
weightBasedParametersForValidation.add(ClusterDrsService.ClusterDrsImbalanceThreshold.key());
580+
weightBasedParametersForValidation.add(ClusterDrsService.ClusterDrsImbalanceSkipThreshold.key());
580581

581582
}
582583

server/src/main/java/org/apache/cloudstack/cluster/ClusterDrsServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ public String getConfigComponentName() {
629629
@Override
630630
public ConfigKey<?>[] getConfigKeys() {
631631
return new ConfigKey<?>[]{ClusterDrsPlanExpireInterval, ClusterDrsEnabled, ClusterDrsInterval, ClusterDrsMaxMigrations,
632-
ClusterDrsAlgorithm, ClusterDrsImbalanceThreshold, ClusterDrsMetric, ClusterDrsMetricType, ClusterDrsMetricUseRatio};
632+
ClusterDrsAlgorithm, ClusterDrsImbalanceThreshold, ClusterDrsMetric, ClusterDrsMetricType, ClusterDrsMetricUseRatio,
633+
ClusterDrsImbalanceSkipThreshold};
633634
}
634635

635636
@Override

0 commit comments

Comments
 (0)