Skip to content

Commit

Permalink
Use getMaxDataNodeCompatibleIndexVersion() in LogsdbIndexModeSettings…
Browse files Browse the repository at this point in the history
…Provider (elastic#120123)

This matches with the version being used when actually creating the index in cluster state on elected master node.
Avoids creating `MappingService` instance in `LogsdbIndexModeSettingsProvider ` with settings that aren't supported with minimum support index version.

Co-authored-by: Kostas Krikellas <[email protected]>
  • Loading branch information
martijnvg and kkrik-es committed Jan 16, 2025
1 parent b076249 commit 8d6db8f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,57 @@ public void testLogsdbRouteOnSortFields() throws IOException {
assertEquals("true", settings.get(IndexSettings.LOGSDB_ROUTE_ON_SORT_FIELDS.getKey()));
assertEquals(List.of("host.name", "message"), settings.get(IndexMetadata.INDEX_ROUTING_PATH.getKey()));
}

public void testLogsdbDefaultWithRecoveryUseSyntheticSource() throws IOException {
Request request = new Request("PUT", "/_cluster/settings");
request.setJsonEntity("{ \"transient\": { \"cluster.logsdb.enabled\": true } }");
assertOK(client().performRequest(request));

request = new Request("POST", "/_index_template/1");
request.setJsonEntity("""
{
"index_patterns": ["my-log-*"],
"data_stream": {
},
"template": {
"settings":{
"index": {
"mode": "logsdb",
"recovery.use_synthetic_source" : "true"
}
},
"mappings": {
"properties": {
"@timestamp" : {
"type": "date"
},
"host.name": {
"type": "keyword"
},
"message": {
"type": "keyword"
}
}
}
}
}
""");
assertOK(client().performRequest(request));

request = new Request("POST", "/my-log-foo/_doc");
request.setJsonEntity("""
{
"@timestamp": "2020-01-01T00:00:00.000Z",
"host.name": "foo",
"message": "bar"
}
""");
assertOK(client().performRequest(request));

String index = DataStream.getDefaultBackingIndexName("my-log-foo", 1);
var settings = (Map<?, ?>) ((Map<?, ?>) getIndexSettings(index).get(index)).get("settings");
assertEquals("logsdb", settings.get("index.mode"));
assertNull(settings.get("index.mapping.source.mode"));
assertEquals("true", settings.get(IndexSettings.LOGSDB_SORT_ON_HOST_NAME.getKey()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ MappingHints getMappingHints(
// In case invalid mappings or setting are provided, then mapper service creation can fail.
// In that case it is ok to return false here. The index creation will fail anyway later, so no need to fallback to stored
// source.
LOGGER.info(() -> Strings.format("unable to create mapper service for index [%s]", indexName), e);
LOGGER.warn(() -> Strings.format("unable to create mapper service for index [%s]", indexName), e);
return MappingHints.EMPTY;
}
}
Expand Down

0 comments on commit 8d6db8f

Please sign in to comment.