Skip to content

Commit

Permalink
Merge branch 'main' into fix-security-index-active-assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Sep 17, 2024
2 parents 39e91be + 71b30ce commit b788181
Show file tree
Hide file tree
Showing 78 changed files with 1,832 additions and 1,526 deletions.
15 changes: 12 additions & 3 deletions .buildkite/scripts/lucene-snapshot/update-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ if [[ "$BUILDKITE_BRANCH" != "lucene_snapshot"* ]]; then
exit 1
fi

echo --- Updating "$BUILDKITE_BRANCH" branch with main
if [[ "$BUILDKITE_BRANCH" == "lucene_snapshot_10" ]]; then
UPSTREAM="main"
elif [[ "$BUILDKITE_BRANCH" == "lucene_snapshot" ]]; then
UPSTREAM="8.x"
else
echo "Error: unknown branch: $BUILDKITE_BRANCH"
exit 1
fi

echo --- Updating "$BUILDKITE_BRANCH" branch with "$UPSTREAM"

git config --global user.name elasticsearchmachine
git config --global user.email 'infra-root+elasticsearchmachine@elastic.co'

git checkout "$BUILDKITE_BRANCH"
git fetch origin main
git merge --no-edit origin/main
git fetch origin "$UPSTREAM"
git merge --no-edit "origin/$UPSTREAM"
git push origin "$BUILDKITE_BRANCH"
26 changes: 3 additions & 23 deletions distribution/tools/java-version-checker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
apply plugin: 'elasticsearch.build'

sourceSets {
unsupportedJdkVersionEntrypoint
}

tasks.named(sourceSets.unsupportedJdkVersionEntrypoint.compileJavaTaskName).configure {
targetCompatibility = JavaVersion.VERSION_1_8
}


