Skip to content

Commit 914a85a

Browse files
[ML] Do not add runtime section to DFA dest index mappings unnecessarily (#69329)
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.
1 parent 1e61059 commit 914a85a

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
@@ -185,8 +185,10 @@ private static CreateIndexRequest createIndexRequest(Clock clock,
185185
properties.putAll(createAdditionalMappings(config, fieldCapabilitiesResponse));
186186
Map<String, Object> metadata = getOrPutDefault(mappingsAsMap, META, HashMap::new);
187187
metadata.putAll(createMetadata(config.getId(), clock, Version.CURRENT));
188-
Map<String, Object> runtimeMappings = getOrPutDefault(mappingsAsMap, RUNTIME, HashMap::new);
189-
runtimeMappings.putAll(config.getSource().getRuntimeMappings());
188+
if (config.getSource().getRuntimeMappings().isEmpty() == false) {
189+
Map<String, Object> runtimeMappings = getOrPutDefault(mappingsAsMap, RUNTIME, HashMap::new);
190+
runtimeMappings.putAll(config.getSource().getRuntimeMappings());
191+
}
190192
return new CreateIndexRequest(destinationIndex, settings).mapping(mappingsAsMap);
191193
}
192194

@@ -270,8 +272,11 @@ public static void updateMappingsToDestIndex(Client client,
270272

271273
// Determine mappings to be added to the destination index
272274
addedMappings.put(PROPERTIES, createAdditionalMappings(config, fieldCapabilitiesResponse));
275+
273276
// Also add runtime mappings
274-
addedMappings.put(RUNTIME, config.getSource().getRuntimeMappings());
277+
if (config.getSource().getRuntimeMappings().isEmpty() == false) {
278+
addedMappings.put(RUNTIME, config.getSource().getRuntimeMappings());
279+
}
275280

276281
// Add the mappings to the destination index
277282
PutMappingRequest putMappingRequest =

0 commit comments

Comments
 (0)