Browse Source

Only set vm.max_map_count if greater than default (#31512)

So the issue here is that we want to avoid setting vm.max_map_count if
it is already equal to the desired value (the bootstrap check requires
262144). The reason we want to avoid this is because in some use-cases
using sysctl to set this will fail. In this case, we want to enable
users to set this value externally and then allow that to cause using
sysctl to set the value to be skipped so that cases where using sysctl
will fail to no longer fail.
Ben Abrams 7 years ago
parent
commit
909a18add7

+ 1 - 1
distribution/packages/src/deb/init.d/elasticsearch

@@ -122,7 +122,7 @@ case "$1" in
 		ulimit -l $MAX_LOCKED_MEMORY
 	fi
 
-	if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
+	if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
 		sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
 	fi
 

+ 1 - 1
distribution/packages/src/rpm/init.d/elasticsearch

@@ -90,7 +90,7 @@ start() {
     if [ -n "$MAX_LOCKED_MEMORY" ]; then
         ulimit -l $MAX_LOCKED_MEMORY
     fi
-    if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
+    if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -gt $(cat /proc/sys/vm/max_map_count) ]; then
         sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
     fi
 

+ 1 - 2
qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats

@@ -178,8 +178,7 @@ setup() {
 }
 
 # Ensures that if $MAX_MAP_COUNT is greater than the set vaule on the OS
-# we do not attempt to update it this should cover equality as well as I think
-# we can trust that equality operators work as intended.
+# we do not attempt to update it.
 @test "[INIT.D] sysctl is not run when it already has a larger or equal value set" {
   # intentionally set to the default +1
   sysctl -q -w vm.max_map_count=262145