Skip to content

Commit 346f914

Browse files
committed
Merge remote-tracking branch 'upstream/main' into entitlements/missing-url-connection-5
2 parents 07aa3c9 + b1c75d1 commit 346f914

File tree

98 files changed

+504
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+504
-483
lines changed

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ develocity {
133133
}
134134
} else {
135135
tag 'LOCAL'
136-
if (providers.systemProperty('idea.active').present) {
136+
if (System.getProperty('idea.active') == 'true') {
137137
tag 'IDEA'
138138
}
139139
}

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Docs live in **three places**:
1717

1818
1. **Reference content** lives in this repo. This covers low-level stuff like settings and configuration information that is tightly coupled to code.
1919
- 👩🏽‍💻 **Engineers** own the bulk of this content.
20-
2. **API reference docs** live in the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification)
20+
2. **API reference docs** live in the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification/blob/main/README.md#how-to-generate-the-openapi-representation)
2121
- This is where you need to update API docs published in the [new API docs system](https://www.elastic.co/docs/api/doc/elasticsearch/v8/)
2222
- 👩🏽‍💻 **Engineers** own this content.
2323
3. **Narrative, overview, and conceptual content** mostly lives in the [`docs-content`](https://github.com/elastic/docs-content/) repo.
@@ -106,4 +106,4 @@ This allows slightly more expressive testing of the snippets. Since that syntax
106106
% TEST[s/\n$/\nstartyaml\n - compare_analyzers: {index: thai_example, first: thai, second: rebuilt_thai}\nendyaml\n/]
107107
```
108108

109-
Any place you can use json you can use elements like `$body.path.to.thing` which is replaced on the fly with the contents of the thing at `path.to.thing` in the last response.
109+
Any place you can use json you can use elements like `$body.path.to.thing` which is replaced on the fly with the contents of the thing at `path.to.thing` in the last response.

plugins/discovery-ec2/build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ esplugin.bundleSpec.from('config/discovery-ec2') {
4646
}
4747

4848
tasks.register("writeTestJavaPolicy") {
49+
boolean inFips = buildParams.inFipsJvm
50+
inputs.property("inFipsJvm", inFips)
51+
final File javaPolicy = new File(layout.buildDirectory.asFile.get(), "tmp/java.policy")
52+
outputs.file(javaPolicy)
4953
doLast {
50-
final File tmp = file("${buildDir}/tmp")
51-
if (tmp.exists() == false && tmp.mkdirs() == false) {
52-
throw new GradleException("failed to create temporary directory [${tmp}]")
53-
}
54-
final File javaPolicy = file("${tmp}/java.policy")
55-
if (buildParams.inFipsJvm) {
54+
if (inFips) {
5655
javaPolicy.write(
5756
[
5857
"grant {",
@@ -95,9 +94,9 @@ tasks.withType(Test).configureEach {
9594
// this is needed to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
9695
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
9796
if (buildParams.inFipsJvm){
98-
nonInputProperties.systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
97+
nonInputProperties.systemProperty 'java.security.policy', "=file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
9998
} else {
100-
nonInputProperties.systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
99+
nonInputProperties.systemProperty 'java.security.policy', "file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
101100
}
102101
}
103102

plugins/examples/security-authorization-engine/src/main/java/org/elasticsearch/example/CustomAuthorizationEngine.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.example;
1111

1212
import org.elasticsearch.action.ActionListener;
13+
import org.elasticsearch.action.support.SubscribableListener;
1314
import org.elasticsearch.cluster.metadata.IndexAbstraction;
1415
import org.elasticsearch.cluster.metadata.ProjectMetadata;
1516
import org.elasticsearch.xpack.core.security.action.user.GetUserPrivilegesResponse;
@@ -86,14 +87,14 @@ public void authorizeClusterAction(RequestInfo requestInfo, AuthorizationInfo au
8687
}
8788

8889
@Override
89-
public void authorizeIndexAction(
90+
SubscribableListener<IndexAuthorizationResult> void authorizeIndexAction(
9091
RequestInfo requestInfo,
9192
AuthorizationInfo authorizationInfo,
9293
AsyncSupplier<ResolvedIndices> indicesAsyncSupplier,
93-
ProjectMetadata project,
94-
ActionListener<IndexAuthorizationResult> listener
94+
ProjectMetadata project
9595
) {
9696
if (isSuperuser(requestInfo.getAuthentication().getEffectiveSubject().getUser())) {
97+
ActionListener<IndexAuthorizationResult> listener = new SubscribableListener<>();
9798
indicesAsyncSupplier.getAsync(ActionListener.wrap(resolvedIndices -> {
9899
Map<String, IndexAccessControl> indexAccessControlMap = new HashMap<>();
99100
for (String name : resolvedIndices.getLocal()) {
@@ -103,8 +104,9 @@ public void authorizeIndexAction(
103104
new IndicesAccessControl(true, Collections.unmodifiableMap(indexAccessControlMap));
104105
listener.onResponse(new IndexAuthorizationResult(indicesAccessControl));
105106
}, listener::onFailure));
107+
return listener;
106108
} else {
107-
listener.onResponse(new IndexAuthorizationResult(IndicesAccessControl.DENIED));
109+
return SubscribableListener.succcess(new IndexAuthorizationResult(IndicesAccessControl.DENIED));
108110
}
109111
}
110112

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ static TransportVersion def(int id) {
5757
public static final TransportVersion V_7_3_0 = def(7_03_00_99);
5858
public static final TransportVersion V_7_3_2 = def(7_03_02_99);
5959
public static final TransportVersion V_7_4_0 = def(7_04_00_99);
60-
public static final TransportVersion V_7_6_0 = def(7_06_00_99);
6160
public static final TransportVersion V_7_8_0 = def(7_08_00_99);
6261
public static final TransportVersion V_7_8_1 = def(7_08_01_99);
6362
public static final TransportVersion V_7_9_0 = def(7_09_00_99);

server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.action.ActionRequest;
1313
import org.elasticsearch.action.ActionRequestValidationException;
14+
import org.elasticsearch.cluster.metadata.ProjectId;
1415
import org.elasticsearch.common.bytes.BytesReference;
1516
import org.elasticsearch.common.bytes.ReleasableBytesReference;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -130,6 +131,7 @@ record Parsed(Pipeline pipeline, List<IngestDocument> documents, boolean verbose
130131
static final String SIMULATED_PIPELINE_ID = "_simulate_pipeline";
131132

132133
static Parsed parseWithPipelineId(
134+
ProjectId projectId,
133135
String pipelineId,
134136
Map<String, Object> config,
135137
boolean verbose,
@@ -139,7 +141,7 @@ static Parsed parseWithPipelineId(
139141
if (pipelineId == null) {
140142
throw new IllegalArgumentException("param [pipeline] is null");
141143
}
142-
Pipeline pipeline = ingestService.getPipeline(pipelineId);
144+
Pipeline pipeline = ingestService.getPipeline(projectId, pipelineId);
143145
if (pipeline == null) {
144146
throw new IllegalArgumentException("pipeline [" + pipelineId + "] does not exist");
145147
}

server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineTransportAction.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.action.support.HandledTransportAction;
1818
import org.elasticsearch.cluster.node.DiscoveryNode;
1919
import org.elasticsearch.cluster.node.DiscoveryNodes;
20+
import org.elasticsearch.cluster.project.ProjectResolver;
2021
import org.elasticsearch.common.Randomness;
2122
import org.elasticsearch.common.settings.Setting;
2223
import org.elasticsearch.common.util.concurrent.EsExecutors;
@@ -49,6 +50,7 @@ public class SimulatePipelineTransportAction extends HandledTransportAction<Simu
4950
private final IngestService ingestService;
5051
private final SimulateExecutionService executionService;
5152
private final TransportService transportService;
53+
private final ProjectResolver projectResolver;
5254
private volatile TimeValue ingestNodeTransportActionTimeout;
5355
// ThreadLocal because our unit testing framework does not like sharing Randoms across threads
5456
private final ThreadLocal<Random> random = ThreadLocal.withInitial(Randomness::get);
@@ -58,7 +60,8 @@ public SimulatePipelineTransportAction(
5860
ThreadPool threadPool,
5961
TransportService transportService,
6062
ActionFilters actionFilters,
61-
IngestService ingestService
63+
IngestService ingestService,
64+
ProjectResolver projectResolver
6265
) {
6366
super(
6467
SimulatePipelineAction.NAME,
@@ -70,6 +73,7 @@ public SimulatePipelineTransportAction(
7073
this.ingestService = ingestService;
7174
this.executionService = new SimulateExecutionService(threadPool);
7275
this.transportService = transportService;
76+
this.projectResolver = projectResolver;
7377
this.ingestNodeTransportActionTimeout = INGEST_NODE_TRANSPORT_ACTION_TIMEOUT.get(ingestService.getClusterService().getSettings());
7478
ingestService.getClusterService()
7579
.getClusterSettings()
@@ -96,9 +100,11 @@ protected void doExecute(Task task, SimulatePipelineRequest request, ActionListe
96100
}
97101
try {
98102
if (discoveryNodes.getLocalNode().isIngestNode()) {
103+
final var projectId = projectResolver.getProjectId();
99104
final SimulatePipelineRequest.Parsed simulateRequest;
100105
if (request.getId() != null) {
101106
simulateRequest = SimulatePipelineRequest.parseWithPipelineId(
107+
projectId,
102108
request.getId(),
103109
source,
104110
request.isVerbose(),

server/src/main/java/org/elasticsearch/action/support/SubscribableListener.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ public final boolean isDone() {
266266
return isDone(state);
267267
}
268268

269+
/**
270+
* @return return {@code true} if and only if this listener is done and has been completed successfully
271+
*/
272+
public final boolean isSuccess() {
273+
return state instanceof SuccessResult;
274+
}
275+
269276
/**
270277
* @return the result with which this listener completed successfully, or throw the exception with which it failed.
271278
*

server/src/main/java/org/elasticsearch/cluster/block/ClusterBlocks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ private static void writeBlockSet(Set<ClusterBlock> blocks, StreamOutput out) th
438438
public static ClusterBlocks readFrom(StreamInput in) throws IOException {
439439
if (in.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT)) {
440440
final Set<ClusterBlock> global = readBlockSet(in);
441-
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::new, ProjectBlocks::readFrom);
441+
final Map<ProjectId, ProjectBlocks> projectBlocksMap = in.readImmutableMap(ProjectId::readFrom, ProjectBlocks::readFrom);
442442
if (global.isEmpty()
443443
&& noProjectOrDefaultProjectOnly(projectBlocksMap)
444444
&& projectBlocksMap.getOrDefault(Metadata.DEFAULT_PROJECT_ID, ProjectBlocks.EMPTY).indices().isEmpty()) {

server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class Metadata implements Diffable<Metadata>, ChunkedToXContent {
8888
public static final String UNKNOWN_CLUSTER_UUID = "_na_";
8989
// TODO multi-project: verify that usages are really expected to work on the default project only,
9090
// and that they are not a stop-gap solution to make the tests pass
91-
public static final ProjectId DEFAULT_PROJECT_ID = new ProjectId("default");
91+
public static final ProjectId DEFAULT_PROJECT_ID = ProjectId.DEFAULT;
9292

9393
public enum XContentContext {
9494
/* Custom metadata should be returned as part of API call */
@@ -1154,7 +1154,7 @@ public static Metadata readFrom(StreamInput in) throws IOException {
11541154
builder.put(ReservedStateMetadata.readFrom(in));
11551155
}
11561156

1157-
builder.projectMetadata(in.readMap(ProjectId::new, ProjectMetadata::readFrom));
1157+
builder.projectMetadata(in.readMap(ProjectId::readFrom, ProjectMetadata::readFrom));
11581158
}
11591159
return builder.build();
11601160
}

0 commit comments

Comments
 (0)