Avoid failing install if system-sysctl is masked

On Debian-based systems the install scripts are run with set -e meaning
that if there is an error in executing one of these scripts then the
script fails. If systemd-sysctl is masked then trying to restart the
systemd-sysctl service to pick up the changes to vm.max_map_count will
fail leading to the post-install script failing. Instead, we should
account for the possbility of failure here by not letting the command to
restart this service exit with non-zero status code. This commit does
this, and adds a test for this situation.

Relates #25657
This commit is contained in:
Jason Tedor 2017-07-11 17:38:50 -04:00 committed by GitHub
parent 847378a43b
commit 3a827827c1
3 changed files with 14 additions and 2 deletions

View File

@ -49,7 +49,7 @@ esac
# to pick up /usr/lib/sysctl.d/elasticsearch.conf
if command -v systemctl > /dev/null; then
systemctl restart systemd-sysctl.service
systemctl restart systemd-sysctl.service || true
fi
if [ "x$IS_UPGRADE" != "xtrue" ]; then

View File

@ -186,3 +186,12 @@ setup() {
systemctl stop elasticsearch.service
}
@test "[SYSTEMD] masking systemd-sysctl" {
clean_before_test
systemctl mask systemd-sysctl.service
install_package
systemctl unmask systemd-sysctl.service
}

View File

@ -268,13 +268,16 @@ clean_before_test() {
userdel elasticsearch > /dev/null 2>&1 || true
groupdel elasticsearch > /dev/null 2>&1 || true
# Removes all files
for d in "${ELASTICSEARCH_TEST_FILES[@]}"; do
if [ -e "$d" ]; then
rm -rf "$d"
fi
done
if is_systemd; then
systemctl unmask systemd-sysctl.service
fi
}
purge_elasticsearch() {