From f76cdc73fa533b61ff2378b6d34d0ede286215a3 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Fri, 21 Apr 2017 09:32:18 +0200 Subject: [PATCH] Honor masking of systemd-sysctl.service During package install on systemd-based systems, some sysctl settings should be set (e.g. vm.max_map_count). In some environments, changing sysctl settings plainly does not work; previously a global environment variable named ES_SKIP_SET_KERNEL_PARAMETERS was introduced to skip calling sysctl, but this causes trouble for: * configuration management systems, which usually cannot apply an env var when running a package manager * package upgrades, which will not have the env var set any more, and thus leaving the package management system in a bad state (possibly half-way upgraded, can be very hard to recover) This removes the env var again and instead of calling systemd-sysctl manually, tells systemd to restart the wrapper unit - which itself can be masked by system administrators or management tools if it is known that sysctl does not work in a given environment. The restart is not silent on systems in their default configuration, but is ignored if the unit is masked. --- distribution/src/main/packaging/scripts/postinst | 13 ++----------- .../install/skip-set-kernel-parameters.asciidoc | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/distribution/src/main/packaging/scripts/postinst b/distribution/src/main/packaging/scripts/postinst index 86f2baadb9483..07e6553313193 100644 --- a/distribution/src/main/packaging/scripts/postinst +++ b/distribution/src/main/packaging/scripts/postinst @@ -48,17 +48,8 @@ case "$1" in esac # to pick up /usr/lib/sysctl.d/elasticsearch.conf -if [ "${ES_SKIP_SET_KERNEL_PARAMETERS:-false}" == "false" ]; then - if command -v /usr/lib/systemd/systemd-sysctl > /dev/null; then - /usr/lib/systemd/systemd-sysctl - elif command -v /lib/systemd/systemd-sysctl > /dev/null; then - /lib/systemd/systemd-sysctl - fi -elif [ "$ES_SKIP_SET_KERNEL_PARAMETERS" == "true" ]; then - echo "skipping setting kernel parameters" -else - echo "unrecognized value [$ES_SKIP_SET_KERNEL_PARAMETERS] for ES_SKIP_SET_KERNEL_PARAMETERS; must [false] (default) or [true]" - exit 1 +if command -v systemctl > /dev/null; then + systemctl restart systemd-sysctl.service fi if [ "x$IS_UPGRADE" != "xtrue" ]; then diff --git a/docs/reference/setup/install/skip-set-kernel-parameters.asciidoc b/docs/reference/setup/install/skip-set-kernel-parameters.asciidoc index 56406fce98729..32faabc4b0894 100644 --- a/docs/reference/setup/install/skip-set-kernel-parameters.asciidoc +++ b/docs/reference/setup/install/skip-set-kernel-parameters.asciidoc @@ -1,2 +1,2 @@ NOTE: On systemd-based distributions, the installation scripts will attempt to set kernel parameters (e.g., -`vm.max_map_count`); you can skip this by setting the environment variable `ES_SKIP_SET_KERNEL_PARAMETERS` to `true`. +`vm.max_map_count`); you can skip this by masking the systemd-sysctl.service unit.