[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:
parent
df88ba4ed7
commit
00c391602d
|
@ -55,13 +55,22 @@ public class TransportMlInfoAction extends HandledTransportAction<MlInfoAction.R
|
|||
|
||||
private Map<String, Object> anomalyDetectorsDefaults() {
|
||||
Map<String, Object> defaults = new HashMap<>();
|
||||
defaults.put(AnalysisLimits.MODEL_MEMORY_LIMIT.getPreferredName(),
|
||||
new ByteSizeValue(AnalysisLimits.DEFAULT_MODEL_MEMORY_LIMIT_MB, ByteSizeUnit.MB));
|
||||
defaults.put(AnalysisLimits.MODEL_MEMORY_LIMIT.getPreferredName(), defaultModelMemoryLimit());
|
||||
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);
|
||||
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() {
|
||||
Map<String, Object> anomalyDetectorsDefaults = new HashMap<>();
|
||||
anomalyDetectorsDefaults.put(DatafeedConfig.SCROLL_SIZE.getPreferredName(), DatafeedConfig.DEFAULT_SCROLL_SIZE);
|
||||
|
|
|
@ -12,7 +12,21 @@
|
|||
cluster.put_settings:
|
||||
body:
|
||||
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:
|
||||
xpack.ml.info: {}
|
||||
|
@ -20,4 +34,4 @@
|
|||
- 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: "4gb" }
|
||||
- match: { limits.max_model_memory_limit: "6gb" }
|
||||
|
|
Loading…
Reference in New Issue