From 7ed7655d52d6dfefa6e64b7e3c89a8f32fb2e51d Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 7 Feb 2025 17:12:20 +0200 Subject: [PATCH 1/5] Adjust details in the SourceFieldMapper deprecation warning --- .../org/elasticsearch/index/mapper/SourceFieldMapper.java | 4 +++- .../xpack/deprecation/TemplateDeprecationChecker.java | 2 +- .../xpack/deprecation/TemplateDeprecationCheckerTests.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index a6cb5561f2e7b..b0069e45e1673 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -58,7 +58,9 @@ public class SourceFieldMapper extends MetadataFieldMapper { public static final String LOSSY_PARAMETERS_ALLOWED_SETTING_NAME = "index.lossy.source-mapping-parameters"; - public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated and will be removed " + public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated."; + + public static final String DEPRECATION_DETAILS = "Configuring source mode in mappings is deprecated and will be removed " + "in future versions. Use [index.mapping.source.mode] index setting instead."; /** The source mode */ diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java index d68e31a1fde4e..8aaa3ba980a54 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java @@ -124,7 +124,7 @@ private DeprecationIssue checkSourceModeInComponentTemplates(ComponentTemplate t DeprecationIssue.Level.CRITICAL, SourceFieldMapper.DEPRECATION_WARNING, "https://github.com/elastic/elasticsearch/pull/117172", - null, + SourceFieldMapper.DEPRECATION_DETAILS, false, null ); diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java index 69bb396a50a91..a08b58a22f7e8 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java @@ -53,7 +53,7 @@ public void testCheckSourceModeInComponentTemplates() throws IOException { DeprecationIssue.Level.CRITICAL, SourceFieldMapper.DEPRECATION_WARNING, "https://github.com/elastic/elasticsearch/pull/117172", - null, + SourceFieldMapper.DEPRECATION_DETAILS, false, null ); From bb380106a6503d845213d2e06ff971d2c471f5b9 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 7 Feb 2025 17:21:41 +0200 Subject: [PATCH 2/5] Use an alias link to allow us to provide a proper guide soon. --- .../xpack/deprecation/TemplateDeprecationChecker.java | 2 +- .../xpack/deprecation/TemplateDeprecationCheckerTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java index 8aaa3ba980a54..dc7ee008ab39e 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java @@ -123,7 +123,7 @@ private DeprecationIssue checkSourceModeInComponentTemplates(ComponentTemplate t return new DeprecationIssue( DeprecationIssue.Level.CRITICAL, SourceFieldMapper.DEPRECATION_WARNING, - "https://github.com/elastic/elasticsearch/pull/117172", + "https://ela.st/migrate-source-mode", SourceFieldMapper.DEPRECATION_DETAILS, false, null diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java index a08b58a22f7e8..998a0a01996df 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java @@ -52,7 +52,7 @@ public void testCheckSourceModeInComponentTemplates() throws IOException { final DeprecationIssue expected = new DeprecationIssue( DeprecationIssue.Level.CRITICAL, SourceFieldMapper.DEPRECATION_WARNING, - "https://github.com/elastic/elasticsearch/pull/117172", + "https://ela.st/migrate-source-mode", SourceFieldMapper.DEPRECATION_DETAILS, false, null From 3a90357e0bf3569674e8100584e9d5a464aa5129 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 7 Feb 2025 17:30:17 +0200 Subject: [PATCH 3/5] Keep the deprecation warning and introduce a title. --- .../elasticsearch/upgrades/SourceModeRollingUpgradeIT.java | 7 ++++--- .../org/elasticsearch/index/mapper/SourceFieldMapper.java | 4 ++-- .../xpack/deprecation/TemplateDeprecationChecker.java | 4 ++-- .../xpack/deprecation/TemplateDeprecationCheckerTests.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java index 8bf870edc5ec8..912a872c94dfa 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java @@ -46,7 +46,7 @@ public void testConfigureStoredSourceBeforeIndexCreationLegacy() throws IOExcept } }"""; var putComponentTemplateRequest = new Request("PUT", "/_component_template/" + templateName); - putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING)); + putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); putComponentTemplateRequest.setJsonEntity(storedSourceMapping); assertOK(client().performRequest(putComponentTemplateRequest)); assertDeprecationWarningForTemplate(templateName); @@ -70,7 +70,7 @@ public void testConfigureStoredSourceWhenIndexIsCreatedLegacy() throws IOExcepti } }"""; var putComponentTemplateRequest = new Request("PUT", "/_component_template/" + templateName); - putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING)); + putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); putComponentTemplateRequest.setJsonEntity(storedSourceMapping); assertOK(client().performRequest(putComponentTemplateRequest)); assertDeprecationWarningForTemplate(templateName); @@ -86,6 +86,7 @@ private void assertDeprecationWarningForTemplate(String templateName) throws IOE Map issuesByTemplate = (Map) response.get("templates"); assertThat(issuesByTemplate.containsKey(templateName), equalTo(true)); var templateIssues = (List) issuesByTemplate.get(templateName); - assertThat(((Map) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); + assertThat(((Map) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); + assertThat(((Map) templateIssues.getFirst()).get("details"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index b0069e45e1673..5ee7ee2ae9bf0 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -58,9 +58,9 @@ public class SourceFieldMapper extends MetadataFieldMapper { public static final String LOSSY_PARAMETERS_ALLOWED_SETTING_NAME = "index.lossy.source-mapping-parameters"; - public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated."; + public static final String DEPRECATION_WARNING_TITLE = "Configuring source mode in mappings is deprecated."; - public static final String DEPRECATION_DETAILS = "Configuring source mode in mappings is deprecated and will be removed " + public static final String DEPRECATION_WARNING = "Configuring source mode in mappings is deprecated and will be removed " + "in future versions. Use [index.mapping.source.mode] index setting instead."; /** The source mode */ diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java index dc7ee008ab39e..ff0ff982d11bf 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationChecker.java @@ -122,9 +122,9 @@ private DeprecationIssue checkSourceModeInComponentTemplates(ComponentTemplate t if (sourceMap.containsKey("mode")) { return new DeprecationIssue( DeprecationIssue.Level.CRITICAL, - SourceFieldMapper.DEPRECATION_WARNING, + SourceFieldMapper.DEPRECATION_WARNING_TITLE, "https://ela.st/migrate-source-mode", - SourceFieldMapper.DEPRECATION_DETAILS, + SourceFieldMapper.DEPRECATION_WARNING, false, null ); diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java index 998a0a01996df..4e1b28b341282 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TemplateDeprecationCheckerTests.java @@ -51,9 +51,9 @@ public void testCheckSourceModeInComponentTemplates() throws IOException { Map> issuesByComponentTemplate = checker.check(clusterState); final DeprecationIssue expected = new DeprecationIssue( DeprecationIssue.Level.CRITICAL, - SourceFieldMapper.DEPRECATION_WARNING, + SourceFieldMapper.DEPRECATION_WARNING_TITLE, "https://ela.st/migrate-source-mode", - SourceFieldMapper.DEPRECATION_DETAILS, + SourceFieldMapper.DEPRECATION_WARNING, false, null ); From 2f5affc70190930292c45553d47c32073e8f106e Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 7 Feb 2025 17:33:11 +0200 Subject: [PATCH 4/5] Use the correct warning --- .../elasticsearch/upgrades/SourceModeRollingUpgradeIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java index 912a872c94dfa..06be9cdeaf1da 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java @@ -46,7 +46,7 @@ public void testConfigureStoredSourceBeforeIndexCreationLegacy() throws IOExcept } }"""; var putComponentTemplateRequest = new Request("PUT", "/_component_template/" + templateName); - putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); + putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING)); putComponentTemplateRequest.setJsonEntity(storedSourceMapping); assertOK(client().performRequest(putComponentTemplateRequest)); assertDeprecationWarningForTemplate(templateName); @@ -70,7 +70,7 @@ public void testConfigureStoredSourceWhenIndexIsCreatedLegacy() throws IOExcepti } }"""; var putComponentTemplateRequest = new Request("PUT", "/_component_template/" + templateName); - putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); + putComponentTemplateRequest.setOptions(expectWarnings(SourceFieldMapper.DEPRECATION_WARNING)); putComponentTemplateRequest.setJsonEntity(storedSourceMapping); assertOK(client().performRequest(putComponentTemplateRequest)); assertDeprecationWarningForTemplate(templateName); From 3947328a2fe6b9e15c80d8b6764eac705b9c9576 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 7 Feb 2025 18:45:03 +0200 Subject: [PATCH 5/5] Add bwc assertions until the backports are completed. --- .../upgrades/SourceModeRollingUpgradeIT.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java index 06be9cdeaf1da..55a03da7c9e90 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java @@ -85,8 +85,13 @@ private void assertDeprecationWarningForTemplate(String templateName) throws IOE assertThat(response.containsKey("templates"), equalTo(true)); Map issuesByTemplate = (Map) response.get("templates"); assertThat(issuesByTemplate.containsKey(templateName), equalTo(true)); - var templateIssues = (List) issuesByTemplate.get(templateName); - assertThat(((Map) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); - assertThat(((Map) templateIssues.getFirst()).get("details"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); + var templateIssue = (Map) ((List) issuesByTemplate.get(templateName)).getFirst(); + // Bwc compatible logic until backports are complete. + if (templateIssue.containsKey("details")) { + assertThat(templateIssue.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING_TITLE)); + assertThat(templateIssue.get("details"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); + } else { + assertThat(templateIssue.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING)); + } } }