Skip to content

Commit 3ec2ed6

Browse files
author
Daniel Augusto Veronezi Salvador
committed
Use default value as threshold when config value is lower than 0.0
1 parent c6649da commit 3ec2ed6

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

server/src/main/java/com/cloud/server/StatsCollector.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146

147147
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
148148
import org.apache.commons.io.FileUtils;
149+
import org.apache.commons.lang3.math.NumberUtils;
149150

150151
/**
151152
* Provides real time stats for various agent resources up to x seconds
@@ -1625,16 +1626,27 @@ public ConfigKey<?>[] getConfigKeys() {
16251626
}
16261627

16271628
public double getImageStoreCapacityThreshold() {
1628-
double thresholdConfig = secondaryStorageCapacityThreshold.value();
1629+
double thresholdConfigValue = secondaryStorageCapacityThreshold.value();
1630+
double thresholdConfigDefaultValue = NumberUtils.toDouble(secondaryStorageCapacityThreshold.defaultValue());
1631+
String thresholdConfigKey = secondaryStorageCapacityThreshold.key();
16291632

1630-
if (thresholdConfig >= MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD && thresholdConfig <= MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD) {
1631-
return thresholdConfig;
1633+
if (thresholdConfigValue >= MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD && thresholdConfigValue <= MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD) {
1634+
return thresholdConfigValue;
16321635
}
16331636

1634-
s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is [%s]. Assuming %s as secondary storage capacity threshold.",
1635-
secondaryStorageCapacityThreshold.key(),
1636-
thresholdConfig,
1637-
thresholdConfig < MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD ? String.format("lower than '%s'", MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD) : String.format("bigger than '%s'", MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD),
1637+
if (thresholdConfigValue < MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD) {
1638+
s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is lower than '%s'. Assuming '%s', default value, as secondary storage capacity threshold.",
1639+
thresholdConfigKey,
1640+
thresholdConfigValue,
1641+
MIN_STORAGE_SECONDARY_CAPACITY_THRESHOLD,
1642+
thresholdConfigDefaultValue));
1643+
return thresholdConfigDefaultValue;
1644+
}
1645+
1646+
s_logger.warn(String.format("Invalid [%s] configuration: value set [%s] is bigger than '%s'. Assuming '%s', top limit, as secondary storage capacity threshold.",
1647+
thresholdConfigKey,
1648+
thresholdConfigValue,
1649+
MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD,
16381650
MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD));
16391651
return MAX_STORAGE_SECONDARY_CAPACITY_THRESHOLD;
16401652
}

0 commit comments

Comments
 (0)