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

Stop exporting HOSTNAME from scripts #25807

Merged
merged 1 commit into from
Jul 20, 2017

Conversation

jasontedor
Copy link
Member

Today we explicitly export the HOSTNAME variable from scripts. This is probably a relic from the days when the scripts were not run on bash but instead assume a POSIX-compliant shell only where HOSTNAME is not guaranteed to exist. Yet, bash guarantees that HOSTNAME is set so we do not need to set it in scripts. This commit removes this legacy.

Today we explicitly export the HOSTNAME variable from scripts. This is
probably a relic from the days when the scripts were not run on bash but
instead assume a POSIX-compliant shell only where HOSTNAME is not
guaranteed to exist. Yet, bash guarantees that HOSTNAME is set so we do
not need to set it in scripts. This commit removes this legacy.
@jasontedor jasontedor added :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts review v6.0.0 labels Jul 20, 2017
@jasontedor jasontedor requested a review from s1monw July 20, 2017 10:59
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

@jasontedor jasontedor merged commit 3042b5d into elastic:master Jul 20, 2017
@jasontedor jasontedor deleted the remove-hostname branch July 20, 2017 13:28
@shaharmor
Copy link

shaharmor commented Aug 17, 2017

Hey,
This PR removed support for using ${HOSTNAME} in the elasticsearch.yml config file for dynamically setting the node.name property.

Was this intentional? I'm pretty sure this is a rather newish feature. Ref: #9474

@jasontedor
Copy link
Member Author

@shaharmor It did not remove support for that, you can still set in the elasticsearch.yml and it will be observed. The only thing that it removed is ensuring that HOSTNAME is set by the startup scripts. We do not need to do this, bash guarantees that HOSTNAME is set (which is now required), and users can still it themselves explicitly in /etc/default/elasticsearch or /etc/sysconfig/elasticsearch if needed.

@shaharmor
Copy link

shaharmor commented Aug 17, 2017

Well, it doesn't work for me :) On ES 6 beta 1

This is my elasticsearch.yml file:

cluster.name: test
path.data: /data/elasticsearch
path.logs: /var/log/elasticsearch
discovery.zen.ping.unicast.hosts:
  - 'elasticsearch-data-001'
  - 'elasticsearch-data-002'
  - 'elasticsearch-data-003'

node.name: ${HOSTNAME}
node.master: true
node.data: true
node.max_local_storage_nodes: 1

network.host:
  - '_site_'
  - '_local_'

bootstrap.memory_lock: true
http.cors.enabled: true
http.cors.allow-origin: "*"

OS:

Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

And HOSTNAME is an existing environment variable:

root@elasticsearch-data-001:~# bash -c 'echo $HOSTNAME'
elasticsearch-data-001

When starting using systemctl restart elasticsearch.service, i'm getting the following error in journalctl -u elasticsearch.service:

Aug 17 11:22:38 elasticsearch-data-001 systemd[1]: Started Elasticsearch.
Aug 17 11:22:50 elasticsearch-data-001 elasticsearch[104026]: Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'HOSTNAME'
Aug 17 11:22:50 elasticsearch-data-001 elasticsearch[104026]:         at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:116)
Aug 17 11:22:50 elasticsearch-data-001 elasticsearch[104026]:         at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:69)
Aug 17 11:22:50 elasticsearch-data-001 elasticsearch[104026]:         at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1117)
Aug 17 11:22:51 elasticsearch-data-001 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 11:22:51 elasticsearch-data-001 systemd[1]: elasticsearch.service: Unit entered failed state.
Aug 17 11:22:51 elasticsearch-data-001 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.

This is after an apt-get dist-upgrade that upgraded ES from latest alpha to beta1. In the alpha it worked flawlessly.

@jasontedor
Copy link
Member Author

It's probably systemd, I'll take a look later. Would you mind opening a new issue with these details and ping me on it? Thanks for trying out the beta!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants