Skip to content

Commit

Permalink
Honor masking of systemd-sysctl.service
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zeha committed Apr 21, 2017
1 parent a436597 commit f76cdc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions distribution/src/main/packaging/scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit f76cdc7

Please sign in to comment.