Skip to content

Commit

Permalink
Merge branch 'main' into fix/117143
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/src/main/java/org/elasticsearch/index/mapper/MapperFeatures.java
  • Loading branch information
kkrik-es committed Dec 3, 2024
2 parents 73638b9 + 00a1222 commit de7c396
Show file tree
Hide file tree
Showing 89 changed files with 1,319 additions and 708 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/116904.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 116904
summary: Add a not-master state for desired balance
area: Allocation
type: enhancement
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/117229.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 117229
summary: "In this pr, a 400 error is returned when _source / _seq_no / _feature /\
\ _nested_path / _field_names is requested, rather a 5xx"
area: Search
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/117572.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117572
summary: Address and remove any references of RestApiVersion version 7
area: Search
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/117865.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 117865
summary: Fix BWC for ES|QL cluster request
area: ES|QL
type: bug
issues: []
2 changes: 1 addition & 1 deletion docs/reference/watcher/actions/email.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ killed by firewalls or load balancers in-between.
| Name | Description
| `format` | Attaches the watch data, equivalent to specifying `attach_data`
in the watch configuration. Possible values are `json` or `yaml`.
Defaults to `json` if not specified.
Defaults to `yaml` if not specified.
|======


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String typeName() {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + typeName() + "].");
throw new IllegalArgumentException("Cannot fetch values for internal field [" + typeName() + "].");
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ tests:
- class: org.elasticsearch.xpack.shutdown.NodeShutdownIT
method: testAllocationPreventedForRemoval
issue: https://github.com/elastic/elasticsearch/issues/116363
- class: org.elasticsearch.threadpool.SimpleThreadPoolIT
method: testThreadPoolMetrics
issue: https://github.com/elastic/elasticsearch/issues/108320
- class: org.elasticsearch.xpack.downsample.ILMDownsampleDisruptionIT
method: testILMDownsampleRollingRestart
issue: https://github.com/elastic/elasticsearch/issues/114233
Expand Down Expand Up @@ -239,6 +236,11 @@ tests:
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
method: test {p0=esql/60_usage/Basic ESQL usage output (telemetry) non-snapshot version}
issue: https://github.com/elastic/elasticsearch/issues/117862
- class: org.elasticsearch.validation.DotPrefixClientYamlTestSuiteIT
issue: https://github.com/elastic/elasticsearch/issues/117893
- class: org.elasticsearch.xpack.core.ml.search.SparseVectorQueryBuilderTests
method: testToQuery
issue: https://github.com/elastic/elasticsearch/issues/117904

# Examples:
#
Expand Down
1 change: 1 addition & 0 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ tasks.named("yamlRestCompatTestTransform").configure ({ task ->
task.skipTest("logsdb/20_source_mapping/stored _source mode is supported", "no longer serialize source_mode")
task.skipTest("logsdb/20_source_mapping/include/exclude is supported with stored _source", "no longer serialize source_mode")
task.skipTest("logsdb/20_source_mapping/synthetic _source is default", "no longer serialize source_mode")
task.skipTest("search/520_fetch_fields/fetch _seq_no via fields", "error code is changed from 5xx to 400 in 9.0")
})
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,88 @@ fetch _seq_no via stored_fields:

---
fetch _seq_no via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: "request"
catch: bad_request
search:
index: test
body:
fields: [ _seq_no ]

# This should be `unauthorized` (401) or `forbidden` (403) or at least `bad request` (400)
# while instead it is mapped to an `internal_server_error (500)`
- match: { status: 500 }
- match: { error.root_cause.0.type: unsupported_operation_exception }
- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_seq_no]: Cannot fetch values for internal field [_seq_no]." }

---
fetch _source via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _source ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_source]: Cannot fetch values for internal field [_source]." }

---
fetch _feature via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _feature ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_feature]: Cannot fetch values for internal field [_feature]." }

---
fetch _nested_path via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _nested_path ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_nested_path]: Cannot fetch values for internal field [_nested_path]." }

---
fetch _field_names via fields:
- requires:
cluster_features: ["meta_fetch_fields_error_code_changed"]
reason: The fields_api returns a 400 instead a 5xx when _seq_no is requested via fields

- do:
catch: bad_request
search:
index: test
body:
fields: [ _field_names ]

- match: { status: 400 }
- match: { error.root_cause.0.type: illegal_argument_exception }
- match: { error.root_cause.0.reason: "error fetching [_field_names]: Cannot fetch values for internal field [_field_names]." }

