-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
Add systemd support #478
Add systemd support #478
Conversation
This seems to break if you run |
This is what you get without tests :) Sorry about that. I will update the PR to allow the template to be overridden in a similar fashion. I think i will also switch from this drop-in snippet approach to just overriding the whole elasticsearch service unit file, which also saves creating a dir in /etc/systemd/system. |
For what it's worth, the local test-kitchen suite is how I found this one (I added a CentOS 7.x distro to the platforms we test against). We don't run them on CI, because they take forever, though. |
any progress on getting this merged? this is kind of annoying to be missing on rhel/centos7. Also, it breaks bootstrap.mlockall: true i also noticed a minor issue which is that if you previously enabled the systemd service, it will keep trying to start/stop the script provided by the RPM in /usr/lib/systemd/system rather than the new one in /etc. after disabling/re-enabling it was fine though. this should probably only matter for people who didn't have this update. not sure there's a good fix for that. |
Found another bug, which is that ES 1.6.x doesn't have the file used by the ExecStartPre thing here: #ExecStartPre=<%= @ES_HOME %>/bin/elasticsearch-systemd-pre-exec Given that all this file does is check if the config file was changed from the default and spew an error, and chef manages the file anyway, i just commented it out. |
Also, heap size isn't getting set.... |
Have you thought of using systemd drop-ins to change the parameter? i.e. instead of having to template the entire systemd startup file use create a directory see: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
It looks similar to this:
The content of the file would look like
|
Hi there -- it looks like this doesn't pass for at least 2 of the test-kitchen suites. Have you also considered using the new |
@martinb3 the The test failures are due to I can solve this in two ways:
<% if ::File.exists?("#{@ES_HOME}/bin/elasticsearch-systemd-pre-exec") %>
ExecStartPre=<%= @ES_HOME %>/bin/elasticsearch-systemd-pre-exec
<% end -%>
Please let me know your preference. I also have a pending fix for ES_HEAP_SIZE etc. not being set which i will commit together with what we decide on the former issue. |
why not just do, just curious
|
because that script is not included with every version of elasticsearch and it will fail on some versions if you leave it like that. please see my comments from earlier |
I'm concerned we may be trying to support systemd a bit too early; what if we include a flag for which init system to use, and try to give it smart defaults? And then if systemd is selected, we use Also, the systemd functionality as-is seems to be broken if you try to deploy multiple instances on a single system (the test-kitchen tests confirm this). I apologize for the slow responses -- I'm trying to wrap my head around this :) |
@martinb3 I have fixes pending for the test kitchen issues, just waiting on your input on which of the proposed fixes have your preference. But I'll prep an update based on option 2 in the meantime. |
…ES_HOME>/bin/elasticsearch-systemd-pre-exec' exists
@hrak If |
the problem with the systemd-pre-exec script is that its included in 2.x but not 1.6.x or etc... |
Indeed, |
I've tried this with a fedora system, using package install, and it fails because there's no applicable template for a tradicional init.d script. If systemd is detected, shouldn't the init.d script be skipped? |
I believe the current Elasticsearch packages still ship an init.d script, regardless of what init system is used. I'm guessing it's there for compatibility or fallback (you could use systemd or the wrapper to start the service). |
I meant tarball install, sorry! The problem is that elasticseach_service is trying to create an init.d script, and it can't find an appropriate template. |
@adagios What version of Fedora? We can probably support that as well, but we might want to open it as a separate issue. We don't currently test against Fedora either. |
@martinb3 the issue is not really specific to Fedora. As part of supporting systemd, I think it shouldn't create the init.d script. This would make it work on all systemd installations, regardless of the existence or not of an, unneeded, init.d script template. |
@adagios not sure I agree with this:
For example Ubuntu 15.10 supported sysvinit, upstart, and systemd, I don't necessarily agree that just because systemd is available we should ignore the packages behavior. The package maintainers spent time on deciding the "best" defaults and this cookbook tries to mirror this. If you want something different then you can always alter the behavior in your wrapper. |
@majormoses I agree with you. It should not ignore the packages behaviour. What I'm defending is that it should not error out if it only knows how to create one type of init script. If it knows how to create a systemd script, it should not give up on a systemd server because it doesn't know how to create an init.d script. |
- Drop support for ES < 5.0 * Remove the shield/watcher plugin installs, since they have become x-pack in ES 5.0 * Remove hashes and different download URLs, other logic that distinguishes between 1.x and 2.x. * Update README.md to reflect that this change drops support for < 5.0 (too many changes) - elasticsearch_install: * Drop warnings for installing as root under ES < 2.0 - elasticsearch_configure: * Replace logging.yml with new log4j2.properties file, add template for this * Update variables that are allowed in /etc/sysconfig/elasticsearch or /etc/default/elasticsearch * Drop ES_JAVA_OPTS and introduce option 'jvm_options' with new template for /etc/elasticsearch/jvm.options * Add new restart_on_upgrade option, drop thread_stack_size, drop env_options, drop gc_settings * Drop some of the defaults in elasticsearch.yml that are no longer present in upstream packaging - elasticsearch_plugin: * change bin/plugin to bin/elasticsearch-plugin when managing plugins * Remove the shield/watcher plugin installs, since they have become x-pack in ES 5.0 * Add new `options` parameter/attribute so that you can pass things like `--batch` to this resource - elasticsearch_service: * Introduce systemd unit files for distros that support them * Guard on which init systems based on presence of /etc/init.d or /usr/lib/systemd/system directories Fixes #424. Fixes #478. Fixes #503.
- Drop support for ES < 5.0 * Remove the shield/watcher plugin installs, since they have become x-pack in ES 5.0 * Remove hashes and different download URLs, other logic that distinguishes between 1.x and 2.x. * Update README.md to reflect that this change drops support for < 5.0 (too many changes) - elasticsearch_install: * Drop warnings for installing as root under ES < 2.0 - elasticsearch_configure: * Replace logging.yml with new log4j2.properties file, add template for this * Update variables that are allowed in /etc/sysconfig/elasticsearch or /etc/default/elasticsearch * Drop ES_JAVA_OPTS and introduce option 'jvm_options' with new template for /etc/elasticsearch/jvm.options * Add new restart_on_upgrade option, drop thread_stack_size, drop env_options, drop gc_settings * Drop some of the defaults in elasticsearch.yml that are no longer present in upstream packaging - elasticsearch_plugin: * change bin/plugin to bin/elasticsearch-plugin when managing plugins * Remove the shield/watcher plugin installs, since they have become x-pack in ES 5.0 * Add new `options` parameter/attribute so that you can pass things like `--batch` to this resource - elasticsearch_service: * Introduce systemd unit files for distros that support them, copy latest init scripts for all platforms * Guard on which init systems based on presence of /etc/init.d or /usr/lib/systemd/system directories Fixes #424. Fixes #478. Fixes #503.
This PR addresses the systemd part of #424
It installs a systemd unit file that overrides some settings of the default systemd service installed by the package. This is needed because the systemd service installed by the package (/usr/lib/systemd/system/elasticsearch.service) has a hardcoded setting for LimitNOFILE (65535) and does not configure LimitMEMLOCK.
With this PR the settings supplied to elasticsearch_configure are correctly applied on a systemd based system.
Tested on Ubuntu 16.04 and CentOS 7. I did not add tests yet because there is an issue with the Ubuntu 16.04 chef/bento box at the moment (See chef/bento#609)