From d7506b8ad4b7c3dbc448aa80dd25fc62791fd3b4 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:46:12 +0200 Subject: [PATCH] Correctly apply fix for high ulimit Commit c70621735d71c9862c5c030bca7152d6bb9b829c changed this logic so that it no longer works correctly: * `-SV` modified virtual memory, not file descriptors * The if check doesn't take the current ulimit into consideration, though it succeeds anyways --- NodeBase/start-novnc.sh | 12 +++++++----- NodeBase/start-vnc.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/NodeBase/start-novnc.sh b/NodeBase/start-novnc.sh index c3cb4efa6..4fc8d9e48 100755 --- a/NodeBase/start-novnc.sh +++ b/NodeBase/start-novnc.sh @@ -7,12 +7,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then if [ "${START_NO_VNC:-$SE_START_NO_VNC}" = true ] ; then # Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045 - ULIMIT=${SE_VNC_ULIMIT:-100000} - if [[ ${ULIMIT} -ge 100000 ]]; then - echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}." - ulimit -Sv ${ULIMIT} + # Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit + TOO_HIGH_ULIMIT=100000 + if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then + NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}} + echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}." + ulimit -n ${NEW_ULIMIT} if [ $? -eq 0 ]; then - echo "Successfully update the open file descriptor limit." + echo "Successfully updated the open file descriptor limit." else echo "The open file descriptor limit could not be updated." fi diff --git a/NodeBase/start-vnc.sh b/NodeBase/start-vnc.sh index c4419b0a1..ae96bd38f 100755 --- a/NodeBase/start-vnc.sh +++ b/NodeBase/start-vnc.sh @@ -45,12 +45,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then done # Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045 - ULIMIT=${SE_VNC_ULIMIT:-100000} - if [[ ${ULIMIT} -ge 100000 ]]; then - echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}." - ulimit -Sv ${ULIMIT} + # Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit + TOO_HIGH_ULIMIT=100000 + if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then + NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}} + echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}." + ulimit -n ${NEW_ULIMIT} if [ $? -eq 0 ]; then - echo "Successfully update the open file descriptor limit." + echo "Successfully updated the open file descriptor limit." else echo "The open file descriptor limit could not be updated." fi