Skip to content

Commit 6f2eab2

Browse files
committed
Merge remote-tracking branch 'upstream/main' into entitlements/fileaccesstree-fix-windows-casing
2 parents e199568 + 36af046 commit 6f2eab2

File tree

100 files changed

+3792
-658
lines changed

Some content is hidden

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

100 files changed

+3792
-658
lines changed

distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/ServerCli.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ protected ServerProcess startServer(Terminal terminal, ProcessInfo processInfo,
271271
.withProcessInfo(processInfo)
272272
.withServerArgs(args)
273273
.withTempDir(tempDir)
274-
.withJvmOptions(jvmOptions)
275-
.withWorkingDir(args.logsDir());
274+
.withJvmOptions(jvmOptions);
276275
return serverProcessBuilder.start();
277276
}
278277

distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/ServerProcessBuilder.java

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

1212
import org.elasticsearch.bootstrap.ServerArgs;
13+
import org.elasticsearch.cli.ExitCodes;
1314
import org.elasticsearch.cli.ProcessInfo;
1415
import org.elasticsearch.cli.Terminal;
1516
import org.elasticsearch.cli.UserException;
@@ -21,6 +22,8 @@
2122
import java.io.IOException;
2223
import java.io.OutputStream;
2324
import java.io.UncheckedIOException;
25+
import java.nio.file.FileAlreadyExistsException;
26+
import java.nio.file.Files;
2427
import java.nio.file.Path;
2528
import java.util.HashMap;
2629
import java.util.List;
@@ -44,7 +47,6 @@ public class ServerProcessBuilder {
4447
private ServerArgs serverArgs;
4548
private ProcessInfo processInfo;
4649
private List<String> jvmOptions;
47-
private Path workingDir;
4850
private Terminal terminal;
4951

5052
// this allows mocking the process building by tests
@@ -84,11 +86,6 @@ public ServerProcessBuilder withJvmOptions(List<String> jvmOptions) {
8486
return this;
8587
}
8688

87-
public ServerProcessBuilder withWorkingDir(Path workingDir) {
88-
this.workingDir = workingDir;
89-
return this;
90-
}
91-
9289
/**
9390
* Specifies the {@link Terminal} to use for reading input and writing output from/to the cli console
9491
*/
@@ -141,6 +138,17 @@ public ServerProcess start() throws UserException {
141138
return start(ProcessBuilder::start);
142139
}
143140

141+
private void ensureWorkingDirExists() throws UserException {
142+
Path workingDir = serverArgs.logsDir();
143+
try {
144+
Files.createDirectories(workingDir);
145+
} catch (FileAlreadyExistsException e) {
146+
throw new UserException(ExitCodes.CONFIG, "Logs dir [" + workingDir + "] exists but is not a directory", e);
147+
} catch (IOException e) {
148+
throw new UserException(ExitCodes.CONFIG, "Unable to create logs dir [" + workingDir + "]", e);
149+
}
150+
}
151+
144152
private static void checkRequiredArgument(Object argument, String argumentName) {
145153
if (argument == null) {
146154
throw new IllegalStateException(
@@ -157,12 +165,14 @@ ServerProcess start(ProcessStarter processStarter) throws UserException {
157165
checkRequiredArgument(jvmOptions, "jvmOptions");
158166
checkRequiredArgument(terminal, "terminal");
159167

168+
ensureWorkingDirExists();
169+
160170
Process jvmProcess = null;
161171
ErrorPumpThread errorPump;
162172

163173
boolean success = false;
164174
try {
165-
jvmProcess = createProcess(getCommand(), getJvmArgs(), jvmOptions, getEnvironment(), workingDir, processStarter);
175+
jvmProcess = createProcess(getCommand(), getJvmArgs(), jvmOptions, getEnvironment(), serverArgs.logsDir(), processStarter);
166176
errorPump = new ErrorPumpThread(terminal, jvmProcess.getErrorStream());
167177
errorPump.start();
168178
sendArgs(serverArgs, jvmProcess.getOutputStream());

distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/ServerProcessTests.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class ServerProcessTests extends ESTestCase {
6565
protected final Map<String, String> sysprops = new HashMap<>();
6666
protected final Map<String, String> envVars = new HashMap<>();
6767
Path esHomeDir;
68-
Path workingDir;
68+
Path logsDir;
6969
Settings.Builder nodeSettings;
7070
ProcessValidator processValidator;
7171
MainMethod mainCallback;
@@ -94,8 +94,8 @@ public void resetEnv() {
9494
sysprops.put("os.name", "Linux");
9595
sysprops.put("java.home", "javahome");
9696
sysprops.put("es.path.home", esHomeDir.toString());
97+
logsDir = esHomeDir.resolve("logs");
9798
envVars.clear();
98-
workingDir = createTempDir();
9999
nodeSettings = Settings.builder();
100100
processValidator = null;
101101
mainCallback = null;
@@ -207,15 +207,7 @@ ProcessInfo createProcessInfo() {
207207
}
208208

209209
ServerArgs createServerArgs(boolean daemonize, boolean quiet) {
210-
return new ServerArgs(
211-
daemonize,
212-
quiet,
213-
null,
214-
secrets,
215-
nodeSettings.build(),
216-
esHomeDir.resolve("config"),
217-
esHomeDir.resolve("logs")
218-
);
210+
return new ServerArgs(daemonize, quiet, null, secrets, nodeSettings.build(), esHomeDir.resolve("config"), logsDir);
219211
}
220212

221213
ServerProcess startProcess(boolean daemonize, boolean quiet) throws Exception {
@@ -231,8 +223,7 @@ ServerProcess startProcess(boolean daemonize, boolean quiet) throws Exception {
231223
.withProcessInfo(pinfo)
232224
.withServerArgs(createServerArgs(daemonize, quiet))
233225
.withJvmOptions(List.of())
234-
.withTempDir(ServerProcessUtils.setupTempDir(pinfo))
235-
.withWorkingDir(workingDir);
226+
.withTempDir(ServerProcessUtils.setupTempDir(pinfo));
236227
return serverProcessBuilder.start(starter);
237228
}
238229

@@ -241,7 +232,7 @@ public void testProcessBuilder() throws Exception {
241232
assertThat(pb.redirectInput(), equalTo(ProcessBuilder.Redirect.PIPE));
242233
assertThat(pb.redirectOutput(), equalTo(ProcessBuilder.Redirect.INHERIT));
243234
assertThat(pb.redirectError(), equalTo(ProcessBuilder.Redirect.PIPE));
244-
assertThat(String.valueOf(pb.directory()), equalTo(workingDir.toString())); // leave default, which is working directory
235+
assertThat(String.valueOf(pb.directory()), equalTo(esHomeDir.resolve("logs").toString()));
245236
};
246237
mainCallback = (args, stdin, stderr, exitCode) -> {
247238
try (PrintStream err = new PrintStream(stderr, true, StandardCharsets.UTF_8)) {
@@ -315,8 +306,7 @@ public void testCommandLineSysprops() throws Exception {
315306
.withProcessInfo(createProcessInfo())
316307
.withServerArgs(createServerArgs(false, false))
317308
.withJvmOptions(List.of("-Dfoo1=bar", "-Dfoo2=baz"))
318-
.withTempDir(Path.of("."))
319-
.withWorkingDir(workingDir);
309+
.withTempDir(Path.of("."));
320310
serverProcessBuilder.start(starter).waitFor();
321311
}
322312

@@ -433,4 +423,26 @@ public void testProcessDies() throws Exception {
433423
int exitCode = server.waitFor();
434424
assertThat(exitCode, equalTo(-9));
435425
}
426+
427+
public void testLogsDirIsFile() throws Exception {
428+
Files.createFile(logsDir);
429+
var e = expectThrows(UserException.class, this::runForeground);
430+
assertThat(e.getMessage(), containsString("exists but is not a directory"));
431+
}
432+
433+
public void testLogsDirCreateParents() throws Exception {
434+
Path testDir = createTempDir();
435+
logsDir = testDir.resolve("subdir/logs");
436+
processValidator = pb -> assertThat(String.valueOf(pb.directory()), equalTo(logsDir.toString()));
437+
runForeground();
438+
}
439+
440+
public void testLogsCreateFailure() throws Exception {
441+
Path testDir = createTempDir();
442+
Path parentFile = testDir.resolve("exists");
443+
Files.createFile(parentFile);
444+
logsDir = parentFile.resolve("logs");
445+
var e = expectThrows(UserException.class, this::runForeground);
446+
assertThat(e.getMessage(), containsString("Unable to create logs dir"));
447+
}
436448
}

docs/changelog/126441.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/changelog/126770.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126770
2+
summary: Remove empty results before merging
3+
area: Search
4+
type: bug
5+
issues:
6+
- 126742

docs/reference/elasticsearch/configuration-reference/thread-pool-settings.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ The following are the types of thread pools and their respective parameters:
9494
9595
### `fixed` [fixed-thread-pool]
9696

97-
The `fixed` thread pool holds a fixed size of threads to handle the requests with a queue (optionally bounded) for pending requests that have no threads to service them.
98-
99-
The `size` parameter controls the number of threads.
100-
101-
The `queue_size` allows to control the size of the queue of pending requests that have no threads to execute them. By default, it is set to `-1` which means its unbounded. When a request comes in and the queue is full, it will abort the request.
97+
A `fixed` thread pool holds a fixed number of threads as determined by the `size` parameter. If a task is submitted to a `fixed` thread pool and there are fewer than `size` busy threads in the pool then the task will execute immediately. If all the threads are busy when a task is submitted then it will be held in a queue for later execution. The `queue_size` parameter controls the maximum size of this queue. A `queue_size` of `-1` means that the queue is unbounded, but most `fixed` thread pools specify a bound on their queue size by default. If a bounded queue is full then it will reject further work, which typically causes the corresponding requests to fail.
10298

10399
```yaml
104100
thread_pool:
@@ -114,6 +110,8 @@ The `scaling` thread pool holds a dynamic number of threads. This number is prop
114110

115111
The `keep_alive` parameter determines how long a thread should be kept around in the thread pool without it doing any work.
116112

113+
If a task is submitted to a `scaling` thread pool when its maximum number of threads are already busy with other tasks, the new task will be held in a queue for later execution. The queue in a `scaling` thread pool is always unbounded.
114+
117115
```yaml
118116
thread_pool:
119117
warmer:

docs/reference/elasticsearch/rest-apis/retrievers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,11 @@ Refer to [*Semantic re-ranking*](docs-content://solutions/search/ranking/semanti
560560

561561
### Prerequisites [_prerequisites_15]
562562

563-
To use `text_similarity_reranker`, you can rely on the preconfigured `.rerank-v1-elasticsearch` inference endpoint, which is based on [Elastic Rerank](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-rerank.html) and serves as the default if no `inference_id` is provided. This model is optimized for reranking based on text similarity. If you'd like to use a different model, you can set up a custom inference endpoint for the `rerank` task using the [Create {{infer}} API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put). The endpoint should be configured with a machine learning model capable of computing text similarity. Refer to [the Elastic NLP model reference](docs-content://explore-analyze/machine-learning/nlp/ml-nlp-model-ref.md#ml-nlp-model-ref-text-similarity) for a list of third-party text similarity models supported by {{es}}.
563+
To use `text_similarity_reranker`, you can rely on the preconfigured `.rerank-v1-elasticsearch` inference endpoint, which uses the [Elastic Rerank model](docs-content://explore-analyze/machine-learning/nlp/ml-nlp-rerank.md) and serves as the default if no `inference_id` is provided. This model is optimized for reranking based on text similarity. If you'd like to use a different model, you can set up a custom inference endpoint for the `rerank` task using the [Create {{infer}} API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put). The endpoint should be configured with a machine learning model capable of computing text similarity. Refer to [the Elastic NLP model reference](docs-content://explore-analyze/machine-learning/nlp/ml-nlp-model-ref.md#ml-nlp-model-ref-text-similarity) for a list of third-party text similarity models supported by {{es}}.
564564

565565
You have the following options:
566566

567-
* Use the built-in [Elastic Rerank](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) cross-encoder model via the inference API’s {{es}} service. For an example of creating an endpoint using the Elastic Rerank model, refer to [this guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-elasticsearch.html#inference-example-elastic-reranker).
567+
* Use the built-in [Elastic Rerank](docs-content://explore-analyze/machine-learning/nlp/ml-nlp-rerank.md) cross-encoder model via the inference API’s {{es}} service. See [this example](https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-elasticsearch.html#inference-example-elastic-reranker) for creating an endpoint using the Elastic Rerank model.
568568
* Use the [Cohere Rerank inference endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) with the `rerank` task type.
569569
* Use the [Google Vertex AI inference endpoint](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) with the `rerank` task type.
570570
* Upload a model to {{es}} with [Eland](eland://reference/machine-learning.md#ml-nlp-pytorch) using the `text_similarity` NLP task type.

docs/reference/query-languages/esql/_snippets/functions/examples/multi_match.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/multi_match.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/greatest.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)