Skip to content

Commit

Permalink
[ML] Uplift model memory limit on job migration (#37125)
Browse files Browse the repository at this point in the history
When a 6.1-6.3 job is opened in a later version
we increase the model memory limit by 30% if it's
below 0.5GB. The migration of jobs from cluster
state to the config index changes the job version,
so we need to also do this uplift as part of that
config migration.

Relates #36961
  • Loading branch information
droberts195 committed Jan 4, 2019
1 parent fbb997f commit 58de97d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.elasticsearch.xpack.core.ml.MlMetadata;
import org.elasticsearch.xpack.core.ml.MlTasks;
import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig;
import org.elasticsearch.xpack.core.ml.job.config.AnalysisLimits;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
import org.elasticsearch.xpack.core.ml.job.persistence.ElasticsearchMappings;
Expand Down Expand Up @@ -403,11 +404,23 @@ public static Job updateJobForMigration(Job job) {
Map<String, Object> custom = job.getCustomSettings() == null ? new HashMap<>() : new HashMap<>(job.getCustomSettings());
custom.put(MIGRATED_FROM_VERSION, job.getJobVersion());
builder.setCustomSettings(custom);
// Increase the model memory limit for 6.1 - 6.3 jobs
Version jobVersion = job.getJobVersion();
if (jobVersion != null && jobVersion.onOrAfter(Version.V_6_1_0) && jobVersion.before(Version.V_6_3_0)) {
// Increase model memory limit if < 512MB
if (job.getAnalysisLimits() != null && job.getAnalysisLimits().getModelMemoryLimit() != null &&
job.getAnalysisLimits().getModelMemoryLimit() < 512L) {
long updatedModelMemoryLimit = (long) (job.getAnalysisLimits().getModelMemoryLimit() * 1.3);
AnalysisLimits limits = new AnalysisLimits(updatedModelMemoryLimit,
job.getAnalysisLimits().getCategorizationExamplesLimit());
builder.setAnalysisLimits(limits);
}
}
// Pre v5.5 (ml beta) jobs do not have a version.
// These jobs cannot be opened, we rely on the missing version
// to indicate this.
// See TransportOpenJobAction.validate()
if (job.getJobVersion() != null) {
if (jobVersion != null) {
builder.setJobVersion(Version.CURRENT);
}
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ setup:

---
"Test model memory limit is updated":
- skip:
version: "all"
reason: "@AwaitsFix: https://github.com/elastic/elasticsearch/issues/36961"

# Jobs created in 6.1.x and 6.2.x underestimated the necessary model memory
# limit, check the limit has been updated.
# Opening the job updates the limit
Expand Down

0 comments on commit 58de97d

Please sign in to comment.