Skip to content

Commit b6cf74c

Browse files
authored
[ML] Fix acceptable model snapshot versions in ML deprecation checker (#81060) (#81101)
This is a followup to #81039. The same requirement to tolerate model snapshots back to 6.4.0 that applies to the job opening code also applies to the deprecation checker. Again, we tell the user that 7.0.0 is the model snapshot version we support, but we actually have to support versions going back to 6.4.0 because we didn't update the constant in the C++ in 7.0.0. Additionally, the wording of the ML deprecation messages is very slightly updated. The messages are different in the 7.16 branch, where they were updated by #79387. This wording is copied forward to master, but with the tiny change that "Snapshot" is changed to "Model snapshot" in one place. This should make it clearer for users that we're talking about ML model snapshots and not cluster snapshots (which are completely different things). Another reason to change the wording is that the UI is looking for the pattern /[Mm]odel snapshot/ to decide when to display the "Fix" button for upgrading ML model snapshots - see elastic/kibana#119745.
1 parent ab2cd90 commit b6cf74c

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MachineLearningField.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.xpack.core.ml;
88

9+
import org.elasticsearch.Version;
910
import org.elasticsearch.common.Numbers;
1011
import org.elasticsearch.common.hash.MurmurHash3;
1112
import org.elasticsearch.common.settings.Setting;
@@ -44,6 +45,13 @@ public final class MachineLearningField {
4445
License.OperationMode.PLATINUM
4546
);
4647

48+
// Ideally this would be 7.0.0, but it has to be 6.4.0 because due to an oversight it's impossible
49+
// for the Java code to distinguish the model states for versions 6.4.0 to 7.9.3 inclusive.
50+
public static final Version MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION = Version.fromString("6.4.0");
51+
// We tell the user we support model snapshots newer than 7.0.0 as that's the major version
52+
// boundary, even though behind the scenes we have to support back to 6.4.0.
53+
public static final Version MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION = Version.V_7_0_0;
54+
4755
private MachineLearningField() {}
4856

4957
public static String valuesToId(String... values) {

x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/MlDeprecationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void testMlDeprecationChecks() throws Exception {
105105
assertThat(response.getMlSettingsIssues(), hasSize(1));
106106
assertThat(
107107
response.getMlSettingsIssues().get(0).getMessage(),
108-
containsString("model snapshot [1] for job [deprecation_check_job] needs to be deleted or upgraded")
108+
containsString("Delete model snapshot [1] or update it to 7.0.0 or greater")
109109
);
110110
assertThat(response.getMlSettingsIssues().get(0).getMeta(), equalTo(Map.of("job_id", jobId, "snapshot_id", "1")));
111111
}

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/MlDeprecationChecker.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.deprecation;
99

10-
import org.elasticsearch.Version;
1110
import org.elasticsearch.action.ActionListener;
1211
import org.elasticsearch.common.settings.Settings;
1312
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
@@ -27,6 +26,9 @@
2726
import java.util.Map;
2827
import java.util.Optional;
2928

29+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION;
30+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION;
31+
3032
public class MlDeprecationChecker implements DeprecationChecker {
3133

3234
static Optional<DeprecationIssue> checkDataFeedQuery(DatafeedConfig datafeedConfig, NamedXContentRegistry xContentRegistry) {
@@ -67,22 +69,23 @@ static Optional<DeprecationIssue> checkDataFeedAggregations(DatafeedConfig dataf
6769
}
6870

6971
static Optional<DeprecationIssue> checkModelSnapshot(ModelSnapshot modelSnapshot) {
70-
if (modelSnapshot.getMinVersion().before(Version.V_7_0_0)) {
72+
if (modelSnapshot.getMinVersion().before(MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION)) {
7173
StringBuilder details = new StringBuilder(
7274
String.format(
7375
Locale.ROOT,
74-
"model snapshot [%s] for job [%s] supports minimum version [%s] and needs to be at least [%s].",
76+
// Important: the Kibana upgrade assistant expects this to match the pattern /[Mm]odel snapshot/
77+
// and if it doesn't then the expected "Fix" button won't appear for this deprecation.
78+
"Model snapshot [%s] for job [%s] has an obsolete minimum version [%s].",
7579
modelSnapshot.getSnapshotId(),
7680
modelSnapshot.getJobId(),
77-
modelSnapshot.getMinVersion(),
78-
Version.V_7_0_0
81+
modelSnapshot.getMinVersion()
7982
)
8083
);
8184
if (modelSnapshot.getLatestRecordTimeStamp() != null) {
8285
details.append(
8386
String.format(
8487
Locale.ROOT,
85-
" The model snapshot's latest record timestamp is [%s]",
88+
" The model snapshot's latest record timestamp is [%s].",
8689
XContentElasticsearchExtension.DEFAULT_FORMATTER.format(modelSnapshot.getLatestRecordTimeStamp().toInstant())
8790
)
8891
);
@@ -92,9 +95,9 @@ static Optional<DeprecationIssue> checkModelSnapshot(ModelSnapshot modelSnapshot
9295
DeprecationIssue.Level.CRITICAL,
9396
String.format(
9497
Locale.ROOT,
95-
"model snapshot [%s] for job [%s] needs to be deleted or upgraded",
98+
"Delete model snapshot [%s] or update it to %s or greater.",
9699
modelSnapshot.getSnapshotId(),
97-
modelSnapshot.getJobId()
100+
MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION
98101
),
99102
"https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-upgrade-job-model-snapshot.html",
100103
details.toString(),

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
import java.util.function.Predicate;
5555

5656
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
57-
import static org.elasticsearch.xpack.ml.job.task.OpenJobPersistentTasksExecutor.MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION;
58-
import static org.elasticsearch.xpack.ml.job.task.OpenJobPersistentTasksExecutor.MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION;
57+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION;
58+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION;
5959
import static org.elasticsearch.xpack.ml.job.task.OpenJobPersistentTasksExecutor.checkAssignmentState;
6060

6161
/*

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/task/OpenJobPersistentTasksExecutor.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,15 @@
6767

6868
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
6969
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
70+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION;
71+
import static org.elasticsearch.xpack.core.ml.MachineLearningField.MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION;
7072
import static org.elasticsearch.xpack.core.ml.MlTasks.AWAITING_UPGRADE;
7173
import static org.elasticsearch.xpack.core.ml.MlTasks.PERSISTENT_TASK_MASTER_NODE_TIMEOUT;
7274
import static org.elasticsearch.xpack.ml.job.JobNodeSelector.AWAITING_LAZY_ASSIGNMENT;
7375

7476
public class OpenJobPersistentTasksExecutor extends AbstractJobPersistentTasksExecutor<OpenJobAction.JobParams> {
7577

7678
private static final Logger logger = LogManager.getLogger(OpenJobPersistentTasksExecutor.class);
77-
// Ideally this would be 7.0.0, but it has to be 6.4.0 because due to an oversight it's impossible
78-
// for the Java code to distinguish the model states for versions 6.4.0 to 7.9.3 inclusive.
79-
public static final Version MIN_CHECKED_SUPPORTED_SNAPSHOT_VERSION = Version.fromString("6.4.0");
80-
// We tell the user we support model snapshots newer than 7.0.0 as that's the major version
81-
// boundary, even though behind the scenes we have to support back to 6.4.0.
82-
public static final Version MIN_REPORTED_SUPPORTED_SNAPSHOT_VERSION = Version.V_7_0_0;
8379

8480
// Resuming a job with a running datafeed from its current snapshot was added in 7.11 and
8581
// can only be done if the master node is on or after that version.

0 commit comments

Comments
 (0)