[ML] Cap default model_memory_limit in the ML info API (elastic/x-pack-elasticsearch#4249)

Original commit: elastic/x-pack-elasticsearch@dc614ad370
This commit is contained in:
Dimitris Athanasiou 2018-03-28 16:05:42 +01:00 committed by GitHub
parent df88ba4ed7
commit 00c391602d
2 changed files with 27 additions and 4 deletions

View File

@ -55,13 +55,22 @@ public class TransportMlInfoAction extends HandledTransportAction<MlInfoAction.R
private Map<String, Object> anomalyDetectorsDefaults() { private Map<String, Object> anomalyDetectorsDefaults() {
Map<String, Object> defaults = new HashMap<>(); Map<String, Object> defaults = new HashMap<>();
defaults.put(AnalysisLimits.MODEL_MEMORY_LIMIT.getPreferredName(), defaults.put(AnalysisLimits.MODEL_MEMORY_LIMIT.getPreferredName(), defaultModelMemoryLimit());
new ByteSizeValue(AnalysisLimits.DEFAULT_MODEL_MEMORY_LIMIT_MB, ByteSizeUnit.MB));
defaults.put(AnalysisLimits.CATEGORIZATION_EXAMPLES_LIMIT.getPreferredName(), AnalysisLimits.DEFAULT_CATEGORIZATION_EXAMPLES_LIMIT); defaults.put(AnalysisLimits.CATEGORIZATION_EXAMPLES_LIMIT.getPreferredName(), AnalysisLimits.DEFAULT_CATEGORIZATION_EXAMPLES_LIMIT);
defaults.put(Job.MODEL_SNAPSHOT_RETENTION_DAYS.getPreferredName(), Job.DEFAULT_MODEL_SNAPSHOT_RETENTION_DAYS); defaults.put(Job.MODEL_SNAPSHOT_RETENTION_DAYS.getPreferredName(), Job.DEFAULT_MODEL_SNAPSHOT_RETENTION_DAYS);
return defaults; return defaults;
} }
private ByteSizeValue defaultModelMemoryLimit() {
ByteSizeValue defaultLimit = new ByteSizeValue(AnalysisLimits.DEFAULT_MODEL_MEMORY_LIMIT_MB, ByteSizeUnit.MB);
ByteSizeValue maxModelMemoryLimit = clusterService.getClusterSettings().get(MachineLearningField.MAX_MODEL_MEMORY_LIMIT);
if (maxModelMemoryLimit != null && maxModelMemoryLimit.getBytes() > 0
&& maxModelMemoryLimit.getBytes() < defaultLimit.getBytes()) {
return maxModelMemoryLimit;
}
return defaultLimit;
}
private Map<String, Object> datafeedsDefaults() { private Map<String, Object> datafeedsDefaults() {
Map<String, Object> anomalyDetectorsDefaults = new HashMap<>(); Map<String, Object> anomalyDetectorsDefaults = new HashMap<>();
anomalyDetectorsDefaults.put(DatafeedConfig.SCROLL_SIZE.getPreferredName(), DatafeedConfig.DEFAULT_SCROLL_SIZE); anomalyDetectorsDefaults.put(DatafeedConfig.SCROLL_SIZE.getPreferredName(), DatafeedConfig.DEFAULT_SCROLL_SIZE);

View File

@ -12,7 +12,21 @@
cluster.put_settings: cluster.put_settings:
body: body:
persistent: persistent:
xpack.ml.max_model_memory_limit: "4gb" xpack.ml.max_model_memory_limit: "512mb"
- do:
xpack.ml.info: {}
- match: { defaults.anomaly_detectors.model_memory_limit: "512mb" }
- match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
- match: { defaults.anomaly_detectors.model_snapshot_retention_days: 1 }
- match: { defaults.datafeeds.scroll_size: 1000 }
- match: { limits.max_model_memory_limit: "512mb" }
- do:
cluster.put_settings:
body:
persistent:
xpack.ml.max_model_memory_limit: "6gb"
- do: - do:
xpack.ml.info: {} xpack.ml.info: {}
@ -20,4 +34,4 @@
- match: { defaults.anomaly_detectors.categorization_examples_limit: 4 } - match: { defaults.anomaly_detectors.categorization_examples_limit: 4 }
- match: { defaults.anomaly_detectors.model_snapshot_retention_days: 1 } - match: { defaults.anomaly_detectors.model_snapshot_retention_days: 1 }
- match: { defaults.datafeeds.scroll_size: 1000 } - match: { defaults.datafeeds.scroll_size: 1000 }
- match: { limits.max_model_memory_limit: "4gb" } - match: { limits.max_model_memory_limit: "6gb" }