Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server cli to always pass through exit code #104943

Merged
merged 3 commits into from Jan 31, 2024

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Jan 30, 2024

In certain circumstances if Elasticsearch encounters an error while starting up, the server cli may exit with no error. This commit fixes the cli to always check and wait on the Elasticsearch process and exit with the same exit code.

relates #104055

A previous refactoring remove the user exception messages once passed
back from Elasticsearch. However, ES may still die while starting up,
and the cli needs to itself exit nicely when that happens. This commit
passes back the ready state of ES when checked in the cli.

relates elastic#104055
@rjernst rjernst added >bug :Core/Infra/CLI CLI utilities, scripts, and infrastructure labels Jan 30, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @rjernst, I've created a changelog YAML for you.

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rjernst, code looks good to me 💯
Only the javadocs should be adjusted accordingly

@@ -54,12 +54,12 @@ class ErrorPumpThread extends Thread {
* @return a bootstrap exeption message if a bootstrap error occurred, or null otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return a bootstrap exeption message if a bootstrap error occurred, or null otherwise
* @return {@code true} if successful, {@code false} if a bootstrap error occurred

@@ -54,12 +54,12 @@ class ErrorPumpThread extends Thread {
* @return a bootstrap exeption message if a bootstrap error occurred, or null otherwise
* @throws IOException if there was a problem reading from stderr of the process
*/
String waitUntilReady() throws IOException {
boolean waitUntilReady() throws IOException {
nonInterruptibleVoid(readyOrDead::await);
if (ioFailure != null) {
throw ioFailure;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently you have waitUntilReady rethrowing exceptions. That would not wait for the forked process to exit, nor convert that exception into a UserException as the existing code does.

Just a question regarding your point on the expected behavior on IOExceptions, currently these are rethrown as UncheckedIOException in ServerProcessBuilder. Are we good keeping it like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for now, yes. The way we get to an IOException is, afaik, a broken pipe. That could happen because of bad code, or because ES got a SIGKILL (I think?). Perhaps we should provide a "nicer" message to users in this case than an exception stacktrace, but I leave that for a future discussion/PR.

@rjernst rjernst added the auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jan 31, 2024
@elasticsearchmachine elasticsearchmachine merged commit 125c1c8 into elastic:main Jan 31, 2024
15 checks passed
@rjernst rjernst deleted the cli/ready_check branch January 31, 2024 17:28
jedrazb pushed a commit to jedrazb/elasticsearch that referenced this pull request Feb 2, 2024
In certain circumstances if Elasticsearch encounters an error while
starting up, the server cli may exit with no error. This commit fixes
the cli to always check and wait on the Elasticsearch process and exit
with the same exit code.

relates elastic#104055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug :Core/Infra/CLI CLI utilities, scripts, and infrastructure Team:Core/Infra Meta label for core/infra team v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants