Skip to content

Commit 74fbaca

Browse files
Merge branch 'main' of github.com:elastic/elasticsearch into ia-fix-eis-everything-default
2 parents 2fd411a + 24cd7d9 commit 74fbaca

File tree

25 files changed

+519
-340
lines changed

25 files changed

+519
-340
lines changed

docs/changelog/138260.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 138260
2+
summary: "[HealthAPI] Deterministic shard availability key order"
3+
area: Health
4+
type: enhancement
5+
issues:
6+
- 138043

docs/changelog/138962.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138962
2+
summary: Allows Cross Project for close `PointInTime`
3+
area: Search
4+
type: enhancement
5+
issues: []

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
package org.elasticsearch.ingest.common;
1010

11-
import org.elasticsearch.TransportVersions;
1211
import org.elasticsearch.action.ActionListener;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.ActionResponse;
@@ -60,9 +59,7 @@ public Request(boolean sorted, String ecsCompatibility) {
6059
Request(StreamInput in) throws IOException {
6160
super(in);
6261
this.sorted = in.readBoolean();
63-
this.ecsCompatibility = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)
64-
? in.readString()
65-
: GrokProcessor.DEFAULT_ECS_COMPATIBILITY_MODE;
62+
this.ecsCompatibility = in.readString();
6663
}
6764

6865
@Override
@@ -74,9 +71,7 @@ public ActionRequestValidationException validate() {
7471
public void writeTo(StreamOutput out) throws IOException {
7572
super.writeTo(out);
7673
out.writeBoolean(sorted);
77-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
78-
out.writeString(ecsCompatibility);
79-
}
74+
out.writeString(ecsCompatibility);
8075
}
8176

8277
public boolean sorted() {

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpStatsAction.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ protected NodeResponse(StreamInput in) throws IOException {
174174
}
175175
databases = in.readCollectionAsImmutableSet(StreamInput::readString);
176176
filesInTemp = in.readCollectionAsImmutableSet(StreamInput::readString);
177-
configDatabases = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)
178-
? in.readCollectionAsImmutableSet(StreamInput::readString)
179-
: null;
177+
configDatabases = in.readCollectionAsImmutableSet(StreamInput::readString);
180178
}
181179

182180
protected NodeResponse(
@@ -226,9 +224,7 @@ public void writeTo(StreamOutput out) throws IOException {
226224
}
227225
out.writeStringCollection(databases);
228226
out.writeStringCollection(filesInTemp);
229-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
230-
out.writeStringCollection(configDatabases);
231-
}
227+
out.writeStringCollection(configDatabases);
232228
}
233229

234230
@Override

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.elasticsearch.ElasticsearchException;
3636
import org.elasticsearch.ResourceNotFoundException;
3737
import org.elasticsearch.TransportVersion;
38-
import org.elasticsearch.TransportVersions;
3938
import org.elasticsearch.action.get.GetRequest;
4039
import org.elasticsearch.common.CheckedSupplier;
4140
import org.elasticsearch.common.bytes.BytesReference;
@@ -214,15 +213,7 @@ protected PercolateQueryBuilder(String field, Supplier<BytesReference> documentS
214213
super(in);
215214
field = in.readString();
216215
name = in.readOptionalString();
217-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
218-
String documentType = in.readOptionalString();
219-
assert documentType == null;
220-
}
221216
indexedDocumentIndex = in.readOptionalString();
222-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
223-
String indexedDocumentType = in.readOptionalString();
224-
assert indexedDocumentType == null;
225-
}
226217
indexedDocumentId = in.readOptionalString();
227218
indexedDocumentRouting = in.readOptionalString();
228219
indexedDocumentPreference = in.readOptionalString();
@@ -256,15 +247,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
256247
}
257248
out.writeString(field);
258249
out.writeOptionalString(name);
259-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
260-
// In 7x, typeless percolate queries are represented by null documentType values
261-
out.writeOptionalString(null);
262-
}
263250
out.writeOptionalString(indexedDocumentIndex);
264-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
265-
// In 7x, typeless percolate queries are represented by null indexedDocumentType values
266-
out.writeOptionalString(null);
267-
}
268251
out.writeOptionalString(indexedDocumentId);
269252
out.writeOptionalString(indexedDocumentRouting);
270253
out.writeOptionalString(indexedDocumentPreference);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.http;
11+
12+
import org.apache.http.HttpStatus;
13+
import org.elasticsearch.client.Request;
14+
import org.elasticsearch.client.ResponseException;
15+
16+
import static org.hamcrest.Matchers.containsString;
17+
import static org.hamcrest.Matchers.equalTo;
18+
19+
public class FieldCapabilitiesIT extends HttpSmokeTestCase {
20+
21+
public void testProjectRoutingInNonCrossProjectEnv() {
22+
// With project_routing as query param in non-CPS env
23+
{
24+
Request request = new Request("POST", "_field_caps?fields=*&project_routing=_alias:_origin");
25+
ResponseException error = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request));
26+
assertThat(error.getMessage(), containsString("request [_field_caps] contains unrecognized parameter: [project_routing]"));
27+
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
28+
}
29+
// With project_routing in body in non-CPS env
30+
{
31+
Request request = new Request("POST", "_field_caps?fields=*");
32+
request.setJsonEntity("""
33+
{
34+
"project_routing": "_alias:_origin"
35+
}
36+
""");
37+
ResponseException error = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request));
38+
assertThat(error.getMessage(), containsString("Unknown key for a VALUE_STRING in [project_routing]"));
39+
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
40+
}
41+
}
42+
}

