Skip to content

Commit 909a18a

Browse files
majormosesjasontedor
authored andcommitted
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.
1 parent 9ac81a1 commit 909a18a

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

distribution/packages/src/deb/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ case "$1" in
122122
ulimit -l $MAX_LOCKED_MEMORY
123123
fi
124124

125-
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
125+
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
126126
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
127127
fi
128128

distribution/packages/src/rpm/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ start() {
9090
if [ -n "$MAX_LOCKED_MEMORY" ]; then
9191
ulimit -l $MAX_LOCKED_MEMORY
9292
fi
93-
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
93+
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
9494
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
9595
fi
9696

qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ setup() {
178178
}
179179

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

0 commit comments

Comments
 (0)