Skip to content

Commit

Permalink
Fix missing node id prefix in startup logs (#29534)
Browse files Browse the repository at this point in the history
When `node.name` is not set, some log traces at startup time does not
show the node id.
  • Loading branch information
tlrx committed Apr 19, 2018
1 parent 827d5ad commit 31a2db4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin>
// use temp logger just to say we are starting. we can't use it later on because the node name might not be set
Logger logger = Loggers.getLogger(Node.class, NODE_NAME_SETTING.get(environment.settings()));
logger.info("initializing ...");

}
try {
Settings tmpSettings = Settings.builder().put(environment.settings())
Expand All @@ -272,13 +271,13 @@ protected Node(final Environment environment, Collection<Class<? extends Plugin>
throw new IllegalStateException("Failed to create node environment", ex);
}
final boolean hadPredefinedNodeName = NODE_NAME_SETTING.exists(tmpSettings);
Logger logger = Loggers.getLogger(Node.class, tmpSettings);
final String nodeId = nodeEnvironment.nodeId();
tmpSettings = addNodeNameIfNeeded(tmpSettings, nodeId);
final Logger logger = Loggers.getLogger(Node.class, tmpSettings);
// this must be captured after the node name is possibly added to the settings
final String nodeName = NODE_NAME_SETTING.get(tmpSettings);
if (hadPredefinedNodeName == false) {
logger.info("node name [{}] derived from node ID [{}]; set [{}] to override", nodeName, nodeId, NODE_NAME_SETTING.getKey());
logger.info("node name derived from node ID [{}]; set [{}] to override", nodeId, NODE_NAME_SETTING.getKey());
} else {
logger.info("node name [{}], node ID [{}]", nodeName, nodeId);
}
Expand Down

0 comments on commit 31a2db4

Please sign in to comment.