qa/smoke-test-http/src/internalClusterTest/java/org/elasticsearch/http/PointInTimeIT.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,28 @@ public void testMissingRequiredParameters() {
4444
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
4545
}
4646
}
47+
48+
public void testProjectRoutingInNonCrossProjectEnv() {
49+
// With project_routing as query param in non-CPS env
50+
{
51+
Request request = new Request("POST", "_pit?project_routing=_alias:_origin");
52+
request.addParameter("keep_alive", "1m");
53+
ResponseException error = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request));
54+
assertThat(error.getMessage(), containsString("request [_pit] contains unrecognized parameter: [project_routing]"));
55+
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
56+
}
57+
// With project_routing in body in non-CPS env
58+
{
59+
Request request = new Request("POST", "logs-*/_pit");
60+
request.addParameter("keep_alive", "1m");
61+
request.setJsonEntity("""
62+
{
63+
"project_routing": "_alias:_origin"
64+
}
65+
""");
66+
ResponseException error = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request));
67+
assertThat(error.getMessage(), containsString("Unknown key for a VALUE_STRING in [project_routing]"));
68+
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
69+
}
70+
}
4771
}

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml

Lines changed: 0 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -413,192 +413,6 @@
413413
- match: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 0 }
414414

415415
---
416-
"indices mappings exact count test for indices level":
417-
418-
- requires:
419-
test_runner_features: [arbitrary_key]
420-
reason: "_ignored_source added to mappings"
421-
422-
- do:
423-
indices.create:
424-
index: index1
425-
body:
426-
settings:
427-
number_of_shards: 4
428-
number_of_replicas: 0
429-
mappings:
430-
runtime:
431-
a_source_field:
432-
type: keyword
433-
properties:
434-
"@timestamp":
435-
type: date
436-
authors:
437-
properties:
438-
age:
439-
type: long
440-
company:
441-
type: text
442-
fields:
443-
keyword:
444-
type: keyword
445-
ignore_above: 256
446-
name:
447-
properties:
448-
first_name:
449-
type: keyword
450-
full_name:
451-
type: text
452-
last_name:
453-
type: keyword
454-
link:
455-
type: alias
456-
path: url
457-
title:
458-
type: text
459-
url:
460-
type: keyword
461-
462-
- do:
463-
nodes.info: {}
464-
- set:
465-
nodes._arbitrary_key_: node_id
466-
467-
- do:
468-
nodes.stats: { metric: _all, level: "indices", human: true }
469-
470-
# In the below assertions, we expect a field count of 26 because the above mapping expects the following:
471-
# Field mappers (incl. alias fields and object mappers' flattened leaves):
472-
# 1. _data_stream_timestamp
473-
# 2. _doc_count
474-
# 3. _feature
475-
# 4. _field_names
476-
# 5. _id
477-
# 6. _ignored
478-
# 7. _ignored_source
479-
# 8. _index
480-
# 9. _index_mode
481-
# 10. _nested_path
482-
# 11. _routing
483-
# 12. _seq_no
484-
# 13. _source
485-
# 14. _tier
486-
# 15. _version
487-
# 16. @timestamp
488-
# 17. authors.age
489-
# 18. authors.company
490-
# 19. authors.company.keyword
491-
# 20. authors.name.last_name
492-
# 21. authors.name.first_name
493-
# 22. authors.name.full_name
494-
# 23. link
495-
# 24. title
496-
# 25. url
497-
# Object mappers:
498-
# 26. authors
499-
# 27. authors.name
500-
# Runtime field mappers:
501-
# 28. a_source_field
502-
503-
- gte: { nodes.$node_id.indices.mappings.total_count: 28 }
504-
- is_true: nodes.$node_id.indices.mappings.total_estimated_overhead
505-
- gte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 26624 }
506-
- match: { "nodes.$node_id.indices.indices.${_project_id_prefix_}index1.mappings.total_count": 28 }
507-
- is_true: "nodes.$node_id.indices.indices.${_project_id_prefix_}index1.mappings.total_estimated_overhead"
508-
- match: { "nodes.$node_id.indices.indices.${_project_id_prefix_}index1.mappings.total_estimated_overhead_in_bytes": 28672 }
509-
510-
---
511-
"Lucene segment level fields stats":
512-
513-
- do:
514-
indices.create:
515-
index: index1
516-
body:
517-
settings:
518-
number_of_shards: 1
519-
number_of_replicas: 0
520-
routing.rebalance.enable: none
521-
mappings:
522-
runtime:
523-
a_source_field:
524-
type: keyword
525-
properties:
526-
"@timestamp":
527-
type: date
528-
authors:
529-
properties:
530-
age:
531-
type: long
532-
company:
533-
type: text
534-
fields:
535-
keyword:
536-
type: keyword
537-
ignore_above: 256
538-
name:
539-
properties:
540-
first_name:
541-
type: keyword
542-
full_name:
543-
type: text
544-
last_name:
545-
type: keyword
546-
link:
547-
type: alias
548-
path: url
549-
title:
550-
type: text
551-
url:
552-
type: keyword
553-
- do:
554-
cluster.state: {}
555-
556-
- set:
557-
routing_table.indices.index1.shards.0.0.node: node_id
558-
559-
- do:
560-
nodes.stats: { metric: _all, level: "indices", human: true }
561-
562-
- do:
563-
index:
564-
index: index1
565-
body: { "title": "foo", "@timestamp": "2023-10-15T14:12:12" }
566-
- do:
567-
indices.flush:
568-
index: index1
569-
- do:
570-
nodes.stats: { metric: _all, level: "indices", human: true }
571-
572-
- gte: { nodes.$node_id.indices.mappings.total_count: 28 }
573-
- lte: { nodes.$node_id.indices.mappings.total_count: 30 }
574-
- gte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 28672 }
575-
- lte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 30720 }
576-
- match: { nodes.$node_id.indices.mappings.total_segments: 1 }
577-
- gte: { nodes.$node_id.indices.mappings.total_segment_fields: 28 }
578-
- lte: { nodes.$node_id.indices.mappings.total_segment_fields: 30 }
579-
- gte: { nodes.$node_id.indices.mappings.average_fields_per_segment: 28 }
580-
- lte: { nodes.$node_id.indices.mappings.average_fields_per_segment: 30 }
581-
582-
- do:
583-
index:
584-
index: index1
585-
body: { "title": "bar", "@timestamp": "2023-11-15T14:12:12" }
586-
- do:
587-
indices.flush:
588-
index: index1
589-
- do:
590-
nodes.stats: { metric: _all, level: "indices", human: true }
591-
592-
- gte: { nodes.$node_id.indices.mappings.total_count: 28 }
593-
- lte: { nodes.$node_id.indices.mappings.total_count: 30 }
594-
- gte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 28672 }
595-
- lte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 30720 }
596-
- match: { nodes.$node_id.indices.mappings.total_segments: 2 }
597-
- gte: { nodes.$node_id.indices.mappings.total_segment_fields: 56 }
598-
- lte: { nodes.$node_id.indices.mappings.total_segment_fields: 60 }
599-
- gte: { nodes.$node_id.indices.mappings.average_fields_per_segment: 28 }
600-
- lte: { nodes.$node_id.indices.mappings.average_fields_per_segment: 30 }
601-
---
602416

603417
"indices mappings does not exist in shards level":
604418

server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ public ActionRequestValidationException validate() {
355355
if (fields == null || fields.length == 0) {
356356
validationException = ValidateActions.addValidationError("no fields specified", validationException);
357357
}
358+
if (projectRouting != null && indicesOptions.resolveCrossProjectIndexExpression() == false) {
359+
validationException = ValidateActions.addValidationError(
360+
"Unknown key for a VALUE_STRING in [project_routing]",
361+
validationException
362+
);
363+
364+
}
358365
return validationException;
359366
}
360367

0 commit comments

Comments
 (0)