---
fetch fields with none stored_fields:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public void testThreadPoolMetrics() throws Exception {
tps[0].forEach(stats -> {
Map<String, Long> threadPoolStats = List.of(
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_COMPLETED, stats.completed()),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_ACTIVE, (long) stats.active()),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_CURRENT, (long) stats.threads()),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_ACTIVE, 0L),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_CURRENT, 0L),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_LARGEST, (long) stats.largest()),
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_QUEUE, (long) stats.queue())
Map.entry(ThreadPool.THREAD_POOL_METRIC_NAME_QUEUE, 0L)
).stream().collect(toUnmodifiableSortedMap(e -> stats.name() + e.getKey(), Entry::getValue));

Function<String, List<Long>> measurementExtractor = name -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.rest.action.search.RestMultiSearchAction;
import org.elasticsearch.rest.action.search.RestSearchAction;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
Expand Down Expand Up @@ -51,10 +47,6 @@
* A multi search API request.
*/
public class MultiSearchRequest extends ActionRequest implements CompositeIndicesRequest {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSearchAction.class);
public static final String FIRST_LINE_EMPTY_DEPRECATION_MESSAGE =
"support for empty first line before any action metadata in msearch API is deprecated "
+ "and will be removed in the next major version";
public static final int MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT = 0;

private int maxConcurrentSearchRequests = 0;
Expand Down Expand Up @@ -213,12 +205,6 @@ public static void readMultiLineFormat(
if (nextMarker == -1) {
break;
}
// support first line with \n
if (parserConfig.restApiVersion() == RestApiVersion.V_7 && nextMarker == 0) {
deprecationLogger.compatibleCritical("msearch_first_line_empty", FIRST_LINE_EMPTY_DEPRECATION_MESSAGE);
from = nextMarker + 1;
continue;
}

SearchRequest searchRequest = new SearchRequest();
if (indices != null) {
Expand Down Expand Up @@ -281,14 +267,11 @@ public static void readMultiLineFormat(
allowNoIndices = value;
} else if ("ignore_throttled".equals(entry.getKey()) || "ignoreThrottled".equals(entry.getKey())) {
ignoreThrottled = value;
} else if (parserConfig.restApiVersion() == RestApiVersion.V_7
&& ("type".equals(entry.getKey()) || "types".equals(entry.getKey()))) {
deprecationLogger.compatibleCritical("msearch_with_types", RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE);
} else if (extraParamParser.apply(entry.getKey(), value, searchRequest)) {
// Skip, the parser handled the key/value
} else {
throw new IllegalArgumentException("key [" + entry.getKey() + "] is not supported in the metadata section");
}
} else if (extraParamParser.apply(entry.getKey(), value, searchRequest)) {
// Skip, the parser handled the key/value
} else {
throw new IllegalArgumentException("key [" + entry.getKey() + "] is not supported in the metadata section");
}
}
defaultOptions = IndicesOptions.fromParameters(
expandWildcards,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.rest.action.document.RestTermVectorsAction;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;
Expand All @@ -52,7 +50,6 @@
// It's not possible to suppress teh warning at #realtime(boolean) at a method-level.
@SuppressWarnings("unchecked")
public final class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> implements RealtimeRequest {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(TermVectorsRequest.class);

private static final ParseField INDEX = new ParseField("_index");
private static final ParseField ID = new ParseField("_id");
Expand All @@ -66,7 +63,6 @@ public final class TermVectorsRequest extends SingleShardRequest<TermVectorsRequ
private static final ParseField DFS = new ParseField("dfs");
private static final ParseField FILTER = new ParseField("filter");
private static final ParseField DOC = new ParseField("doc");
private static final ParseField TYPE = new ParseField("_type");

private String id;

Expand Down Expand Up @@ -583,8 +579,6 @@ public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentP
termVectorsRequest.version = parser.longValue();
} else if (VERSION_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
termVectorsRequest.versionType = VersionType.fromString(parser.text());
} else if (restApiVersion == RestApiVersion.V_7 && TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.compatibleCritical("termvectors_with_types", RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
} else {
throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ public DesiredBalance(long lastConvergedIndex, Map<ShardId, ShardAssignment> ass
this(lastConvergedIndex, assignments, Map.of(), ComputationFinishReason.CONVERGED);
}

public static final DesiredBalance INITIAL = new DesiredBalance(-1, Map.of());
/**
* The placeholder value for {@link DesiredBalance} when the node stands down as master.
*/
public static final DesiredBalance NOT_MASTER = new DesiredBalance(-2, Map.of());
/**
* The starting value for {@link DesiredBalance} when the node becomes the master.
*/
public static final DesiredBalance BECOME_MASTER_INITIAL = new DesiredBalance(-1, Map.of());

public ShardAssignment getAssignment(ShardId shardId) {
return assignments.get(shardId);
Expand Down
Loading

0 comments on commit de7c396

Please sign in to comment.