Skip to content

Commit 34586d5

Browse files
authored
[ML] adds latest record timestamp to model snapshot deprecation warning (#73066) (#73213)
This adds the latest record timestamp of the deprecated model snapshot in the warning. This hopefully gives the user a better view into whether they would want to delete the snapshot or to upgrade it.
1 parent fdc0601 commit 34586d5

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.ActionListener;
1212
import org.elasticsearch.common.settings.Settings;
1313
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
14+
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
1415
import org.elasticsearch.xpack.core.XPackSettings;
1516
import org.elasticsearch.xpack.core.action.util.PageParams;
1617
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
@@ -53,6 +54,20 @@ static Optional<DeprecationIssue> checkDataFeedAggregations(DatafeedConfig dataf
5354

5455
static Optional<DeprecationIssue> checkModelSnapshot(ModelSnapshot modelSnapshot) {
5556
if (modelSnapshot.getMinVersion().before(Version.V_7_0_0)) {
57+
StringBuilder details = new StringBuilder(String.format(
58+
Locale.ROOT,
59+
"model snapshot [%s] for job [%s] supports minimum version [%s] and needs to be at least [%s].",
60+
modelSnapshot.getSnapshotId(),
61+
modelSnapshot.getJobId(),
62+
modelSnapshot.getMinVersion(),
63+
Version.V_7_0_0));
64+
if (modelSnapshot.getLatestRecordTimeStamp() != null) {
65+
details.append(String.format(
66+
Locale.ROOT,
67+
" The model snapshot's latest record timestamp is [%s]",
68+
XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(modelSnapshot.getLatestRecordTimeStamp().getTime())
69+
));
70+
}
5671
return Optional.of(new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
5772
String.format(
5873
Locale.ROOT,
@@ -61,15 +76,9 @@ static Optional<DeprecationIssue> checkModelSnapshot(ModelSnapshot modelSnapshot
6176
modelSnapshot.getJobId()
6277
),
6378
"https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-upgrade-job-model-snapshot.html",
64-
String.format(
65-
Locale.ROOT,
66-
"model snapshot [%s] for job [%s] supports minimum version [%s] and needs to be at least [%s]",
67-
modelSnapshot.getSnapshotId(),
68-
modelSnapshot.getJobId(),
69-
modelSnapshot.getMinVersion(),
70-
Version.V_7_0_0
79+
details.toString()
7180
)
72-
));
81+
);
7382
}
7483
return Optional.empty();
7584
}

0 commit comments

Comments
 (0)