Skip to content

Commit 7ef83eb

Browse files
[7.x][ML] Do not add runtime section to DFA dest index mappings unnecessarily (#69329) (#69332)
Since config runtime mappings were added to data frame analytics jobs in #69183, when we create the destination index we add a `runtime` section in its mappings regardless of whether the job config contains any runtime fields. This causes failures in the BWC tests when in a mixed cluster where there are nodes versioned before runtime fields were introduced. This is the first part of the fix were we do not create a `runtime` section in the destination index mappings unless necessary. Backport of #69329
1 parent 12e2cc8 commit 7ef83eb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ private static CreateIndexRequest createIndexRequest(Clock clock,
190190
properties.putAll(createAdditionalMappings(config, fieldCapabilitiesResponse));
191191
Map<String, Object> metadata = getOrPutDefault(mappingsAsMap, META, HashMap::new);
192192
metadata.putAll(createMetadata(config.getId(), clock, Version.CURRENT));
193-
Map<String, Object> runtimeMappings = getOrPutDefault(mappingsAsMap, RUNTIME, HashMap::new);
194-
runtimeMappings.putAll(config.getSource().getRuntimeMappings());
193+
if (config.getSource().getRuntimeMappings().isEmpty() == false) {
194+
Map<String, Object> runtimeMappings = getOrPutDefault(mappingsAsMap, RUNTIME, HashMap::new);
195+
runtimeMappings.putAll(config.getSource().getRuntimeMappings());
196+
}
195197
return new CreateIndexRequest(destinationIndex, settings).mapping(type, mappingsAsMap);
196198
}
197199

@@ -281,8 +283,11 @@ public static void updateMappingsToDestIndex(Client client,
281283

282284
// Determine mappings to be added to the destination index
283285
addedMappings.put(PROPERTIES, createAdditionalMappings(config, fieldCapabilitiesResponse));
286+
284287
// Also add runtime mappings
285-
addedMappings.put(RUNTIME, config.getSource().getRuntimeMappings());
288+
if (config.getSource().getRuntimeMappings().isEmpty() == false) {
289+
addedMappings.put(RUNTIME, config.getSource().getRuntimeMappings());
290+
}
286291

287292
// Add the mappings to the destination index
288293
PutMappingRequest putMappingRequest =

0 commit comments

Comments
 (0)