tasks.named("jar") {
manifest {
attributes("Multi-Release": "true")
}

FileCollection mainOutput = sourceSets.main.output;
from(sourceSets.unsupportedJdkVersionEntrypoint.output)
eachFile { details ->
if (details.path.equals("org/elasticsearch/tools/java_version_checker/JavaVersionChecker.class") &&
mainOutput.asFileTree.contains(details.file)) {
details.relativePath = details.relativePath.prepend("META-INF/versions/17")
}
}
compileJava {
options.release = 8
}

// TODO revisit forbiddenApis issues
["javadoc", "forbiddenApisMain", "forbiddenApisUnsupportedJdkVersionEntrypoint"].each {
["javadoc", "forbiddenApisMain"].each {
tasks.named(it).configure { enabled = false }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
package org.elasticsearch.tools.java_version_checker;

import java.util.Arrays;
import java.util.Locale;

/**
* Java 17 compatible main which just exits without error.
* Java 8 compatible main to check the runtime version
*/
final class JavaVersionChecker {

Expand All @@ -23,5 +24,27 @@ public static void main(final String[] args) {
if (args.length != 0) {
throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
}

final int MIN_VERSION = 21;
final int version;
String versionString = System.getProperty("java.specification.version");
if (versionString.equals("1.8")) {
version = 8;
} else {
version = Integer.parseInt(versionString);
}
if (version >= MIN_VERSION) {
return;
}

final String message = String.format(
Locale.ROOT,
"The minimum required Java version is %d; your Java version %d from [%s] does not meet that requirement.",
MIN_VERSION,
version,
System.getProperty("java.home")
);
System.err.println(message);
System.exit(1);
}
}

This file was deleted.

5 changes: 0 additions & 5 deletions docs/changelog/111684.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions docs/changelog/112678.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 112678
summary: Make "too many clauses" throw IllegalArgumentException to avoid 500s
area: Search
type: bug
issues:
- 112177
5 changes: 5 additions & 0 deletions docs/changelog/112888.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 112888
summary: Fix `getDatabaseType` for unusual MMDBs
area: Ingest Node
type: bug
issues: []
13 changes: 13 additions & 0 deletions docs/reference/release-notes/8.15.0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ signed integer) may encounter errors (issue: {es-issue}111854[#111854])
`xpack.security.authc.realms.*.files.role_mapping` configuration option. As a workaround, custom role mappings
can be configured using the https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html[REST API] (issue: {es-issue}112503[#112503])

* ES|QL queries can lead to node crashes due to Out Of Memory errors when:
** Multiple indices match the query pattern
** These indices have many conflicting field mappings
** Many of those fields are included in the request
These issues deplete heap memory, increasing the likelihood of OOM errors. (issue: {es-issue}111964[#111964], {es-issue}111358[#111358]).
+
To work around this issue, you have a number of options:
** Downgrade to an earlier version
** Upgrade to 8.15.2 upon release
** Follow the instructions to
<<esql-kibana-enable,disable ES|QL queries in {kib}>>
** Change the default data view in Discover to a smaller set of indices and/or one with fewer mapping conflicts.

[[breaking-8.15.0]]
[float]
=== Breaking changes
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/release-notes/8.15.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ Also see <<breaking-changes-8.15,Breaking changes in 8.15>>.
`xpack.security.authc.realms.*.files.role_mapping` configuration option. As a workaround, custom role mappings
can be configured using the https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html[REST API] (issue: {es-issue}112503[#112503])

* ES|QL queries can lead to node crashes due to Out Of Memory errors when:
** Multiple indices match the query pattern
** These indices have many conflicting field mappings
** Many of those fields are included in the request
These issues deplete heap memory, increasing the likelihood of OOM errors. (issue: {es-issue}111964[#111964], {es-issue}111358[#111358]).
+
To work around this issue, you have a number of options:
** Downgrade to an earlier version
** Upgrade to 8.15.2 upon release
** Follow the instructions to
<<esql-kibana-enable,disable ES|QL queries in {kib}>>
** Change the default data view in Discover to a smaller set of indices and/or one with fewer mapping conflicts.

[[bug-8.15.1]]
[float]
=== Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class AbstractChallengeRestTest extends ESRestTestCase {
private XContentBuilder contenderMappings;
private Settings.Builder baselineSettings;
private Settings.Builder contenderSettings;
private RestClient client;
protected RestClient client;

@ClassRule()
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.datastreams.logsdb.qa;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.ObjectMapper;
import org.elasticsearch.logsdb.datageneration.DataGenerator;
import org.elasticsearch.logsdb.datageneration.DataGeneratorSpecification;
import org.elasticsearch.logsdb.datageneration.FieldDataGenerator;
import org.elasticsearch.logsdb.datageneration.datasource.DataSourceHandler;
import org.elasticsearch.logsdb.datageneration.datasource.DataSourceRequest;
import org.elasticsearch.logsdb.datageneration.datasource.DataSourceResponse;
import org.elasticsearch.logsdb.datageneration.fields.PredefinedField;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class DataGenerationHelper {
private final ObjectMapper.Subobjects subobjects;
private final boolean keepArraySource;

private final DataGenerator dataGenerator;

DataGenerationHelper() {
// TODO enable subobjects: auto
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using copy_to.
this.subobjects = ESTestCase.randomValueOtherThan(
ObjectMapper.Subobjects.AUTO,
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
);
this.keepArraySource = ESTestCase.randomBoolean();

var specificationBuilder = DataGeneratorSpecification.builder().withFullyDynamicMapping(ESTestCase.randomBoolean());
if (subobjects != ObjectMapper.Subobjects.ENABLED) {
specificationBuilder = specificationBuilder.withNestedFieldsLimit(0);
}
this.dataGenerator = new DataGenerator(specificationBuilder.withDataSourceHandlers(List.of(new DataSourceHandler() {
@Override
public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequest.ObjectMappingParametersGenerator request) {
if (subobjects == ObjectMapper.Subobjects.ENABLED) {
// Use default behavior
return null;
}

assert request.isNested() == false;

// "enabled: false" is not compatible with subobjects: false
// "dynamic: false/strict/runtime" is not compatible with subobjects: false
return new DataSourceResponse.ObjectMappingParametersGenerator(() -> {
var parameters = new HashMap<String, Object>();
parameters.put("subobjects", subobjects.toString());
if (ESTestCase.randomBoolean()) {
parameters.put("dynamic", "true");
}
if (ESTestCase.randomBoolean()) {
parameters.put("enabled", "true");
}
return parameters;
});
}
}))
.withPredefinedFields(
List.of(
// Customized because it always needs doc_values for aggregations.
new PredefinedField.WithGenerator("host.name", new FieldDataGenerator() {
@Override
public CheckedConsumer<XContentBuilder, IOException> mappingWriter() {
return b -> b.startObject().field("type", "keyword").endObject();
}

@Override
public CheckedConsumer<XContentBuilder, IOException> fieldValueGenerator() {
return b -> b.value(ESTestCase.randomAlphaOfLength(5));
}
}),
// Needed for terms query
new PredefinedField.WithGenerator("method", new FieldDataGenerator() {
@Override
public CheckedConsumer<XContentBuilder, IOException> mappingWriter() {
return b -> b.startObject().field("type", "keyword").endObject();
}

@Override
public CheckedConsumer<XContentBuilder, IOException> fieldValueGenerator() {
return b -> b.value(ESTestCase.randomFrom("put", "post", "get"));
}
}),

// Needed for histogram aggregation
new PredefinedField.WithGenerator("memory_usage_bytes", new FieldDataGenerator() {
@Override
public CheckedConsumer<XContentBuilder, IOException> mappingWriter() {
return b -> b.startObject().field("type", "long").endObject();
}

@Override
public CheckedConsumer<XContentBuilder, IOException> fieldValueGenerator() {
// We can generate this using standard long field but we would get "too many buckets"
return b -> b.value(ESTestCase.randomLongBetween(1000, 2000));
}
})
)
)
.build());
}

DataGenerator getDataGenerator() {
return dataGenerator;
}

void logsDbMapping(XContentBuilder builder) throws IOException {
dataGenerator.writeMapping(builder);
}

void standardMapping(XContentBuilder builder) throws IOException {
if (subobjects != ObjectMapper.Subobjects.ENABLED) {
dataGenerator.writeMapping(builder, Map.of("subobjects", subobjects.toString()));
} else {
dataGenerator.writeMapping(builder);
}
}

void logsDbSettings(Settings.Builder builder) {
if (keepArraySource) {
builder.put(Mapper.SYNTHETIC_SOURCE_KEEP_INDEX_SETTING.getKey(), "arrays");
}
}
}
Loading

0 comments on commit b788181

Please sign in to comment.