Skip to content

Commit b4ac570

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 fa42ae9 commit b4ac570

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

distribution/deb/src/main/packaging/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ case "$1" in
147147
ulimit -l $MAX_LOCKED_MEMORY
148148
fi
149149

150-
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
150+
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
151151
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
152152
fi
153153

distribution/rpm/src/main/packaging/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ start() {
114114
if [ -n "$MAX_LOCKED_MEMORY" ]; then
115115
ulimit -l $MAX_LOCKED_MEMORY
116116
fi
117-
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
117+
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
118118
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
119119
fi
120120

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
@@ -197,8 +197,7 @@ setup() {
197197
}
198198

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

0 commit comments

Comments
 (0)