You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by is...@apache.org on 2023/09/29 17:27:55 UTC

[solr] 01/03: SOLR-16644 Fixing the entropy warning threshold based on OS ubuntu and the kernel version

This is an automated email from the ASF dual-hosted git repository.

ishan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 0f7e067f916f49f4094f74c63512cd0accf9e2ca
Author: Raghavan Muthuregunathan <ra...@gmail.com>
AuthorDate: Tue Aug 15 01:42:51 2023 -0700

    SOLR-16644 Fixing the entropy warning threshold based on OS ubuntu and the kernel version
---
 solr/bin/solr | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/solr/bin/solr b/solr/bin/solr
index cc72f621094..9f2c858ac79 100644
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -1915,12 +1915,28 @@ function start_solr() {
         -jar start.jar "${SOLR_JETTY_CONFIG[@]}" $SOLR_JETTY_ADDL_CONFIG \
 	1>"$SOLR_LOGS_DIR/solr-$SOLR_PORT-console.log" 2>&1 & echo $! > "$SOLR_PID_DIR/solr-$SOLR_PORT.pid"
 
-    # check if /proc/sys/kernel/random/entropy_avail exists then check output of cat /proc/sys/kernel/random/entropy_avail to see if less than 300
-    if [[ -f /proc/sys/kernel/random/entropy_avail ]] && (( $(cat /proc/sys/kernel/random/entropy_avail) < 300)); then
-	echo "Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require"
-	echo "RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'."
-	echo ""
+  entropy_threshold=300
+  # Determine if the operating system is Ubuntu
+  os_name=$(lsb_release -is)
+  if [[ "$os_name" == "Ubuntu" ]]; then
+    # Get the kernel version
+    kernel_version=$(uname -r | awk -F. '{print $1"."$2}')
+    # Set entropy threshold based on kernel version
+    if [[ $(echo "$kernel_version >= 5.15" | bc) -eq 1 ]]; then
+      # For kernels 5.15 and newer
+      entropy_threshold=64  # Adjusted for 256 pool size (approx 25% of 256)
+    else
+      # For older kernels
+      entropy_threshold=300  # Original threshold for 4096 pool size
     fi
+  fi
+
+        # Check entropy and display warning if below threshold
+    if [[ -f /proc/sys/kernel/random/entropy_avail ]] && (( $(cat /proc/sys/kernel/random/entropy_avail) < $entropy_threshold)); then
+      echo "Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require"
+      echo "RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'."
+    fi
+
     # no lsof on cygwin though
     if lsof -v 2>&1 | grep -q revision; then
       echo -n "Waiting up to $SOLR_START_WAIT seconds to see Solr running on port $SOLR_PORT"