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

Restore printing bootstrap checks as errors #93178

Merged
merged 3 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/93178.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 93178
summary: Restore printing bootstrap checks as errors
area: Infra/CLI
type: bug
issues:
- 93074
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.cli.ExitCodes;
import org.elasticsearch.common.settings.SecureSettings;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.NodeValidationException;

import java.io.PrintStream;

import static org.elasticsearch.bootstrap.BootstrapInfo.USER_EXCEPTION_MARKER;

/**
* A container for transient state during bootstrap of the Elasticsearch process.
*/
Expand Down Expand Up @@ -71,10 +71,10 @@ Environment environment() {
return nodeEnv.get();
}

void exitWithUserException(int exitCode, Exception e) {
err.print(USER_EXCEPTION_MARKER);
Copy link
Contributor

Choose a reason for hiding this comment

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

The stderr pump thread looks for this marker, I wonder if this changes that behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

It slightly changes the error path, but it effectively doesn't change the result because the pump still exits after the stream is closed, which happens when we exit the main process.

I plan to create a followup to remove USER_EXCEPTION_MARKER as it is now no longer used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see now, the error pump finally has the latch decrement.

err.println(e.getMessage());
gracefullyExit(exitCode);
void exitWithNodeValidationException(NodeValidationException e) {
Logger logger = LogManager.getLogger(Elasticsearch.class);
logger.error("node validation exception\n{}", e.getMessage());
gracefullyExit(ExitCodes.CONFIG);
}

void exitWithUnknownException(Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.lucene.util.StringHelper;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.cli.ExitCodes;
import org.elasticsearch.common.ReferenceDocs;
import org.elasticsearch.common.filesystem.FileSystemNatives;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
Expand Down Expand Up @@ -68,7 +67,7 @@ public static void main(final String[] args) {
initPhase2(bootstrap);
initPhase3(bootstrap);
} catch (NodeValidationException e) {
bootstrap.exitWithUserException(ExitCodes.CONFIG, e);
bootstrap.exitWithNodeValidationException(e);
} catch (Throwable t) {
bootstrap.exitWithUnknownException(t);
}
Expand Down