-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow legacy index settings on legacy indices #90264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
35d4a9b
[BWC]Ignore unknown index settings
8cf458d
Add rolling upgrade test
2e63bd0
Fix test bugs.
5c14872
Update docs/changelog/90264.yaml
grcevski 97abce2
Merge branch 'main' into fix/legacy_index_settings
82eaed7
Merge branch 'fix/legacy_index_settings' of github.com:grcevski/elast…
b5fe879
Fix test for BWC > 8.0
ad5669b
WIP: rework to reuse old index settings
837837a
Merge branch 'main' into fix/legacy_index_settings
1a99860
Refactor for use with validators
9dfb706
Remove test code.
fe74090
Use v7 explicitly in version checks.
grcevski 99dc5a7
Use v7 explicitly in setting name.
grcevski 0d86dcd
Merge branch 'main' into fix/legacy_index_settings
b03ad83
Fix compile issues
d7d8e87
WIP: Apply feedback
ebd159b
Finish work on new setting behaviour
1d25759
Add more tests
a6ff3b5
Fix tests
476de2d
Merge branch 'main' into fix/legacy_index_settings
a7948fc
Merge branch 'main' into fix/legacy_index_settings
62a0f18
Simplify compare expressions, add tests.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 90264 | ||
summary: Allow legacy index settings on legacy indices | ||
area: Infra/Core | ||
type: enhancement | ||
issues: | ||
- 84992 |
114 changes: 114 additions & 0 deletions
114
...lling-upgrade/src/test/java/org/elasticsearch/upgrades/UpgradeWithOldIndexSettingsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.common.xcontent.support.XContentMapValues; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class UpgradeWithOldIndexSettingsIT extends AbstractRollingTestCase { | ||
|
||
private static final String INDEX_NAME = "test_index_old_settings"; | ||
private static final String EXPECTED_WARNING = "[index.indexing.slowlog.level] setting was deprecated in Elasticsearch and will " | ||
+ "be removed in a future release! See the breaking changes documentation for the next major version."; | ||
|
||
private static final String EXPECTED_V8_WARNING = "[index.indexing.slowlog.level] setting was deprecated in the previous Elasticsearch" | ||
+ " release and is removed in this release."; | ||
|
||
@SuppressWarnings("unchecked") | ||
public void testOldIndexSettings() throws Exception { | ||
switch (CLUSTER_TYPE) { | ||
case OLD -> { | ||
Request createTestIndex = new Request("PUT", "/" + INDEX_NAME); | ||
createTestIndex.setJsonEntity("{\"settings\": {\"index.indexing.slowlog.level\": \"WARN\"}}"); | ||
createTestIndex.setOptions(expectWarnings(EXPECTED_WARNING)); | ||
if (UPGRADE_FROM_VERSION.before(Version.V_8_0_0)) { | ||
// create index with settings no longer valid in 8.0 | ||
client().performRequest(createTestIndex); | ||
} else { | ||
assertTrue( | ||
expectThrows(ResponseException.class, () -> client().performRequest(createTestIndex)).getMessage() | ||
.contains("unknown setting [index.indexing.slowlog.level]") | ||
); | ||
|
||
Request createTestIndex1 = new Request("PUT", "/" + INDEX_NAME); | ||
client().performRequest(createTestIndex1); | ||
} | ||
|
||
// add some data | ||
Request bulk = new Request("POST", "/_bulk"); | ||
bulk.addParameter("refresh", "true"); | ||
if (UPGRADE_FROM_VERSION.before(Version.V_8_0_0)) { | ||
bulk.setOptions(expectWarnings(EXPECTED_WARNING)); | ||
} | ||
bulk.setJsonEntity(String.format(Locale.ROOT, """ | ||
{"index": {"_index": "%s"}} | ||
{"f1": "v1", "f2": "v2"} | ||
""", INDEX_NAME)); | ||
client().performRequest(bulk); | ||
} | ||
case MIXED -> { | ||
// add some more data | ||
Request bulk = new Request("POST", "/_bulk"); | ||
bulk.addParameter("refresh", "true"); | ||
if (UPGRADE_FROM_VERSION.before(Version.V_8_0_0)) { | ||
bulk.setOptions(expectWarnings(EXPECTED_WARNING)); | ||
} | ||
bulk.setJsonEntity(String.format(Locale.ROOT, """ | ||
{"index": {"_index": "%s"}} | ||
{"f1": "v3", "f2": "v4"} | ||
""", INDEX_NAME)); | ||
client().performRequest(bulk); | ||
} | ||
case UPGRADED -> { | ||
if (UPGRADE_FROM_VERSION.before(Version.V_8_0_0)) { | ||
Request createTestIndex = new Request("PUT", "/" + INDEX_NAME + "/_settings"); | ||
// update index settings should work | ||
createTestIndex.setJsonEntity("{\"index.indexing.slowlog.level\": \"INFO\"}"); | ||
createTestIndex.setOptions(expectWarnings(EXPECTED_V8_WARNING)); | ||
client().performRequest(createTestIndex); | ||
|
||
// ensure we were able to change the setting, despite it having no effect | ||
Request indexSettingsRequest = new Request("GET", "/" + INDEX_NAME + "/_settings"); | ||
Map<String, Object> response = entityAsMap(client().performRequest(indexSettingsRequest)); | ||
|
||
var slowLogLevel = (String) (XContentMapValues.extractValue( | ||
INDEX_NAME + ".settings.index.indexing.slowlog.level", | ||
response | ||
)); | ||
|
||
// check that we can read our old index settings | ||
assertThat(slowLogLevel, is("INFO")); | ||
} | ||
assertCount(INDEX_NAME, 2); | ||
} | ||
} | ||
} | ||
|
||
private void assertCount(String index, int countAtLeast) throws IOException { | ||
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search"); | ||
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true"); | ||
searchTestIndexRequest.addParameter("filter_path", "hits.total"); | ||
Response searchTestIndexResponse = client().performRequest(searchTestIndexRequest); | ||
Map<String, Object> response = entityAsMap(searchTestIndexResponse); | ||
|
||
var hitsTotal = (Integer) (XContentMapValues.extractValue("hits.total", response)); | ||
|
||
assertTrue(hitsTotal >= countAtLeast); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity.
Any particular reason not to use yml test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just my comfort level with writing yml tests, but that definitely means I should add one :). I'll add a yml test too!