Warning when starting Gerrit JVM without OOM protection

When gerrit.sh gets started from a non-root user, the JVM PID is not
protected against the Kernel OOM killer attacks.
Instead of silently ignoring the setting, display a warning making aware
of the danger and telling the user what to do.

Bug: Issue 9514
Change-Id: I4c1c0e06b260e75d900f436d37f0b91d031cd24e
This commit is contained in:
Luca Milanesio
2018-08-01 15:58:13 -07:00
parent 63899d219e
commit 727a856753

View File

@@ -439,6 +439,11 @@ case "$ACTION" in
echo -16 > "/proc/${PID}/oom_adj"
fi
fi
elif [ "$(uname -s)"=="Linux" ] && test -d "/proc/${PID}"; then
echo "WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer,"
echo " one of the possible causes are ${0} not run as root."
echo " Consider changing the OOM score adjustment manually for Gerrit's PID=${PID} with e.g.:"
echo " echo '-1000' | sudo tee /proc/${PID}/oom_score_adj"
fi
TIMEOUT="$GERRIT_STARTUP_TIMEOUT"